← All posts

STAYCHARTED BLOG · Machine learning · Rules and automation

Keyword tables vs machine learning for UNSPSC, HS and product codes

Keyword tables assign codes until descriptions vary. When a model trained on your past coding does better for UNSPSC, HS and catalog codes, and when not.

By Manoj Mohandas ·

Why keyword tables break on codes

  • Codes are fine-grained. UNSPSC distinguishes detailed commodities, while the HS system has more than 5,600 six-digit groups of goods. A table that covers the common ones misses the long tail.
  • Words mean different things. "Cable" is electrical wire, a computer cable or a steel cable. "Sleeve" is clothing, packaging or a pipe fitting.
  • Descriptions are messy. Supplier abbreviations, part numbers and units ("CBL CAT6 SFTP 305M BX") don't match a clean keyword.
  • Order and conflicts. When "laptop" and "bag" both match, the table's order decides between a computer and a laptop bag.
  • No confidence. The table can't say "I'm not sure", so a wrong code flows into a spend report or a customs entry.

What a trained model does instead

A model trained on lines your team already coded learns how your descriptions map to your codes, including abbreviations and supplier wording. It suggests a code with a confidence, and the unsure ones go to a specialist.

  • It learns your level of detail. Train on the level you actually use, such as UNSPSC class or HS six-digit, not more.
  • It's measured per code on lines it never saw, so you know where it's reliable.
  • It improves from corrections in the Review Queue.

We measured this for HS codes on public customs rulings: HS code classification benchmark →

Where a rule should stay

  • Legal determinations. A customs classification is the importer's responsibility. Use the model to suggest and a licensed broker or specialist to decide on anything uncertain or high-duty.
  • Exact identifiers. If a part number or GTIN maps to one code, a lookup table is exact. Use it first.
  • Policy overrides. "All items from this program code to X."

The order that works: exact lookups first, then the model, then a person for anything below the cutoff.

How to decide, with your own numbers

  1. Export coded lines: description, supplier, any attributes, and the final code.
  2. Train on everything before last quarter; test on last quarter.
  3. Run your keyword table on the same lines and compare both with the final codes.
  4. Keep the table for codes where it wins; let the model handle the rest.

Explore the rules vs machine learning series

Common questions

Can a model assign UNSPSC codes it has never seen?

No. It suggests codes from your history. For codes you've never used, keep a rule or a person, or add examples.

Is a model accurate enough for customs?

It can make the first suggestion and flag the unsure ones. The classification decision and its legal responsibility stay with the importer and their broker. This isn't legal advice; check with your customs advisor.

What about a large language model?

A general AI assistant can classify descriptions, but it does not automatically know your coding history, and answers may vary with prompts or model changes. A published StayCharted classifier uses a fixed model version measured on your examples. Compare both on the same held-out records. Asking an assistant vs training a classifier →

Sources and further reading

Put it into practice with StayCharted

Start free →

Check plans and allowances · Security and your data