A CPU serving bundle for a demo. It maps a product photo and/or a product title to a 10-digit
US Harmonized Tariff Schedule (HTS) code and returns a ≤30-character customs description, alternates,
a confidence score, an abstain flag, and the nearest past customs rulings as justification.
It runs on onnxruntime + tokenizers + numpy (no torch; the reranker's trees are evaluated in numpy).
On 4 CPU threads: under 1 GB RSS, about 30–45 ms per text query including reranking, and about 250 ms with a photo.
Bundle version: r4 + reranker.
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 it against the HTS and with a licensed broker.
It retrieves and reranks rather than using a softmax classifier:
MatMulNBits (block 128).norm(0.2·image + 0.8·text).lambdarank, 250 trees × 7 leaves, monotone constraints) rescores
the top 30 candidates with 24 features: fused rank and score, leaf gap, per-level ruling
votes, keyword (BM25) match against the leaf text and plain-language aliases, "Other"-bucket
and sibling counts, and stated-fact checks (gender, fiber, knit/woven, quantities). It was trained only on 2023 validation rulings plus half of an extra CBP set,
using 5-fold out-of-fold training grouped by gold code. Benchmarks and 2024+ test rulings were never in its training data.| file | what |
|---|---|
text.onnx |
fine-tuned text tower, weight-only 8-bit (input input_ids, batch 1, ≤256 tokens) |
vision.onnx |
jina-clip-v1 vision tower, weight-only 8-bit (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 |
rerank.json |
reranker trees, feature list, softmax temperature (T = 2), abstain threshold |
rr_aliases.json |
plain-language aliases per leaf, used by the reranker's keyword features |
meta.json |
serving settings (max_tokens) |
Serving code: hts/serve.py and hts/engine.py in the project repository.
A prediction counts as correct only if it matches the gold code to the stated depth. Every query is in the denominator, so a ruling whose gold code is shorter than 10 digits counts as a 10-digit miss. Training uses US rulings dated 2022 or earlier; validation uses 2023; the test sets use 2024 or later. Near-duplicate rulings are merged before scoring. Intervals are 95% Wilson intervals.
| set | n | R@10 | top-1 HS6 | top-1 10-digit |
|---|---|---|---|---|
| US CBP rulings 2024+, full description | 2,855 | 0.890 | 0.658 | 0.415 |
| US CBP rulings 2024+, short description | 2,480 | 0.787 | 0.533 | 0.304 |
| HSCodeComp (product titles, text only) | 632 | 0.752 | 0.503 [0.464, 0.542] | 0.342 [0.306, 0.380] |
| ATLAS test (product titles) | 200 | 0.710 | 0.540 [0.471, 0.608] | 0.335 [0.273, 0.403] |
What the reranker adds over the fused shortlist on the same bundle: +0.6 to +2.5 points top-1 10-digit on the test sets (−0.3 on out-of-fold validation), +2 to +5 points R@10, and fewer clarifying questions. On 500 real listings, questions per answer dropped from 1.04 to 0.73.
Real marketplace listings (500 product pages; gold = the depth at which two independent LLM labelers agreed, usually 4–6 digits; this set was also used for model selection): 0.784 top-1.
Photos:
Abstain threshold: abstain when the top HS6 mass is below 0.375. On out-of-fold validation the model answers 56% of queries, with 74% HS6 precision on those answers. This is a probability mass, not a calibrated probability of being correct. Calibration has not been checked on the test sets or on photo inputs.
All results are from a single training seed. Quantization was validated end to end on an earlier model (within about 1 point; top-1 agreement with fp32 0.99). The numbers above are measured through the shipped 8-bit stack.
Ruling snippets in pool.parquet and the training data come from:
orlandowhite/hts-cross-rulings
and fklc/cbp-rulings-past-2012 (MIT) datasets.rr_aliases.json.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