Abstract
Modern economic analyses often require linking centuries-old U.S. tariff schedules — written in archaic prose and coded under multiple, now-obsolete systems — to today's eight-digit Harmonized System (HS). I present the first fully automated concordance that threads every tariff line from the 1789 Tariff Act through four major coding overhauls into the 2023 HS vocabulary. The pipeline "walks" backwards one calendar year at a time: each description is (i) modernized with a GPT-4 prompt, (ii) embedded with the sentence-transformer MPNet, and (iii) matched to its nearest neighbor in the previous year using a composite similarity score. When that score dips below a specified threshold, I first apply a hierarchical HS fallback — matching at the 2-, 4-, or 6-digit level appropriate to the historical regime — before any remaining low-confidence records trigger a Selenium-based query to the U.S. Census HS-Classifier, with GPT selecting among the most probable codes the website outputs. On three public schedules — 1789 (free text), 1963 (TSUS-8), and 1989 (HS-8) — the method attains 65%, 75%, and 90% similarity scores respectively. The resulting open-source concordance and Python package let researchers map any historical description to a ranked list of 2023 HS codes with confidence scores, enabling consistent long-run trade analyses without manual recoding.
Introduction
U.S. trade policy has evolved dramatically over the last 250 years, and its history is recorded in a fragmented stack of tariff schedules: the 1789 Tariff Act lists goods in plain English with no numeric code; the 1930 Smoot–Hawley schedule introduces paragraph-level structure; the TSUS arrives in 1963 with an 8-digit code; the TSUSA layers an annotated revision in 1972; and the U.S. finally adopts the international Harmonized System (HS) on 1 January 1989, with WCO-led revisions every five years thereafter. Researchers studying long-run trade policy face the obvious problem: a "1789 nutmeg" line and a "2023 nutmeg, crushed or ground" line look like the same product, but they live in entirely different vocabularies, and there is no canonical mapping between them.
I built this pipeline as my SuperUROP at MIT Political Science to close that gap. The motivating use case is concrete: an economic historian wants to compare U.S. import duty patterns from the early Republic to the modern day, and currently has to do that alignment by hand, line by line, across hundreds of thousands of records. Prior NLP work has tackled product-description matching for clean modern e-commerce data, and a separate strand of research has tackled historical text normalization (orthographic drift, archaic spellings). What was missing was a single system that handled both at once — language drift across centuries, plus successive reorganizations of the underlying classification scheme.
The contribution of this work is threefold. First, an iterative back-mapping procedure that "walks" backward one year at a time from 2023 to 1789 rather than attempting a single-shot direct match — short hops absorb each year's small revisions and avoid the semantic cliff a direct 1789-to-2023 comparison would produce. Second, a hybrid verification fallback that, for the small fraction of low-confidence matches, queries the U.S. Census HS-Classifier via Selenium and uses GPT to pick the right code from the site's drop-down output. Third, an open-source Python package that accepts any historical tariff description and returns a ranked list of 2023 HS codes with confidence scores, plus the full machine-readable concordance.
Approach
The system has four cooperating components. A Selenium scraper pulls historical schedules from the U.S. International Trade Commission and Census archives. A GPT-4 prompt modernizes archaic phrasing one year at a time, so the back-walk never has to bridge more than ~12 months of linguistic drift. An MPNet sentence-transformer (specifically all-mpnet-base-v2) produces L2-normalized embeddings of every description. And a composite similarity score combines cosine similarity on the embeddings with two character-level signals, which together govern when the pipeline trusts an automatic match versus falling through to verification.
The core back-mapping step works like this. Starting from the fully coded 2023 schedule (initialized from the 2024 ground-truth HS list), I compute MPNet embeddings for every line in year N. Each year-N vector is then compared against the pre-computed embedding matrix for year N+1. Cosine similarity alone works well for unambiguous goods but is brittle for descriptions full of qualifiers like "crushed or ground" or "not elsewhere specified." To make the match more robust I combine three signals: cosine similarity in MPNet space (weight 0.7), token-level Jaccard overlap that rewards shared content words regardless of word order (weight 0.2), and a normalized Levenshtein ratio that picks up small character edits (weight 0.1). The combined score is S = 0.7 cosine + 0.2 Jaccard + 0.1 Levenshtein. I tuned those weights by qualitatively reviewing hundreds of match decisions on the 2020–2022 schedules. The highest-scoring neighbor becomes the provisional match, inheriting its HS code and description; its score is stored for confidence filtering. Once year N is fully mapped, those updated descriptions become the reference set for year N–1, and the walk continues all the way back to 1789.
When a match's composite score falls below the operating threshold τ ≈ 0.50 (chosen because the share-above-threshold curve has a sharp drop at that point), the pipeline does not immediately escalate to a live web lookup. It first tries an era-aware hierarchical fallback. The HTSUS era (1989–2024) allows HS-8 only. TSUSA (1963–1988) allows HS-8 down to HS-6. The Smoot–Hawley TSUS era (1930–1962) opens up HS-4. Pre-TSUS schedules (1789–1929) allow HS-2 chapter-level matches. The fallback strips two digits at a time from the candidate code, looks up the official WCO description for that prefix in a pre-embedded matrix of chapters/headings/subheadings, recomputes cosine similarity against the line's MPNet vector, and accepts the coarser code if it scores at least τ and beats the previous best. In practice this hierarchical probe fires for roughly 4–6% of lines per pre-1989 year, and the median fallback depth is HS-6 for TSUSA and HS-4 for Smoot–Hawley schedules.
Only after both the year-to-year match and the hierarchical fallback fail does the pipeline launch the web-verification module. Selenium opens the U.S. Census HS-Classifier in headless Chrome, injects the modernized description into the search box, and presses Classify. The site returns a dynamic drop-down (anywhere from one heading to several dozen nested choices); a GPT-4 prompt ranks the scraped options against the query and returns the most plausible click-path. If the site then displays a fibre-composition table — common for textile goods — the same prompt generates percentages summing to 100 and types them in. The classifier finally produces a tabular result of candidate HS codes; a final GPT-4 prompt picks the most accurate option given the modernized description. Because GPT is stateless and temperature is fixed, this stage is reproducible.
Results
I evaluate the pipeline on three public schedules that exercise different parts of the design: the 1989 schedule (first U.S. machine-readable HS file, tests an HS-to-HS hop), the 1963 inaugural TSUS schedule (tests the TSUS→HS bridge), and the 1789 Tariff Act (425 free-text lines, tests the full modernization chain with no numeric ground truth). The 2023 schedule (13,776 HS-8 lines) supplies the canonical embedding matrix.
Figure 2 plots, for every source year N from 1789 to 2022, the mean composite similarity between each line in year N and the 2023 description it ultimately maps to. The shape is the central long-run finding. There are three clear stable regimes separated by sharp troughs that line up exactly with statutory rewrites of the schedule. The pre-TSUS era drifts gradually upward from about 0.45 in 1789 to roughly 0.80 by 1929 as commodity language converges toward modern usage. The 1930 Smoot–Hawley adoption produces the first visible cliff (mean drops by ~0.28) but similarity recovers within two decades. A second, deeper cliff appears in 1963 with the legally binding TSUSA (mean drops by ~0.41). After the U.S. joins the international HS in 1989, average similarity stays above 0.90 and approaches 1.00 by the 2010s.
Restricting to the HTSUS era (1989–2022) — the window where HS-6 codes are directly comparable across years — the pipeline retains the original HS-6 code in roughly 79% of cases. An additional 8.9% drop only to HS-4 (i.e., the chapter and heading match but the subheading differs), 5.5% drop to HS-2, and just 6.8% jump into a completely different chapter. This is the headline number for the project: across more than three decades and several WCO revision cycles, four out of five tariff lines stay in their exact six-digit subheading.
The remaining 21% of HTSUS-era cases concentrate in years immediately following structural revisions. In 1995 and 1996 specifically, between 23.5% and 28.2% of mappings fall below the τ = 0.50 threshold — the WCO ran a major HS revision in that window, which pushed many lines into different headings. Smaller dips show up around 2002, 2007, and 2012, all of which line up with subsequent WCO revision cycles, and in each case similarity recovers within a year or two as the schedule stabilizes.
Two specific low-similarity cases illustrate why the web-verification fallback earns its place. A 1989 tariff for "Nutmeg" (HS 0908.10.00) maps in 2023 to "Nutmeg, crushed or ground" (HS 0908.20.00); the embedding-only score lands around 0.58, below threshold, but the Census HS-Classifier picks the correct subheading. A 1995 line for "Coffee substitutes containing coffee" gets reclassified by 1996 as "Soluble or instant coffee" under a different chapter (HS-2 = 99); again the embedding score is sub-threshold, and the website lookup yields the correct chapter and heading. Across the full 1989–2022 corpus, only about 2.2% of mappings ultimately need the web-verification module, but it rescues nearly all of them.
For the 1789 schedule — which has no numeric ground truth, only a hand-curated HS-2 equivalent for its 64 entries — the pipeline achieves 60.9% chapter-level accuracy (precision 71.2%, F1 = 0.605). Errors cluster in three patterns: generic nineteenth-century labels like "manufactures of metal" or "wares of glass" whose wording straddles modern chapters, archaic spellings ("fyne sugar," "cotton stuffs") that survive GPT modernization but still embed closer to neighbouring categories, and multi-material goods (e.g., "hats of beaver and silk") that the single-label ground truth forces into one chapter even though the pipeline often picks the other plausible parent.
Discussion
The headline finding is that one-year hops plus a hierarchical fallback plus a small amount of grounded web verification can handle 250 years of vocabulary drift and four major scheme overhauls without manual relabeling. The 79% HS-6 retention number across 1989–2022 is the most recruiter-legible result; the more interesting structural result is the shape of Figure 2, where the cliffs and recoveries match historical events in the schedule itself. That correspondence is what convinces me the pipeline is tracking real semantic content rather than a bag of incidental lexical features.
A few honest limitations are worth naming. The composite weights (0.7 / 0.2 / 0.1) were chosen by qualitative inspection of hundreds of samples between 2020 and 2022, not by exhaustive search; a learned ranker or a small fine-tuning pass on labeled pairs would almost certainly beat the static weights. The web-verification module depends on the Census HS-Classifier site staying online with a stable interface — if that goes away, the bottom 2.2% of cases need a new fallback. The pipeline currently assumes English-language single-material descriptions; multi-material goods are forced into a single chapter by the ground truth, which understates accuracy on items like "hats of beaver and silk."
The deliverable is the open-source concordance and an accompanying Python package that exposes the full mapping behind a single function call: feed in any tariff description from any year between 1789 and 2023 and get back a ranked list of 2023 HS codes with confidence scores. The intended downstream use is long-run trade-policy work — comparing U.S. import patterns across centuries — that would otherwise require months of hand-coded historical alignment. Future work I'd like to take on includes replacing the fixed similarity threshold with a learned decision rule, extending the modernization prompt to non-English schedules, and adding multi-label outputs for composite goods so accuracy on lines like "hats of beaver and silk" can be measured fairly.
References
- (2023). Using Machine Learning and NLP for the Product Matching Problem. Lecture Notes in Networks and Systems, vol. 450, pp. 123–137. Springer.
- (2019). A Large-Scale Comparison of Historical Text Normalization Systems. Proceedings of EMNLP 2019, pp. 327–342.
- (2022). A Hybrid Approach of Weighted Fine-Tuned BERT Extraction with Deep Siamese Bi-LSTM Model for Semantic Text Similarity Identification. Multimedia Tools and Applications, vol. 81, no. 9, pp. 12013–12033. Springer.