CPU serving bundle for a demo that maps a product photo and/or a product title to a 10-digit
US Harmonized Tariff Schedule (HTS) code, a ≤30-character customs description, alternates,
a calibrated confidence and the nearest past customs rulings as justification.
Runs on onnxruntime + tokenizers + numpy (no torch), ~615 MB RSS, ~30 ms per text query
and ~250 ms with an image on 4 CPU threads.
Not legal advice. Classification depends on facts a photo or title may not show (material, function, composition). Use the output as a starting point and confirm with the HTS and a licensed broker.
Retrieval, not a softmax classifier:
MatMulNBits (top-1 agreement with fp32: 0.99).| file | what |
|---|---|
text.onnx |
fine-tuned text tower, weight-only int8 (input input_ids, batch 1, ≤96 tokens) |
vision.onnx |
jina-clip-v1 vision tower, weight-only int8 (input pixel_values [1,3,224,224]) |
tokenizer.json |
tokenizer for text.onnx |
image_adapter.npz |
W, b, gap of the image adapter |
index.npz |
PCA matrix (768→256) and per-dim int8 scales |
score_leaf.onnx, score_pool.onnx |
int8 GEMM scorers holding the leaf / ruling embeddings |
leaves.parquet |
HTS leaf codes, descriptions, paths (HTS revision downloaded 2026-11-12) |
pool.parquet |
ruling snippets: label (code), source, text |
Serving code: hts/serve.py (FastAPI router) in the project repository.
A retrieved code counts only if it is at least as specific as the gold code and starts with it. Test rulings are dated 2024 or later; training rulings 2022 or earlier.
| set | n | R@10 | top-1 HS6 | top-1 10-digit |
|---|---|---|---|---|
| US CBP rulings 2024+, full description | 2,856 | 0.862 | 0.652 | 0.505 |
| US CBP rulings 2024+, short description | 2,856 | 0.765 | 0.553 | 0.402 |
| HSCodeComp (product titles) | 632 | 0.715 | 0.422 | 0.274 |
| ATLAS test (product titles) | 200 | 0.635 | 0.535 | 0.325 |
Images (ABO product photos, 725 items / 29 product types, heading-level): image only 0.65 top-1 heading (0.92 in top 10); image + title 0.84.
HS6 confidence is calibrated on validation: at confidence ≥ 0.4, 50% of queries are answered with 74% HS6 accuracy; at ≥ 0.9, 95%.
Ruling snippets in pool.parquet and training data came from:
orlandowhite/hts-cross-rulings
and fklc/cbp-rulings-past-2012 (MIT) datasets.Base model: jinaai/jina-clip-v1 (Apache-2.0).
text.onnx 144 MBvision.onnx 102 MBscore_pool.onnx 52 MBscore_leaf.onnx 5 MBimage_adapter.npz 2 MBindex.npz 789.2 kBjinaai/jina-clip-v1