Trie-Constrained Token Prediction with Hierarchy-Aware Semantic Alignment for HS Code Prediction

📅 2026-08-05
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the challenges faced by small language models in Harmonized System (HS) code prediction, where they frequently generate invalid codes and struggle to capture the semantic relationships between product descriptions and the hierarchical structure of HS codes, limiting their applicability in resource-constrained settings. To overcome these limitations, the study introduces a novel approach that integrates Trie-based constrained decoding with a hierarchy-aware semantic alignment (HSA) mechanism. This method guides generation strictly within the space of valid HS codes while explicitly aligning multi-level semantics between product texts and the HS taxonomy. Using only sub-billion-parameter models, the proposed approach achieves a 49.96 percentage point improvement in HS6 accuracy over zero-shot inference and outperforms the strongest task-specific baseline by 11.94 percentage points on real-world port data, demonstrating the feasibility of deploying highly accurate yet efficient HS code prediction systems.
📝 Abstract
Harmonized System (HS) code prediction (HSP) from commodity text is essential to international trade, and its importance continues to grow in port logistics. For the purposes of such prediction, recently, large language models (LLMs) have been actively investigated, owing especially to their strong language-understanding capabilities. However, their high computational cost limits deployment in constrained environments such as container terminals. Small language models (SLMs) offer a practical alternative, but their smaller scale makes them prone to generating invalid HS codes and to overlooking the hierarchical semantics between commodity text and HS codes. To address these limitations, this study proposes TRIE-HSA, which combines trie-constrained token prediction with hierarchy-aware semantic alignment (HSA). This method constrains the SLM to predict only valid digits under the HS taxonomy and aligns commodity text representations with the hierarchical structure of HS codes. In extensive experiments on data collected from an operational container terminal, TRIE-HSA improved average HS6 accuracy by 49.96 %p over zero-shot inference and exceeded the strongest task-specific benchmark by 11.94 %p. These results demonstrate that accurate and structurally valid HSP is achievable with fewer than 10 billion parameters. Therefore, TRIE-HSA offers a practical basis for deployment of HSP in port logistics operations that cannot support largescale LLMs.
Problem

Research questions and friction points this paper is trying to address.

HS code prediction
small language models
hierarchical semantics
invalid code generation
port logistics
Innovation

Methods, ideas, or system contributions that make the work stand out.

trie-constrained decoding
hierarchy-aware semantic alignment
HS code prediction
small language models
structured output generation
🔎 Similar Papers
No similar papers found.