A hs coding classification method and system based on hierarchical bucket rearrangement
Patent Information
- Application Number
- CN202611097044.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-08-18
AI Technical Summary
随着全球贸易规模持续扩张、跨境电商等贸易新业态快速发展,进出口商品品类不断丰富、申报业务量持续增长,传统依赖人工经验的归类方式存在效率低、成本高、一致性差等短板,已难以适配数字化通关与合规管理的发展需求,HS编码智能分类技术由此成为贸易数字化领域的重要研究方向,目前已发展出规则匹配、传统机器学习、深度神经网络、预训练语言模型等多种技术路径,在各类报关与监管场景中逐步落地应用
本发明提供一种基于层级分桶重排的HS编码分类方法,通过截取编码长度获取多级层级标签并建立父子从属关系,对商品字段进行增强和特征提取生成基础文本,并以父级编码作为路径约束生成各层级增强文本,再提取特征向量训练分层分类模型,输出候选编码概率后通过多级重排校正优化排序,最终逐级加载模型以上层输出约束下层实现分类。本方法充分利用HS编码的层级结构,通过分桶划分缩小分类空间,减少相近编码误判风险;引入父级路径约束融入税则规则知识,增强法规遵循性和层级一致性;结合特征增强处理同义词、长尾商品表述,并通过重排校正机制提升候选排序准确性。采用本方法有效降低对专家经验和人工维护的依赖,提升分类精度与合规性,增强模型泛化能力和长尾样本处理效果,同时兼顾可解释性、部署成本、响应速度及数据安全,满足高并发低延迟业务要求。
Smart Images

Figure CN122594947A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of HS coding classification technology, and in particular relates to an HS coding classification method and system based on hierarchical bin rearrangement. Background Technology
[0002] The Harmonized System (HS) coding system is a fundamental coding system supporting international trade, customs supervision, tax collection, cross-border e-commerce declaration, and import / export compliance management. It features a strict hierarchical structure with chapters, headings, and subheadings, requiring comprehensive information on product name, use, material, composition, processing technology, and specifications, while adhering to legal rules such as chapter notes, heading notes, and subheading notes in tariff documents. With the continuous expansion of global trade and the rapid development of new trade formats such as cross-border e-commerce, the categories of import and export commodities are constantly enriching, and the volume of declarations is continuously increasing. Traditional classification methods relying on manual experience suffer from low efficiency, high costs, and poor consistency, making them unsuitable for the development needs of digital customs clearance and compliance management. Therefore, HS coding intelligent classification technology has become an important research direction in the field of trade digitalization. Currently, various technical approaches have been developed, including rule matching, traditional machine learning, deep neural networks, and pre-trained language models, and are gradually being applied in various customs declaration and supervision scenarios.
[0003] Existing HS coding intelligent classification technologies still have many shortcomings: While rule-based and keyword matching classification methods possess strong interpretability, they heavily rely on expert experience and manual maintenance. With adjustments to tariff rules, evolution of industry terminology, and the continuous emergence of new products, the rule base requires continuous iteration and updates, resulting in high maintenance costs. Furthermore, these methods struggle to comprehensively cover synonyms, abbreviations, colloquial expressions, mixed Chinese and English descriptions, and long-tail products, easily leading to insufficient coverage, rule conflicts, and mismatches when dealing with tens of thousands of codes. Traditional machine learning methods often treat HS coding classification as a planar multi-classification task, failing to fully utilize the HS coding system. The hierarchical structure of the encoding itself, coupled with an excessively large classification space, can easily lead to misclassifications between similar chapters, similar items, and frequently confused codes. Furthermore, such methods typically use only commodity declaration texts as training input, failing to effectively incorporate professional knowledge of tariff rules. This results in the model learning more from the statistical patterns of historical declaration data, making it difficult to reflect the regulatory constraints of customs classification. While deep neural networks, pre-trained language models, and large language models offer stronger semantic understanding and generalization capabilities, they generally suffer from high training data requirements, high computational resource consumption, and high deployment and maintenance costs. Moreover, large language models are prone to output instability and illusion risks, failing to meet the business requirements of private deployment, high concurrency, and low latency in data-sensitive scenarios. Furthermore, HS-coded samples naturally exhibit severe long-tail distribution characteristics. Existing methods are prone to overfitting or classification failure when dealing with a small number of subcategories. Some hierarchical classification schemes only perform simple step-by-step predictions, lacking parent coding path hints, tariff rule knowledge enhancement, secondary rearrangement of candidate codes, and special correction mechanisms for high-frequency confusion codes. This results in deficiencies in the hierarchical consistency of classification results and the accuracy of candidate ranking. A single technical approach also struggles to simultaneously address multiple business objectives such as accuracy, interpretability, deployment cost, and response speed.
[0004] It is evident that existing HS coding intelligent classification technologies cannot deeply align with the hierarchical structure and regulatory constraints of HS coding. They cannot effectively improve the accuracy and compliance of classification results through hierarchical attribution constraints and the injection of tax rules, and they struggle to simultaneously address diverse business objectives such as classification accuracy, interpretability, deployment costs, response speed, and data security. Summary of the Invention
[0005] This invention provides an HS coding classification method and system based on hierarchical bucket rearrangement. This method can fit the hierarchical structure attributes and regulatory constraints of HS coding, and can take into account multiple business objectives such as classification accuracy, interpretability, deployment cost, response speed and data security.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: A hierarchical bucket rearrangement-based HS coding classification method includes: Based on the encoding length, multi-level hierarchical tags are extracted from the HS encoding, and there is a top-down parent-child relationship between the tags; The commodity fields of historical declaration data are enhanced and specification features are extracted to generate basic enhanced text; for each lower level except the highest level, the corresponding parent code is used as path constraint information, and the enhanced text corresponding to each lower level is generated based on the basic enhanced text. Text statistical features are extracted from the enhanced text corresponding to each level to obtain the feature vector corresponding to each level; The samples at each level are divided into buckets based on the corresponding parent code, and the classification model at each level is trained based on the feature vector of the corresponding level; the classification model is used to output the classification probability of each candidate code within the corresponding level range. Candidate code sets are obtained by filtering the classification probabilities output by each level of classification model. Multi-level rearrangement correction is performed on the candidate code sets to correct the candidate order, and the corrected candidate code order results are obtained. The product field of the product to be classified is processed by feature extraction. The corresponding trained classification model and rearrangement correction logic are loaded in a hierarchical order from top to bottom. The parent code output of the previous level is used as the input constraint of the next level. Finally, the HS code classification result and candidate code list are output.
[0007] Furthermore, before performing field enhancement and specification feature extraction on the commodity fields of the historical declaration data, the process also includes: The following steps are involved in performing text normalization on the product fields of historical declaration data: Convert null and invalid values in the product field to empty strings, convert full-width punctuation marks to half-width punctuation marks, standardize the space delimiter, merge consecutive whitespace characters into a single space, and convert English characters to lowercase. The specification features are the specification unit information corresponding to capacity, weight, quantity, and packaging form extracted from the product field, and added as an independent field to the basic enhanced text.
[0008] Furthermore, the process of generating corresponding enhanced text for each lower level based on the basic enhanced text also includes: The structured tariff knowledge base is obtained and parsed to generate tariff rule knowledge texts of corresponding levels. The tariff rule knowledge texts are then concatenated with the basic enhanced texts and path constraint information to obtain the enhanced texts corresponding to each lower level.
[0009] Furthermore, the extraction of text statistical features from the enhanced text corresponding to each level includes: Character-level TF-IDF features and word-level TF-IDF features are extracted from the enhanced text. The character-level TF-IDF features and word-level TF-IDF features at the same level are concatenated to obtain the fused feature vector corresponding to that level. The character-level TF-IDF features are extracted using the character n-gram method, and the word-level TF-IDF features are extracted using a customized word segmentation rule combined with the word-level n-gram method.
[0010] Furthermore, each level of classification model includes a linear support vector machine model and a logistic regression model; the calibration probability output by the linear support vector machine model and the class probability output by the logistic regression model are obtained respectively, and the two probabilities are weighted, fused and normalized to obtain the classification probability of each candidate code within the corresponding level range.
[0011] Furthermore, the multi-level rearrangement correction includes: one-to-many candidate rearrangement and pairwise rearrangement of high-frequency confusion coding pairs; One-to-many candidate rearrangement: Train an independent binary classifier rearranger for each candidate coding category with sufficient sample size in each level. For the selected candidate coding set, use the confidence output of the corresponding binary classifier rearranger to correct the original classification probability and re-normalize it to complete the first rearrangement correction. High-frequency confusion code pair rearrangement: Multiple sets of high-frequency confusion code pairs are preset and corresponding binary classification models are trained; in the candidate code ranking after the first rearrangement correction, if the top two candidate codes match a set of high-frequency confusion code pairs, the probability quality of the set of high-frequency confusion code pairs is redistributed using the output of the corresponding binary classification model, and the second rearrangement correction is completed.
[0012] Furthermore, a long-tail adaptation mechanism is incorporated into the process of training classification models for each level based on feature vectors of the corresponding level. Set a minimum sample number threshold for each level of candidate coding categories, and filter out candidate coding categories with a sample number lower than the minimum sample number threshold; For parent buckets containing only a single child-level encoding category, set them to single-label mode and return the unique child-level encoding directly during inference; for parent buckets with insufficient sample size for stable training, set them to majority class fallback mode and return the child-level encoding with the largest number of samples in the bucket.
[0013] Furthermore, when outputting the candidate encoding list, it is sorted by path score, including: The product of the predicted probabilities of each level in a single complete candidate path is used as the comprehensive score of the path, or the sum of the logarithms of the predicted probabilities of each level is used as the comprehensive score; the candidate codes are sorted from high to low according to the comprehensive scores, and a preset number of candidate codes are output.
[0014] Furthermore, the multi-level hierarchical label has four levels, which are generated by HS encoding by truncating the characters from front to back according to their length, namely the first 2 bits, the first 4 bits, the first 6 bits, and the first 8 bits; the prefix of the next level of encoding is the same as that of the previous level of encoding, and a parent-child relationship is formed between the labels of each level.
[0015] A hierarchical binning rearrangement-based HS coding classification system includes: The hierarchical tag extraction module is used to extract multi-level hierarchical tags from the HS code according to the encoding length. The tags at each level have a top-down parent-child relationship. The field enhancement module is used to enhance the commodity fields and extract specification features from historical declaration data to generate basic enhanced text. For each lower level except the highest level, the corresponding parent code is used as path constraint information to generate the corresponding enhanced text for each lower level based on the basic enhanced text. The feature extraction module is used to extract text statistical features from the enhanced text corresponding to each level, and obtain the feature vector corresponding to each level; The model training module is used to divide the samples of each level into buckets based on the corresponding parent code, and to train the classification model of each level based on the feature vector of the corresponding level; the classification model is used to output the classification probability of each candidate code within the corresponding level range; The rearrangement correction module is used to filter candidate code sets based on the classification probabilities output by each level of classification model, perform multi-level rearrangement correction on the candidate code sets to correct the candidate order, and obtain the corrected candidate code order result. The classification output module is used to extract features from the product fields of the products to be classified, load the corresponding trained classification models and rearrangement correction logic in a hierarchical order from top to bottom, use the parent code output from the previous level as the input constraint for the next level, and finally output the HS code classification result and candidate code list.
[0016] Compared with the prior art, the present invention has the following beneficial effects: This invention provides a hierarchical binning and rearrangement-based HS coding classification method. It obtains multi-level hierarchical labels by truncating the coding length and establishing parent-child hierarchical relationships. The product field is enhanced and features extracted to generate basic text. Parent coding is used as path constraints to generate enhanced text for each level. Feature vectors are then extracted to train a hierarchical classification model. After outputting candidate coding probabilities, multi-level rearrangement is used for correction and optimization of the ranking. Finally, the model is loaded level by level, with upper-level outputs constraining lower-level classification. This method fully utilizes the hierarchical structure of HS coding, reducing the classification space through binning and minimizing the risk of misclassification due to similar coding. Parent path constraints are introduced to incorporate tariff rules, enhancing regulatory compliance and hierarchical consistency. Feature enhancement is combined to handle synonyms and long-tail product descriptions, and a rearrangement correction mechanism improves candidate ranking accuracy. This method effectively reduces reliance on expert experience and manual maintenance, improves classification accuracy and compliance, enhances model generalization ability and long-tail sample processing performance, while also considering interpretability, deployment cost, response speed, and data security, meeting the requirements of high-concurrency, low-latency business operations. Attached Figure Description
[0017] Figure 1 A system design diagram of an HS coding classification method based on hierarchical bucket rearrangement provided in an embodiment of the present invention; Figure 2 A flowchart of the model training process provided in this embodiment of the invention; Figure 3 This is a schematic diagram illustrating the principle of field enhancement and feature extraction provided in an embodiment of the present invention. Figure 4 A flowchart of candidate encoding fusion and rearrangement provided in an embodiment of the present invention; Figure 5 A flowchart of a single product reasoning process provided in an embodiment of the present invention; Figure 6 This is an overall architecture diagram of the HS coding classification method based on hierarchical bucket rearrangement provided in an embodiment of the present invention; Figure 7 This is a core flowchart of an HS coding classification method based on hierarchical bucket rearrangement provided in an embodiment of the present invention; Figure 8 This is a schematic diagram of the structure of an HS coding classification system based on hierarchical bin rearrangement, provided as an embodiment of the present invention. Detailed Implementation
[0018] To further understand the content of this invention, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments are merely illustrative and not limiting of the invention.
[0019] The technical terms involved in this invention are explained as follows: HS code: full name Harmonized System Code.
[0020] TF-IDF, short for Term Frequency-Inverse Document Frequency, is a statistical method for text feature extraction that measures the importance of words in a document by calculating term frequency and inverse document frequency.
[0021] SVM: Support Vector Machine, is a type of supervised learning model.
[0022] LR: short for Logistic Regression, is a statistical method.
[0023] OVR: One-Versus-Rest, is a multi-classification strategy.
[0024] RAG stands for Retrieval-Augmented Generation, which is a technique that combines retrieval and generation.
[0025] XGBoost: short for eXtreme Gradient Boosting, is a machine learning algorithm based on gradient boosting decision trees.
[0026] Pairwise comparison is a machine learning method.
[0027] Calibrated Classifier (CV) is a cross-validation method for classifiers used for probability calibration.
[0028] GPU: Graphics Processing Unit, is a type of hardware specifically designed for processing graphics and parallel computing.
[0029] ML: short for Machine Learning.
[0030] DL: Short for Deep Learning.
[0031] Top-K (also known as TopK): refers to the K highest probability predictions output by the model.
[0032] n-gram: a basic method for extracting n consecutive units (such as characters or words) as features from a text sequence.
[0033] LinearSVC: short for Linear Support Vector Classifier, is a type of linear support vector machine classifier.
[0034] Sigmoid: also known as a sigmoid function or a logical function.
[0035] As described in the background section, the shortcomings and deficiencies of the prior art are as follows: While existing HS code classification methods based on rule and keyword matching offer strong interpretability, they heavily rely on expert experience and manual maintenance. When tariff rules, product names, industry terminology, or declaration practices change, the rule base needs continuous updates, resulting in high maintenance costs. Furthermore, these methods struggle to cover synonyms, abbreviations, colloquial descriptions, mixed Chinese and English descriptions, and emerging products. When faced with tens of thousands of codes and a large number of long-tail products, they are prone to insufficient coverage, rule conflicts, and mismatches.
[0036] While existing traditional machine learning methods have low resource consumption, most still treat HS coding as a simple planar multi-class classification problem, failing to fully utilize the hierarchical structure of HS coding itself, such as chapters, headings, and subheadings. When the model directly faces a large number of candidate codes, the classification space becomes too large, easily leading to misclassifications between codes from similar chapters, headings, or frequently confused codes. Furthermore, traditional methods typically rely solely on commodity text samples for training, rarely incorporating rule-based knowledge from tariff codes, such as category notes, chapter notes, and subheading notes, into the model input. This results in the model learning more from statistical patterns in historical declaration data, rather than reflecting the regulatory constraints of customs classification.
[0037] While deep neural networks, pre-trained language models, and large language models can improve semantic understanding, they typically require more training data and higher computing resources, resulting in high costs for model inference, deployment, and maintenance. For scenarios such as customs declaration, cross-border trade, and intranet customs clearance, business data is often sensitive and unsuitable for relying on large cloud-based model services. Furthermore, the output of large models is prone to instability and illusion risks, making it difficult to guarantee strict control over encoding formats, candidate ranking, and classification criteria. For business systems requiring high concurrency, low latency, low cost, and private deployment, existing deep model solutions still face significant implementation hurdles.
[0038] Furthermore, HS coding data naturally exhibits a severe long-tail distribution. Popular coding samples are plentiful, while samples for many subcategories are scarce. Existing methods are prone to overfitting or training failures in local categories with insufficient samples, and lack stable handling mechanisms for scenarios such as single subcategories, few-sample subcategories, and nearly duplicated products. Although some methods employ hierarchical classification, they typically only perform simple step-by-step predictions, lacking parent coding hints, tariff rule knowledge enhancement, secondary reordering of candidate codes, and correction mechanisms for high-frequency confused codes. This results in shortcomings in top candidate ranking, differentiation of similar codes, and hierarchical consistency.
[0039] To address the aforementioned issues, this embodiment provides an HS code classification method based on hierarchical bucketing and rearrangement. This method fully utilizes the hierarchical structure of HS codes, integrates commodity declaration text, specification information, and tariff rules knowledge, and improves classification accuracy, stability, interpretability, and deployment economy through low-resource model fusion, candidate rearrangement, and a long-tail fallback mechanism. This invention specifically addresses the above problems by proposing a low-resource HS code classification scheme based on hierarchical bucketing, parent path hints, tariff knowledge enhancement, and candidate rearrangement to overcome the shortcomings of existing methods in terms of resource consumption, hierarchical consistency, rule knowledge utilization, long-tail category handling, and private deployment.
[0040] For example, such as Figure 7 As shown, this embodiment provides an HS coding classification method based on hierarchical bucket rearrangement, including: Based on the encoding length, multi-level hierarchical tags are extracted from the HS encoding, and there is a top-down parent-child relationship between the tags; The commodity fields of historical declaration data are enhanced and specification features are extracted to generate basic enhanced text; for each lower level except the highest level, the corresponding parent code is used as path constraint information, and the enhanced text corresponding to each lower level is generated based on the basic enhanced text. Text statistical features are extracted from the enhanced text corresponding to each level to obtain the feature vector corresponding to each level; The samples at each level are divided into buckets based on the corresponding parent code, and the classification model at each level is trained based on the feature vector of the corresponding level; the classification model is used to output the classification probability of each candidate code within the corresponding level range. Candidate code sets are obtained by filtering the classification probabilities output by each level of classification model. Multi-level rearrangement correction is performed on the candidate code sets to correct the candidate order, and the corrected candidate code order results are obtained. The product field of the product to be classified is processed by feature extraction. The corresponding trained classification model and rearrangement correction logic are loaded in a hierarchical order from top to bottom. The parent code output of the previous level is used as the input constraint of the next level. Finally, the HS code classification result and candidate code list are output.
[0041] The classification method provided in this embodiment will be further explained below: For example, this embodiment provides an HS coding classification method based on hierarchical binning and rearrangement. It fully utilizes the hierarchical structure of HS coding to decompose the traditional one-time multi-category classification task into a multi-stage binning classification task of "chapter—item—sub-item—detailed coding". In each stage, the system constructs field-enhanced text based on the product name, declared product name, specifications, and unit of measurement, and integrates rule knowledge such as class annotations, chapter annotations, and sub-item annotations from the tariff book. This allows the model to not only learn the features of historical declaration samples but also make judgments based on customs classification rules. Simultaneously, this solution employs character-level and word-level TF-IDF feature fusion, linear support vector machine (SVM) model and logistic regression (LR) probability fusion, OVR candidate rearrangement, and high-frequency obfuscated coding pairwise rearrangement mechanisms to achieve multi-level correction of candidate codes. This method does not rely on large-scale pre-trained models and high-memory GPUs, and can still achieve a high Top1-98% accuracy and Top3-100% hit rate under actual testing conditions of approximately 1GB of video memory usage. Compared to directly using large deep learning models or single-stage multi-classification models, this solution has advantages such as low training resource consumption, small classification space, strong adaptability to long-tail categories, interpretable candidate results, incremental updates of the model in buckets, and suitability for private deployment. It is particularly suitable for scenarios such as customs commodity classification, cross-border e-commerce declaration, and enterprise customs declaration assistance. The trained hscode classification model has been deployed on the server and made available to users.
[0042] In this embodiment, as Figure 1As shown, this classification method can be deployed on enterprise intranet servers, customs classification auxiliary servers, cross-border e-commerce declaration system servers, or ordinary computing terminals. The system as a whole includes a data access module, a data cleaning module, a field enhancement module, a tariff knowledge enhancement module, a feature extraction module, a hierarchical binning training module, a candidate re-ranking module, a model storage module, an online inference module, and a result output and manual review module. The data flow between the modules is as follows: historical declaration data and tariff knowledge base enter the data cleaning module and the tariff knowledge enhancement module, respectively; the cleaned commodity fields and tariff knowledge jointly construct enhanced text; the enhanced text enters the feature extraction module to generate sparse vectors; the hierarchical binning training module trains classification models and re-ranking models at different levels based on sparse vectors; after training, the model, category set, parent coding bucket mapping, tariff knowledge mapping, and configuration parameters are written to the model storage module; the online inference module loads the model package and performs step-by-step prediction on the commodity information input by the user; the result output module returns 2-bit, 4-bit, 6-bit, and 8-bit candidate codes, candidate probabilities, the final Top1 result, and the TopK candidate results.
[0043] As can be seen, this classification method does not rely on specific cloud services, nor does it require a large-scale GPU configuration. The main components required for model training and inference are a text cleaning program, a TF-IDF feature extractor, a linear support vector machine model, a logistic regression model, a one-to-one multiple sorter, a one-to-one confusion pair reorderer, and a model serialization file. These modules can be implemented as multiple software functional modules on the same server, or they can be split into a training server, a model file server, and an online inference server according to the needs of the business system. If deployed in a network system, the training server is responsible for offline reading of historical declaration data and the tariff knowledge base and generating a model package, while the online inference server is responsible for loading the model package and providing prediction interfaces. User terminals, customs declaration systems, or business front-ends submit commodity information and obtain prediction results through LAN or intranet interfaces. Alternatively, this embodiment can be embedded as a data processing flow into an existing customs declaration system, replacing the existing direct planar classification or keyword matching process.
[0044] Explainable, such as Figure 6 As shown, the specific steps of the HS encoding classification method based on hierarchical bucket rearrangement provided in this embodiment are as follows: It includes two main stages: a training stage and an online inference stage; wherein, the training stage includes: Data input and field definition process: like Figure 2 As shown, specifically as follows Figure 2As shown in S201, the training data includes at least the fields of original product name, declared product name, specifications, and known HS code. In one specific embodiment, the input fields include itemname, gname, gmodel, and gcode. Here, itemname represents the product name or product display name, gname represents the declared product name, gmodel represents the specifications or declared specifications, and gcode represents the HS code already determined in historical declaration records.
[0045] After reading the training data, the system first verifies the existence of necessary fields. If any necessary field from itemname, gname, gmodel, or gcode is missing, a data format error is indicated, and training stops to prevent erroneous fields from entering the model. The gcode field is standardized by removing noise such as decimal points, spaces, and non-numeric characters, converting it into a continuous numeric string. Then, different level labels are extracted based on the encoding length: the first 2 characters are hs2, the first 4 characters are hs4, the first 6 characters are hs6, and the first 8 characters are hs8. Data that is shorter than the corresponding level is filtered out during training at that level.
[0046] In the HS coding system, a 2-digit code typically corresponds to a "chapter," a 4-digit code typically corresponds to a "heading," a 6-digit code typically corresponds to a "subheading," and an 8-digit code typically corresponds to a more granular domestic tariff heading or declaration code. This invention utilizes this natural hierarchical relationship to represent a complete code as follows:
[0047] Where hs2 is the first 2 bits of HS, hs4 is the first 4 bits of HS, hs6 is the first 6 bits of HS, and hs8 is the first 8 bits of HS. Since hs4 necessarily belongs to hs2, hs6 necessarily belongs to hs4, and hs8 necessarily belongs to hs6, this invention uses the parent encoding as a constraint in both training and inference, and no longer treats all encodings as unrelated planar categories.
[0048] Text cleaning and normalization process: like Figure 2 As shown in S202 and S203, the system performs unified cleaning on the product text fields. For invalid values such as null, missing values, "NULL", and "(NULL)", the system converts them to empty strings; for Chinese full-width brackets, commas, semicolons, and colons, the system converts them to half-width or uniform symbols; for common separators such as forward slashes, hyphens, and underscores, the system adds spaces before and after them or replaces them with spaces; for consecutive whitespace characters, the system merges them into a single space; and for English characters, the system uniformly converts them to lowercase. This processing reduces feature splitting caused by differences in capitalization, punctuation, separators, or input habits for the same product.
[0049] For example, the product text "BLANKME Radiant Cushion Foundation Refill CO1 / 15g" can be standardized to "blankme Radiant Cushion Foundation Refill Col / 15g". Regarding "15g"... Specification information such as “2”, “30 ml”, “1 kg”, “10 tablets”, and “2 bottles” are further extracted by the system using regular expressions to form specification subtext. The specification subtext does not replace the original field, but is added as an additional field to enhance the text, so that the model can not only see the complete product description, but also more clearly identify the specifications, capacity, weight, quantity and packaging form.
[0050] Enhanced text construction process for declaration fields: like Figure 3 As shown, this invention does not simply concatenate multiple fields directly. Instead, it adds field names as explicit markers to the text and performs repetitive enhancement and specification extraction based on the importance of different fields. For each sample, the system constructs a basic enhanced text T. base :
[0051] Here, `spec(·)` represents a function that extracts specification features such as unit of measurement, capacity, weight, quantity, and number of packages from the text. `itemname`, `gname`, and `gmodel` are derived from the product name, declared product name, and specification model fields, respectively; `gname2` and `gmodel2` represent repetition enhancements for the declared product name and specification model. By adding field markers such as "itemname", "gname", and "gmodel" to the text, the model can distinguish the semantic differences when the same word appears in different fields; by repeating `gname` and `gmodel`, the system increases the influence weight of the declared product name and specification model on the classification results in the TF-IDF feature space; by specifically extracting `gmodel_spec` and `gname_spec`, the system enhances the model's sensitivity to specification units such as "ml, g, kg, granules, tablets, bottles, boxes, strips, bags, sets, pieces, units, units, tables, and individuals"; `gmodel_spec` and `gname_spec` are explicit markers for specification model-derived features and declared product name-derived features, respectively.
[0052] The purpose of the above-mentioned field enhancement methods is that not all text fields are equally important in HS classification. For example, the product display name may contain brand, marketing terms, or series names, while the declared product name and specifications are usually closer to the classification elements. Through field labeling and repetition enhancement, this invention achieves lightweight field weight modeling without introducing complex neural networks, enabling the linear model to make fuller use of the declared field structure.
[0053] The process of enhancing tariff knowledge and providing parent path suggestions: like Figure 1 and Figure 3 As shown, the classification method in this embodiment further introduces a tariff knowledge enhancement module. The system reads the structured knowledge file of the tariff book and extracts regular text such as class titles, chapter titles, class notes, domestic subheading notes, subheading notes, and chapter notes. For each 2-digit chapter code hs2, the system constructs the tariff knowledge text K(hs2) corresponding to that chapter:
[0054] Here, `class_title` represents the class title, `chapter_title` represents the chapter title, `class_note` represents the class note, `chapter_note` represents the chapter note, `class_cn_note` and `chapter_cn_note` represent domestic subheading notes or domestic rule-based notes, and `class_sub_note` and `chapter_sub_note` represent subheading notes. The system performs the above knowledge text through the same normalization process as the product text, and then uses it as the `book_hint` field to input into the model.
[0055] When predicting 4-digit, 6-digit, and 8-digit codes, the system not only inputs the product text but also adds the already determined or predicted parent code as a path suggestion to the text. For example, the enhanced text in the 4-digit prediction stage can be represented as:
[0056] The enhanced text in the 6-bit prediction stage can be represented as:
[0057] The enhanced text in the 8-bit prediction stage can be represented as:
[0058] The role of parent path hints is that when the model enters the next level of prediction, the model no longer faces the entire encoding space, but makes local judgments under the constraints of the parent encoding.
[0059] The role of tariff knowledge enhancement is that, in addition to learning statistical patterns from historical declaration data, the model can also access official classification rule texts such as category notes, chapter notes, and subheading notes, thereby improving its adaptability to customs classification rules. Both types of information are added to the input in text form, so the fusion of rule knowledge and sample experience can be achieved without changing the basic structure of the TF-IDF and linear classification models.
[0060] Custom word segmentation and TF-IDF feature extraction process: As shown Figure 3 in the figure, the system constructs both character-level TF-IDF features and word-level TF-IDF features for the enhanced text. The character-level features adopt the character n-gram method, where the value of n can range from 2 to 5, and are used to capture fine-grained patterns such as Chinese phrases, brand segments, model segments, abbreviations, and continuous character combinations. The word-level features adopt customized word segmentation rules, which can recognize Chinese continuous characters, English letters, numbers, and common measurement units. The customized word segmentation rules cover at least Chinese word strings, English letter strings, number strings, and unit words such as ml, kg, g, grain, piece, bottle, box, strip, bag, set, branch, piece, unit, etc. The value of n for word-level n-gram can be taken from 1 to 3, and is used to capture word or phrase combinations such as "foundation cream", "refill", "15g", "co1", etc.
[0061] For any enhanced text T, let t represent one of the word terms or character n-grams, tf(t, T) represent the number of occurrences of t in T, df(t) represent the number of training samples containing t, and N represent the total number of training samples. In one embodiment, the system calculates the TF-IDF weights using sublinear term frequency scaling and inverse document frequency: Sublinear term frequency:
[0062] Inverse document frequency:
[0063] TF-IDF weight:
[0064] When the word term does not appear, there is:
[0065] The system obtains character-level vectors and word-level vectors respectively: ,
[0066] And splice the two to form a fused feature vector:
[0067] where, X char represents the character-level feature vector, X word represents the word-level feature vector, and X represents the fused feature vector.
[0068] It can be seen that the above fused features can capture both Chinese and English lexical semantics, as well as fine-grained information such as short character segments, models, specifications, brand abbreviations, etc., and are suitable for dealing with common problems in cross-border commodity descriptions, such as mixed Chinese and English, mixed digital models, mixed specification units, and text irregularities.
[0069] Training set and test set grouping process: To avoid inflated model evaluation results due to nearly identical products, such as Figure 2 As shown in S204, this embodiment uses a grouping method instead of simple random segmentation during the training and evaluation phase. The system de-standardizes the product name and declared product name, removing capacity, weight, quantity, number of packages, and purely numerical information, retaining the core product name, and then constructs a grouping key `group_key`:
[0070] Here, `core(·)` represents the core extraction function for text after removing specifications and units of measurement. For example, "15g foundation cream" and "30g foundation cream" may have the same or similar core names after removing specifications, and therefore would be grouped into the same group. The system uses a random grouping method to group samples under the same `group_key` into either the training or test set, avoiding different specifications, batches, or models of the same product appearing simultaneously in both sets. This approach allows for a more realistic evaluation of the model's generalization ability to unseen products and reduces data leakage.
[0071] HS2 global model training process: like Figure 2 As shown in S205, the first stage trains the 2-bit chapter coding model. Since the 2-bit chapter coding is the highest level, the system adopts a global training approach, that is, training the HS2 main model on all valid samples. First, the first two bits are extracted from the gcode as the label y2, and the enhanced text T is constructed. base The system trains two main classification models: the first is a probability-calibrated linear support vector machine (SVM), and the second is a logistic regression (LR) model. Linear support vector machines are suitable for high-dimensional sparse text features and can learn strong classification boundaries; logistic regression models have the advantages of stable probability output and smooth ranking. Both are used together to improve the ranking stability of candidate codes.
[0072] For a linear support vector machine, in one embodiment, LinearSVC can be used and probability calibration can be performed using the Sigmoid method. Let the decision function value output by the support vector machine for category c be f. c (x), after Sigmoid calibration, yields an approximate probability value:
[0073] Among them, A c and B c These are all calibration parameters, which can be obtained through cross-validation. For the logistic regression model, let θ be the parameter corresponding to category c.c Then its probability output can be expressed as:
[0074] The system obtains the probability distributions of the SVM model and LR model for each 2-bit encoded category, and then proceeds to the probability fusion and candidate rearrangement process.
[0075] Training process of HS4, HS6, and HS8 hierarchical bucket model: like Figure 2 As shown in S206 to S208, the second to fourth stages employ parent-level encoding binning training. Unlike directly training a planar model covering all 4-bit, 6-bit, or 8-bit encodings, this embodiment first divides the samples into multiple local bins according to the parent encoding, i.e., binning is achieved, and then trains the child classification model within each bin.
[0076] During the HS4 training phase, the system bins the samples according to hs2. For each 2-bit parent code b2, all samples with hs2=b2 are taken to form a bin D(b2), and the 4-bit sub-model M within that bin is trained using the sample's hs4 as the label. 4,b2 This model only needs to distinguish the 4-digit item codes that may appear in the current chapter, and does not need to distinguish all 4-digit codes. Its training objective can be expressed as:
[0077] x4 is extracted from T4, which contains the basic enhanced text of the product, hs2_hint, and book_hint.
[0078] During the HS6 training phase, the system bins the samples according to hs4. For each 4-bit parent code b4, all samples with hs4=b4 are taken to form a bin D(b4), and the 6-bit sub-model M within that bin is trained using hs6 as the label. 6,b4 Its training objective can be expressed as:
[0079] x6 is extracted from T6, which contains hs2_hint, hs4_hint, and book_hint.
[0080] During the HS8 training phase, the system bins the samples according to hs6. For each 6-bit parent code b6, all samples with hs6=b6 are taken to form a bin D(b6), and the 8-bit sub-model M within that bin is trained using hs8 as the label. 8,b6 Its training objective can be expressed as:
[0081] x8 is extracted from T8, which contains hs2_hint, hs4_hint, hs6_hint, and book_hint.
[0082] Each bucket model can employ an SVM master model and an LR master model similar to those used in the HS2 stage, and train an OVR rearranger within the bucket. For example... Figure 2 As shown in S209 to S210, the system independently stores the model, class set, OVR reorderer, knowledge map, training metrics, and runtime configuration for each parent bucket. The stored model package is used to output the final TopN predictions, classification reports, etc. In this way, a large-scale classification problem that may originally contain tens of thousands of candidate codes is decomposed into a small-scale classification problem within multiple parent buckets. The candidate space of each sub-model is smaller, and similar classes are more concentrated, thus reducing training costs, inference costs, and the range of misclassifications.
[0083] For example, the classification method in this embodiment also introduces long-tail category filtering, single-label return, and majority class fallback mechanism, as follows: HS-encoded data typically exhibits a pronounced long-tail distribution, meaning a few popular encoded samples are plentiful, while a large number of subdivided encoded samples are scarce. To ensure training stability, this invention employs a long-tail processing mechanism. First, the system sets a minimum sample count threshold for each category level. For example, for categories hs4, hs6, and hs8, if the sample count for a particular category falls below a preset threshold, it can be temporarily excluded from supervised training at that level in the current training implementation, or used as a subsequent object for manual review / rule supplementation. Second, a minimum sample count threshold is set for each parent bucket. If the sample count within a bucket is too low, complex models are not trained, or a fallback strategy is employed.
[0084] For a given parent bucket, if the bucket contains only one child code category, the system does not need to train a classifier and instead marks the bucket as single_label mode. During online inference, as soon as the parent bucket is entered, the system directly returns the unique child code and sets its probability to 1. For a given parent bucket, if the bucket contains multiple child codes, but the model cannot be stably trained due to insufficient samples, insufficient training set categories after grouping, or insufficient samples for a certain category for cross-validation calibration, the system marks the bucket as majority_fallback mode and records the child code with the most samples in the training set or within the bucket as the majority class fallback result. During online inference, the system returns the majority class code and indicates that the training conditions for the bucket are insufficient.
[0085] Furthermore, for models requiring probabilistic calibration, the cross-validation fold count (cv) is not fixed but dynamically determined based on the minimum number of samples in each class within the training set. Let n be the minimum number of samples in each class within a certain bucket of the training set. min Then we can assume:
[0086] When n min When the value is less than 2, calibration training is not performed, and fallback logic is invoked. This mechanism avoids errors caused by insufficient sample classes in the CalibratedClassifierCV equal probability calibrator, improving the system's engineering stability in real-world long-tail data.
[0087] The specific process of main model probability fusion is as follows: like Figure 4 As shown, within each level or each parent bucket, the system can simultaneously train both the SVM master model and the LR master model, and then perform a weighted fusion of the probabilities output by the two models. Let P... svm (c|x) represents the calibration probability of the SVM model for class c, P lr (c|x) represents the probability of the LR model for class c, λ represents the SVM weights, and 1-λ represents the LR weights. The fusion probability is then:
[0088] In one embodiment, λ can be 0.60, and the LR weight can be 0.40; alternatively, λ can be set to 0.55, 0.65, or other empirical values based on the validation set performance. To ensure the validity of the probability distribution after fusion, the system normalizes the probabilities of all classes:
[0089] Through the above fusion, the system balances the discriminative boundary capabilities of linear SVM in high-dimensional sparse text spaces with the smoothness and stability of logistic regression probability output. The fused probability is used not only for Top1 determination but also for TopK candidate ranking and subsequent reordering. This represents the weighted fusion probability that the model predicts the sample belongs to category j given an input sample x.
[0090] As another preferred embodiment, an OVR candidate rearrangement mechanism is also provided: After the main model is fused, the system does not directly output the final result. Instead, it performs a one-to-many candidate rearrangement on the Top N candidates. For a certain level of class set C, the system trains an OVR binary class rearranger R for each class c with a sample size reaching a threshold. c This is used to determine whether an input sample belongs to category c. Its binary classification label is defined as:
[0091] During online inference, the system first bases on Obtain the TopN candidate category set C top For C topFor each candidate category c, if a corresponding OVR rearranger R exists... c Then calculate the binary classification confidence score of this category relative to other categories:
[0092] Then use Q ovr (c|x) modifies the original fusion probability. In one embodiment, the modification is as follows:
[0093] Here, μ can be 0.55 or 0.50. For categories that are not in the Top N, or categories for which an OVR rearranger has not been trained, the original probabilities can be retained. The system is then normalized again after correction:
[0094] In the formula, This represents the sum of all candidate categories in the entire classification system. Summing gives the total probability after class correction for all categories.
[0095] The role of the OVR (Optical Ranking Renderer) is to further refine the candidate recall results from the broad scope of the main model. While the main model addresses "which codes are likely related," the OVR reorderer addresses "which of the top candidates is more similar to the current category." This mechanism is particularly suitable for scenarios where multiple similar codes have close probabilities, and it is difficult to distinguish between Top 1 and Top 2 candidates.
[0096] For example Figure 4 As shown, this embodiment also introduces a pairwise high-frequency confusion pair rearrangement mechanism. In the 2-bit chapter prediction stage, this embodiment can also set a pairwise rearranger for high-frequency confusion pairs. The system presets easily confused code pairs based on historical misclassification records, business experience, or statistical confusion matrices, such as 33 and 34, 21 and 22, 21 and 15, 33 and 96, 85 and 90, etc. For each confusion pair (a, b), the system selects samples from the training set whose true labels belong to a or b, and trains a binary classification model R. ab This is used to output the probability that a sample belongs to a rather than b:
[0097] During online inference, if the Top 2 candidate after main model fusion and OVR correction happens to fall into a pre-defined confusion pair (a, b), then a pairwise rearrangement is triggered. Let the probability mass of the current classes a and b be:
[0098] The system then redistributes the probability mass between a and b as follows:
[0099]
[0100] The probabilities of other categories remain unchanged, and then overall normalization is performed. This method is only triggered when the Top 2 candidate matches a confusing pair, and does not impose additional reasoning burden on all categories. Its purpose is to specifically correct historically high-frequency confusing chapters, reducing the probability of misjudgment between adjacent chapters, similar-purpose products, and similar-ingredient products.
[0101] At this point, the HS coding classification method based on hierarchical bucket rearrangement has completed the training phase.
[0102] The following explanation pertains to the online reasoning phase: like Figure 5 As shown, the online reasoning process for a single product includes: The online inference phase receives product fields input by the user, including product name, declared product name, specifications, etc. The system first performs the same text cleaning, specification extraction, field augmentation, and TF-IDF vectorization processing as in the training phase to ensure consistency between the training and inference feature spaces. Then, it predicts step-by-step according to the following steps.
[0103] The first step is to construct the basic enhanced text T in the system. base The data is input into the HS2 global model to obtain the fusion probability of each 2-bit chapter code. After OVR rearrangement and necessary pairwise confusion pair rearrangement, the TopK candidates and their probabilities for hs2 are output. The system can take the Top1 as the parent code for the next stage, or in embodiments where improved recall is required, multiple hs2 candidate paths can be retained for subsequent expansion.
[0104] The second step involves the system retrieving the predicted hs2, adding it as hs2_hint to the text, and concatenating it with the tax knowledge text corresponding to K(hs2) to obtain T4. Based on hs2, the system loads the corresponding HS4 bucketed sub-model M from the model repository. 4,hs2 Output the Top K candidates and their probabilities for the 4-bit code within the parent bucket. If the bucket is in single_label mode, return the unique 4-bit code directly; if the bucket is in majority_fallback mode, return the majority fallback code.
[0105] The third step involves the system taking the predicted hs4, adding hs2 and hs4 as hs2_hint and hs4_hint respectively to the text to obtain T6, and then loading the corresponding HS6 bucketing sub-model M. 6,hs4 The system outputs 6-bit encoded TopK candidates and their probabilities. Similarly, for single-label buckets or majority class catch-all buckets, the system directly returns the results according to the corresponding pattern.
[0106] Fourth, the system takes the predicted hs6, adds hs2, hs4, and hs6 as hs2_hint, hs4_hint, and hs6_hint to the text respectively, to obtain T8, and loads the corresponding HS8 bucketing sub-model M. 8,hs6 Output the 8-bit encoded TopK candidates and their probabilities.
[0107] Fifth, the system summarizes the results from each level and outputs 2-bit, 4-bit, 6-bit, and 8-bit prediction results, corresponding probabilities, candidate ranking, and the final Top1 code. In embodiments where Top3, Top5, and Top15 candidate lists need to be output, the system can retain multiple parent-level candidates using a path expansion method. Let a complete candidate path be π = (hs2, hs4, hs6, hs8), then the comprehensive score of this path can be expressed as:
[0108] To avoid the value being too small due to the multiplication of multiple probabilities, a logarithmic form can also be used:
[0109] The system sorts the complete path according to Score or LogScore and outputs the Top M candidate codes with the highest overall scores. For scenarios requiring only fast response, a step-by-step Top 1 path can be used; for scenarios requiring manual review or high recall candidates, a Top K path expansion can be used.
[0110] The following is a practical application of the classification method provided in this embodiment. The specific implementation process is as follows: Taking the product "BLANKME Radiant Cushion Foundation Refill CO1" as an example, with the declared product name "BLANKME Radiant Cushion Foundation Refill CO1" and the specification "CO1", the system first performs text standardization, converting the English brand and model to lowercase while retaining the Chinese product name. The system then constructs basic enhanced text: itemname blankme luminous cushion foundation refill co1 gname blankme luminous cushion foundation refill co1 gname2 blankme luminous cushion foundation refill co1 gmodel co1 gmodel2co1 gmodel_spec gname_spec If the HS2 model predicts that the product is more likely to belong to Chapter 33, then in the HS4 stage, "hs2_hint 33" and the relevant tariff knowledge book_hint for Chapter 33 are concatenated into the text, entering the 4-bit sub-model corresponding to Chapter 33. If HS4 predicts 3304, then in the HS6 stage, "hs4_hint 3304" continues to be used as the parent path hint; if HS6 predicts 330499, then in the HS8 stage, "hs6_hint 330499" continues to be used as the parent path hint, and a finer 8-bit code is distinguished within the bucket corresponding to 330499. This process allows the model to solve only the local classification problem under the current parent code at each level, avoiding unconstrained jumps between irrelevant chapters and irrelevant items.
[0111] After training is complete, the system serializes and saves the model package. The model package includes at least: the SVM main model, LR main model, OVR rearranger, and Pairwise rearranger for the HS2 stage; the set of sub-models stored in HS4 buckets according to HS2; the set of sub-models stored in HS6 buckets according to HS4; the set of sub-models stored in HS8 buckets according to HS6; the category set, pattern label, single-label result, majority class result, training metric, and configuration parameters corresponding to each bucket; and the tariff knowledge mapping and field processing configuration.
[0112] Because the models are stored independently by parent coding bucket, when a new sample is added to a chapter, item, or sub-item, or when tariff rules change, only the sub-model within the corresponding parent bucket needs to be updated, without having to retrain all levels of models. For example, if only the cosmetics-related samples in Chapter 33 change, the HS4 sub-model under hs2=33 and its downstream related HS6 and HS8 sub-models can be retrained; if only the 8-bit coded sample corresponding to 330499 is added, only the HS8 sub-model within the hs6=330499 bucket needs to be updated. This approach reduces model maintenance costs and improves the system's ability to adapt to changes in tariff rules and commodities.
[0113] Online inference results can include the following: 2-bit TopK candidates, 4-bit TopK candidates, 6-bit TopK candidates, 8-bit TopK candidates, final Top1 code, final Top3 / Top5 / TopN candidate codes, probability of each candidate, whether single-label return is triggered, whether majority class fallback is triggered, whether OVR re-ranking is triggered, and whether Pairwise re-ranking is triggered. For business systems requiring manual review, the system can simultaneously save candidate codes, probabilities, original product text, enhanced text fragments, field hit features, and model version number for easy subsequent auditing and feedback.
[0114] Because this embodiment employs TF-IDF sparse features and a linear classification model, the model can further output important features or high-weight terms. For example, in judging a candidate code, the system can extract character fragments, terms, specifications, or tariff knowledge terms that contribute significantly to the category, serving as supplementary evidence for manual review. Compared to directly calling a large language model to generate a single answer, the output results of this invention are more stable, the candidate code format is controllable, and the probability ranking is verifiable, making it suitable for scenarios such as customs classification, cross-border e-commerce declaration, and auxiliary review of enterprise customs declarations.
[0115] Therefore, existing direct planar classification processes typically treat the complete HS code as a single category label, directly outputting a complete code after inputting the product text. This approach suffers from problems such as a huge number of categories, severe confusion between similar codes, difficulty in training long-tail categories, inconsistent levels, and lack of tariff rule constraints. The HS code classification method based on hierarchical binning and rearrangement provided in this embodiment adopts a hierarchical binning process of "first chapter, then item, then sub-item, then further subdivided codes," and adds parent path hints and tariff knowledge hints at each level. The differences include at least the following: First, the classification space is different. Existing methods directly deal with the full set of codes, while this invention only performs local classification within the parent bin at each level, significantly reducing the candidate space. Second, the input information is different. Existing methods typically only use product text, while this invention uses field-enhanced text, specification features, parent code hints, and tariff knowledge text simultaneously. Third, the candidate processing is different. Existing methods typically directly use the category with the highest probability in the main model, while this invention further performs OVR candidate rearrangement after main model probability fusion and performs pairwise specific correction for high-frequency confusion pairs. Fourth, the long-tail processing is different. Existing methods are prone to training failure or overfitting on a small number of classes. This invention addresses this by implementing single-label return, majority class fallback, and dynamic cross-validation fold adjustment mechanisms. Fifth, the maintenance methods differ. Existing overall model updates are costly, while this invention allows for local updates based on parent buckets.
[0116] To implement the classification method provided in the above embodiments, an implementable system device is provided, specifically including: (1) a data access unit, used to receive historical declaration data, commodity data to be predicted, and tariff knowledge data; (2) an encoding standardization unit, used to perform non-numeric character deletion, length verification, and hierarchical encoding truncation on the gcode field to generate hs2, hs4, hs6, and hs8 tags; (3) a text normalization unit, used to perform case unification, symbol unification, null value processing, and space normalization on the text such as commodity name, declared product name, and specifications; (4) (5) The specification feature extraction unit is used to extract capacity, weight, quantity, packaging unit and specification combination information according to rules; (6) The field enhancement unit is used to concatenate field name, field content, repeated enhancement field, specification field, parent code hint and tariff knowledge hint into enhanced text; (7) The tariff knowledge enhancement unit is used to read the class title, chapter title, class note, chapter note, subheading note and domestic subheading note in the tariff book, and generate book_hint according to the parent code; (8) The feature extraction unit is used to generate character-level TF-IDF vector and word-level TF-IDF vector. The F vector is concatenated with the other two to form a fused feature vector; (8) Hierarchical bucketing training unit, used to train the HS2 global model, the HS4 sub-models bucketed by hs2, the HS6 sub-models bucketed by hs4, and the HS8 sub-models bucketed by hs6; (9) Probability fusion unit, used to perform weighted fusion and normalization of the output probabilities of the SVM model and the LR model; (10) Candidate rearrangement unit, used to perform OVR rearrangement on the TopN candidates and perform Pairwise rearrangement when the Top2 candidate hits the preset confusion pair; (11) Long tail fallback unit, used to perform long tail fallback on the buckets When there are insufficient single labels, insufficient samples, insufficient categories, or insufficient calibration conditions, single label return, majority class return, or dynamic CV adjustment are performed; (12) Model storage unit, used to store model package, parent bucket mapping, category set, reorderer, tariff knowledge mapping, configuration parameters, and training evaluation indicators; (13) Online inference unit, used to load model package, perform step-by-step prediction of the goods to be predicted, and generate candidate code ranking; (14) Result output and verification unit, used to output TopK candidates, final codes, probabilities, model versions, reordering trigger status, and information required for manual verification at each level. The above units can be implemented by software program modules, or by the cooperation of server, processor, memory, and network interface. When the processor executes the program stored in memory, it completes the steps of the above HS coding intelligent classification method.
[0117] For example, such as Figure 8 As shown, this embodiment also provides an HS coding classification system based on hierarchical bucket rearrangement, including: a hierarchical label extraction module, used to extract multi-level hierarchical labels from the HS coding according to the coding length, wherein each level label has a top-down parent-child subordinate relationship; The field enhancement module is used to enhance the commodity fields and extract specification features from historical declaration data to generate basic enhanced text. For each lower level except the highest level, the corresponding parent code is used as path constraint information to generate the corresponding enhanced text for each lower level based on the basic enhanced text. The feature extraction module is used to extract text statistical features from the enhanced text corresponding to each level, and obtain the feature vector corresponding to each level; The model training module is used to divide the samples of each level into buckets based on the corresponding parent code, and to train the classification model of each level based on the feature vector of the corresponding level; the classification model is used to output the classification probability of each candidate code within the corresponding level range; The rearrangement correction module is used to filter candidate code sets based on the classification probabilities output by each level of classification model, perform multi-level rearrangement correction on the candidate code sets to correct the candidate order, and obtain the corrected candidate code order result. The classification output module is used to extract features from the product fields of the products to be classified, load the corresponding trained classification models and rearrangement correction logic in a hierarchical order from top to bottom, use the parent code output from the previous level as the input constraint for the next level, and finally output the HS code classification result and candidate code list.
[0118] The present invention also provides an HS coding classification device based on hierarchical bucket rearrangement, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the HS coding classification method based on hierarchical bucket rearrangement.
[0119] The present invention also provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the steps of the HS encoding classification method based on hierarchical bucket rearrangement.
[0120] When the processor executes the computer program, it implements the above-mentioned steps of HS encoding classification based on hierarchical bucket rearrangement, for example: extracting multi-level hierarchical labels from the HS encoding according to the encoding length, and having a top-down parent-child relationship between each level of label; The commodity fields of historical declaration data are enhanced and specification features are extracted to generate basic enhanced text; for each lower level except the highest level, the corresponding parent code is used as path constraint information, and the enhanced text corresponding to each lower level is generated based on the basic enhanced text. Text statistical features are extracted from the enhanced text corresponding to each level to obtain the feature vector corresponding to each level; The samples at each level are divided into buckets based on the corresponding parent code, and the classification model at each level is trained based on the feature vector of the corresponding level; the classification model is used to output the classification probability of each candidate code within the corresponding level range. Candidate code sets are obtained by filtering the classification probabilities output by each level of classification model. Multi-level rearrangement correction is performed on the candidate code sets to correct the candidate order, and the corrected candidate code order results are obtained. The product field of the product to be classified is processed by feature extraction. The corresponding trained classification model and rearrangement correction logic are loaded in a hierarchical order from top to bottom. The parent code output of the previous level is used as the input constraint of the next level. Finally, the HS code classification result and candidate code list are output.
[0121] For example, the computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing preset functions, the instruction segments describing the execution process of the computer program in the HS coding classification device based on hierarchical bucket rearrangement. For example, the computer program can be divided into a hierarchical label extraction module, a field enhancement module, a feature extraction module, a model training module, a rearrangement correction module, and a classification output module; the specific functions are as follows: the hierarchical label extraction module is used to extract multi-level hierarchical labels from the HS coding according to the coding length, with a top-down parent-child relationship between each level of labels; the field enhancement module is used to enhance the commodity fields of historical declaration data and extract specification features to generate basic enhanced text; for each lower level except the highest level, the corresponding parent level coding is used as path constraint information to generate enhanced text corresponding to each lower level based on the basic enhanced text; the feature extraction module is used to extract text statistical features from the enhanced text corresponding to each level to obtain the feature vector corresponding to each level; The model training module is used to divide the samples of each level into buckets based on the corresponding parent code, and train the classification model of each level based on the feature vector of the corresponding level. The classification model is used to output the classification probability of each candidate code within the corresponding level range. The rearrangement and correction module is used to filter the candidate code set based on the classification probability output by the classification model of each level, and perform multi-level rearrangement and correction on the candidate code set to correct the candidate order, and obtain the corrected candidate code order result. The classification output module is used to extract features from the product field of the product to be classified, load the corresponding trained classification model and rearrangement and correction logic level by level according to the top-down order of the levels, use the parent code output by the previous level as the input constraint of the next level, and finally output the HS code classification result and the candidate code list.
[0122] The hierarchical binning-based HS encoding classification device can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. The hierarchical binning-based HS encoding classification device may include, but is not limited to, processors and memory. Those skilled in the art will understand that the above examples of hierarchical binning-based HS encoding classification devices do not constitute a limitation on hierarchical binning-based HS encoding classification devices. Such devices may include more components than described above, or combinations of certain components, or different components. For example, the hierarchical binning-based HS encoding classification device may also include input / output devices, network access devices, buses, etc.
[0123] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor, or any conventional processor. This processor is the control center of the hierarchical bucket rearrangement-based HS coding classification system, connecting all parts of the system via various interfaces and lines.
[0124] The memory can be used to store the computer program and / or modules. The processor implements various functions of the hierarchical bucket rearrangement-based HS coding classification device by running or executing the computer program and / or modules stored in the memory, and by calling the data stored in the memory.
[0125] The memory may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback, image playback, etc.). The data storage area may store data created based on the use of the mobile phone (such as audio data, phonebook, etc.). Furthermore, the memory may include high-speed random access memory and non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital cards (SD cards), flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.
[0126] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the HS coding classification method based on hierarchical bucket rearrangement.
[0127] If the modules / units integrated by the hierarchical bin rearrangement-based HS coding classification system are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
[0128] Based on this understanding, the present invention can implement all or part of the processes in the above-described hierarchical bucket-based HS encoding classification method, or it can be accomplished by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the above-described hierarchical bucket-based HS encoding classification method. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or a preset intermediate form, etc.
[0129] The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc.
[0130] It should be noted that the content contained in the computer-readable storage medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.
[0131] Compared with existing classification methods, this invention provides an HS coding classification method and system based on hierarchical bucket rearrangement, which has the following advantages: First, reduce the class space complexity of large-scale HS coding classification tasks: Traditional machine learning methods typically treat the complete HS code as a regular category label for direct classification. This means that after inputting product text, the model directly selects one from all candidate codes. However, due to the large number of HS code categories, deep hierarchies, and numerous similar codes, direct planar classification leads to an excessively large category space for the model. As the number of candidate categories increases, the boundaries between different categories become more complex, especially prone to misclassification between similar products, related sections, and adjacent items.
[0132] This invention leverages the inherent hierarchical structure of HS coding—"chapter—item—subitem—detailed coding"—to break down a large-scale, one-time classification task into multiple stages: HS2, HS4, HS6, and HS8. Stage HS2 determines the chapter; stage HS4 determines the item only within the established HS2 parent coding bucket; stage HS6 determines the subitem only within the established HS4 parent coding bucket; and stage HS8 determines the detailed coding only within the established HS6 parent coding bucket. Thus, the problem of directly selecting results from the full coding is transformed into a localized, smaller-scale classification problem under multiple parent constraints.
[0133] The technical benefits of this improvement are that each sub-model only needs to distinguish between possible child codes under the current parent code, rather than simultaneously distinguishing between codes under all unrelated chapters or categories. Therefore, the candidate set at each stage is smaller, the model classification boundary is simpler, and both training difficulty and inference complexity are reduced. Simultaneously, since the next-level prediction must be subordinate to the previous-level prediction, the system can reduce significant hierarchical errors caused by jumps across chapters and categories, improving the hierarchical consistency of the HS coding output.
[0134] Second, improve the model's ability to utilize the hierarchical relationship of HS encoding: While some existing methods also employ a hierarchical classification approach, they typically simply predict the upper-level code first, then the lower-level code, without explicitly using the upper-level code as an input signal to the model. Therefore, the lower-level model cannot fully perceive which upper-level classification path the current product already belongs to, easily leading to insufficient utilization of hierarchical information.
[0135] In the HS4, HS6, and HS8 prediction stages, this invention incorporates the already determined or predicted parent codes as path hints into the enhanced text. For example, `hs2_hint` is added when predicting 4-bit codes, `hs2_hint` and `hs4_hint` are added when predicting 6-bit codes, and `hs2_hint`, `hs4_hint`, and `hs6_hint` are added when predicting 8-bit codes. In this way, the parent codes not only serve as routing conditions for the model to select sub-models but also participate in lower-level classification decisions as part of the text features.
[0136] The improved reasoning logic lies in the fact that the lower-level codes of HS encoding do not exist in isolation, but rather rely on their higher-level codes to determine the candidate range and semantic boundaries. After explicitly injecting the parent code into the model input, the lower-level model can simultaneously utilize product text features and parent path features for judgment. For example, for products containing terms such as "foundation cream" and "refill," when the parent path is Chapter 33, the lower-level prediction should focus on cosmetic-related categories, rather than jumping to irrelevant chapters. Therefore, this invention can improve the path continuity and hierarchical constraint capability in the hierarchical classification process.
[0137] Third, improve the model's ability to utilize knowledge of tariff rules: Existing traditional machine learning methods mostly rely on historical declaration samples for training, and the models primarily learn the statistical correspondence between commodity text and historical codes. However, HS code classification is not simply a matter of text similarity; it also needs to consider the rules and regulations in the tariff book, such as class notes, chapter notes, subheading notes, and national subheading notes. If the model relies solely on historical data, it is easily affected by historical declaration habits, sample bias, or data noise, making it difficult to reflect the regulatory constraints in customs classification rules.
[0138] This invention includes a tariff knowledge enhancement module that reads structured tariff knowledge files, extracts rule text such as class titles, chapter titles, class annotations, chapter annotations, subheading annotations, and national subheading annotations, and establishes a tariff knowledge mapping according to HS2 chapter encoding. When performing HS4, HS6, and HS8 predictions, the system adds the tariff knowledge corresponding to the parent chapter as a book_hint to the enhancement text, ensuring that the classification model encounters rule-based text information during both training and inference.
[0139] The advantages of this improvement are that the model no longer relies solely on empirical associations from historical samples, but can simultaneously utilize both commodity declaration texts and tariff rule texts. For scenarios with limited historical samples, incomplete commodity descriptions, or marketing-oriented commodity names, tariff knowledge can provide the model with more stable domain context information. For example, chapter titles, chapter notes, and subheading notes often contain information such as commodity scope, exclusion rules, and special classification conditions. Once this information is transformed into textual features that the model can recognize, it helps improve the model's adaptability to customs classification rules and reduces misjudgments caused by relying solely on commodity names or keywords.
[0140] Fourth, improve the stability of candidate code sorting: Single-class classification models typically have inherent biases. For example, linear support vector machines (SVMs) are suitable for boundary delimitation in high-dimensional sparse text spaces, but their raw outputs are not natural probabilities and require probability calibration. Logistic regression models have relatively stable probability outputs, but their discrimination boundaries under complex high-dimensional text features may not be as strong as those of SVMs. Using only one model may lead to unstable probability rankings for some classes, especially when the probabilities of Top 1 and Top 2 are close, causing fluctuations.
[0141] This invention simultaneously trains a probability-calibrated linear support vector machine (SVM) model and a logistic regression model within each level or each parent bucket, and then weights and fuses their output probabilities. The linear SVM provides strong high-dimensional sparse text discrimination capabilities, while logistic regression offers smoother probability ranking capabilities. Through weighted fusion, the system can combine the advantages of both models, reducing the bias of a single model in certain categories.
[0142] The advantages of this improvement are that the fused candidate probabilities reflect both the support vector machine's judgment of the classification boundary and the logistic regression's smooth estimation of the probability distribution, which helps improve the stability of the TopK candidate ranking. In practical applications, the system not only needs to provide the Top1 code, but also often needs to output Top3, Top5, or Top15 candidates for manual review; therefore, candidate ranking stability itself is an important technical achievement.
[0143] Fifth, improve the ability to distinguish between similar codes and high-frequency confusion codes: Existing classification models typically select the category with the highest probability as the final result after the main model outputs the probability, without specifically ranking the top candidates. For HS code classification, many errors are not between completely unrelated categories, but rather occur between codes of similar sections, adjacent items or uses, or with similar ingredients. In such cases, although the main model may have recalled the correct code to the top candidates, because the probabilities among the candidates are close, the final top-ranked code may still be replaced by a similar code.
[0144] This invention incorporates an OVR candidate re-ranking mechanism after the main model's fusion probability. The system trains a binary classifier that ranks candidates by class ("one class against all other classes") for candidate categories with a threshold number of samples. After the main model outputs the Top N candidates, the system recalculates the binary classification confidence for each of the Top N candidate categories and uses this confidence to correct the original fusion probability. This mechanism is equivalent to the main model first performing a large-scale candidate recall, followed by the OVR re-ranking mechanism performing a fine-grained sorting of the candidate set.
[0145] Furthermore, for historically frequently confused coding pairs, this invention also sets up a pairwise confusion pair rearrangement mechanism. When the Top 2 candidate matches a preset confusion pair, the system triggers a one-to-one binary classification model to redistribute the probability quality between the two candidates. This method does not require pairwise comparisons for all categories, but only triggers when there is a genuine risk of confusion. Therefore, it improves the ability to specifically correct frequently confused codes with only a small increase in computation.
[0146] This improvement directly addresses the problem of insufficient differentiation between similar codes in existing technologies. The main model is responsible for improving recall, OVR is responsible for fine-tuning the candidates internally, and Pairwise is responsible for correcting specific biases caused by high-frequency confusion. The three form a coarse-to-fine candidate correction chain, thereby reducing the probability of misclassification between similar products, similar uses, and adjacent chapters.
[0147] Sixth, improve engineering stability for long-tail categories and parent buckets with few samples: HS-coded data naturally exhibits a long-tailed distribution, meaning a few popular coded samples are plentiful, while a large number of subdivided coded samples are scarce. Existing models are prone to overfitting, calibration failures, or training failures with a small number of classes. Especially after employing bucketing training, some parent buckets may contain only one child class, or although there may be multiple classes, the number of samples may be insufficient to support stable training. Forcing the training of complex models may not only result in errors but also produce unreliable results.
[0148] This invention employs a multi-layered long-tail fallback mechanism. For cases where a bucket contains only one sub-label, the system uses the `single_label` mode, directly returning this unique sub-label during online inference without requiring classifier training. For cases where a bucket contains multiple sub-labels but there are insufficient samples, insufficient categories after grouping, or insufficient calibration conditions, the system uses the `majority_fallback` mode, recording the majority class label as the fallback result. For models requiring probabilistic calibration, the system dynamically adjusts the cross-validation folds based on the number of samples in the minimum class of the training set; when the number of samples in the minimum class is insufficient to complete calibration, the system switches to fallback logic.
[0149] This improvement enables the system to adapt to the imbalanced distribution of real-world business data. Its technical effect is not simply to improve a single metric, but rather to ensure that the system can still provide controllable results when faced with anomalies such as small sample sizes, single-class distributions, or imbalanced training set splits, preventing training process crashes or online inference unavailability. For enterprise-level customs declaration systems, stability and availability are often as important as accuracy; therefore, this long-tail processing mechanism significantly improves the engineering feasibility of the solution.
[0150] Seventh, improve the realism and generalization reliability of model evaluation results: In customs declaration data, the same product may have multiple records with different specifications, batches, packaging, or models. If ordinary random segmentation is used, similar products may appear in both the training and test sets, making the model appear to have high accuracy, but its generalization ability decreases when faced with products that are not actually seen. This problem leads to inflated evaluation results, which is not conducive to judging the true performance of the model.
[0151] This invention constructs a group_key during the training and evaluation phase. The system first denormalizes the product name and declared product name, removing capacity, weight, quantity, number of packages, and purely numerical information, retaining only the core product name. Then, a group key is constructed based on the core name. When splitting the training and test sets, samples under the same group_key are grouped into the same set, preventing different specifications of the same product from appearing simultaneously in both the training and test sets.
[0152] The advantages of this improvement are: the model evaluation more closely resembles the scenario of "predicting unseen products" in real-world business. By reducing data leakage caused by near-duplicate products, the accuracy, TopK hit rate, and classification reports obtained by the system are more valuable for reference, helping to realistically evaluate the model's generalization ability and facilitating subsequent targeted optimization for low-accuracy buckets or easily confused codes.
[0153] Eighth, reduce the resource costs of model training, deployment, and operation: While deep neural networks, pre-trained language models, and large language models possess strong semantic understanding capabilities, they typically require high computing power, large amounts of GPU memory, and complex deployment environments. In scenarios such as customs declaration, corporate customs reporting, and cross-border trade, business data is often sensitive, and many systems are deployed on intranets or dedicated servers, making them unsuitable for relying on large cloud-based model services. Furthermore, large models suffer from issues such as unstable output, uncontrollable interpretation, and non-strict formatting.
[0154] This invention employs TF-IDF sparse features, linear support vector machines, logistic regression, and a lightweight reordering mechanism as its main technical components. It does not rely on large-scale pre-trained models, nor does it require the use of high-memory GPUs. After model training, it can be serialized and saved as a model package, which can be loaded during online inference to complete predictions.
[0155] The advantages of this improvement are: low system resource consumption and simple deployment environment, making it suitable for use on enterprise intranets, ordinary servers, or customs auxiliary audit systems. Since the inference process mainly includes text cleaning, TF-IDF vectorization, linear model prediction, and a small amount of candidate rearrangement, response speed and concurrency capabilities are easier to control. At the same time, this solution avoids uploading sensitive declaration data to external cloud models, which helps meet data security and private deployment requirements.
[0156] Ninth, improve system interpretability and ease of manual review: HS code classification scenarios not only focus on the accuracy of model predictions but also on whether the prediction results are verifiable, auditable, and traceable. While existing large language models can generate textual explanations, these explanations may be unstable, and the output format and basis may have uncontrollable risks. For customs classification, enterprise declaration, and compliance audit scenarios, the system needs to stably output structured information such as candidate codes, probabilities, model versions, and triggering mechanisms.
[0157] This invention employs TF-IDF features and a linear classification model, inherently possessing a certain degree of interpretability. The system can output information such as TopK candidates at each level, candidate probabilities, whether OVR reordering is triggered, whether Pairwise reordering is triggered, and whether single-label return or majority class fallback is triggered. Furthermore, the system can also extract terms, character segments, unit specifications, or tariff knowledge terms that contribute significantly to a particular candidate encoding based on the linear model weights, serving as a basis for manual review.
[0158] This improvement transforms the prediction result from a single code into a structured outcome that includes candidate ranking, probability, path, triggering mechanism, and traceable features. Human reviewers can then judge the reasonableness of the model's results based on the top candidates and high-weight features, thereby improving the efficiency of human-machine collaborative classification and reducing the review risks associated with completely black-box models.
[0159] Tenth, reduce maintenance costs when adding new samples and when tariff rules change: Existing holistic classification models typically train all codes within a single large model. When samples of a particular chapter, item, or sub-code change, the entire model often needs to be retrained, resulting in high training and validation costs. In the HS coding scenario, product names, declaration practices, tariff rules, and national subheadings may change over time. Retraining the entire model for every change would negatively impact system iteration efficiency.
[0160] This invention independently stores models according to parent encoding buckets. HS4 models are stored in HS2 buckets, HS6 models in HS4 buckets, and HS8 models in HS6 buckets; simultaneously, the corresponding category set, pattern label, rearranger, training metrics, and configuration parameters for each bucket are stored. When a local encoding rule or sample changes, only the child model within the corresponding parent bucket needs to be updated, without needing to retrain all models.
[0161] This improvement significantly reduces the cost of later model maintenance. For example, when new samples related to cosmetics are added in Chapter 33, the corresponding HS4 sub-model and related downstream buckets can be updated primarily; when a new 8-bit sub-code sample is added under a certain 6-bit code, only the HS8 sub-model within the corresponding HS6 bucket needs to be updated. Through partial updates, the system can adapt to new products, new rules, and new samples more quickly, while reducing the impact on other stable coding buckets.
[0162] The above embodiments are merely one of the implementation methods for achieving the technical solution of the present invention. The scope of protection claimed by the present invention is not limited to this embodiment, but also includes any variations, substitutions and other implementation methods that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention.
[0163] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the protection scope of the present invention.
Claims
1. A hierarchical bucket rearrangement-based HS coding classification method, characterized in that, include: Based on the encoding length, multi-level hierarchical tags are extracted from the HS encoding, and there is a top-down parent-child relationship between the tags. Enhance the product fields and extract specification features from historical declaration data to generate basic enhanced text; For each lower level except the highest level, the corresponding parent level code is used as the path constraint information, and the corresponding enhanced text for each lower level is generated based on the basic enhanced text. Text statistical features are extracted from the enhanced text corresponding to each level to obtain the feature vector corresponding to each level; The samples at each level are divided into buckets based on the corresponding parent code, and the classification model at each level is trained based on the feature vector of the corresponding level; the classification model is used to output the classification probability of each candidate code within the corresponding level range. Candidate code sets are obtained by filtering the classification probabilities output by each level of classification model. Multi-level rearrangement correction is performed on the candidate code sets to correct the candidate order, and the corrected candidate code order results are obtained. The product field of the product to be classified is processed by feature extraction. The corresponding trained classification model and rearrangement correction logic are loaded in a hierarchical order from top to bottom. The parent code output of the previous level is used as the input constraint of the next level. Finally, the HS code classification result and candidate code list are output.
2. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, Before performing field enhancement and specification feature extraction on the commodity fields of historical declaration data, the process also includes: The following steps are involved in performing text normalization on the product fields of historical declaration data: Convert null and invalid values in the product field to empty strings, convert full-width punctuation marks to half-width punctuation marks, standardize the space delimiter, merge consecutive whitespace characters into a single space, and convert English characters to lowercase. The specification features are the specification unit information corresponding to capacity, weight, quantity, and packaging form extracted from the product field, and added as an independent field to the basic enhanced text.
3. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, The process of generating corresponding enhanced text for each lower level based on the basic enhanced text also includes: The structured tariff knowledge base is obtained and parsed to generate tariff rule knowledge texts of corresponding levels. The tariff rule knowledge texts are then concatenated with the basic enhanced texts and path constraint information to obtain the enhanced texts corresponding to each lower level.
4. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, The extraction of text statistical features from the enhanced text corresponding to each level includes: Character-level TF-IDF features and word-level TF-IDF features are extracted from the enhanced text. The character-level TF-IDF features and word-level TF-IDF features at the same level are concatenated to obtain the fused feature vector corresponding to that level. The character-level TF-IDF features are extracted using the character n-gram method, and the word-level TF-IDF features are extracted using a customized word segmentation rule combined with the word-level n-gram method.
5. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, Each level of classification model includes a linear support vector machine model and a logistic regression model. The calibration probability output by the linear support vector machine model and the class probability output by the logistic regression model are obtained respectively. The two probabilities are weighted, fused and normalized to obtain the classification probability of each candidate code within the corresponding level range.
6. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, The multi-level rearrangement correction includes: one-to-many candidate rearrangement and pairwise rearrangement of high-frequency obfuscation codes; One-to-many candidate rearrangement: Train an independent binary classifier rearranger for each candidate coding category with sufficient sample size in each level. For the selected candidate coding set, use the confidence output of the corresponding binary classifier rearranger to correct the original classification probability and re-normalize it to complete the first rearrangement correction. High-frequency confusion code pair rearrangement: Multiple sets of high-frequency confusion code pairs are preset and corresponding binary classification models are trained; in the candidate code ranking after the first rearrangement correction, if the top two candidate codes match a set of high-frequency confusion code pairs, the probability quality of the set of high-frequency confusion code pairs is redistributed using the output of the corresponding binary classification model, and the second rearrangement correction is completed.
7. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, A long-tail adaptation mechanism is incorporated into the process of training classification models for each level based on feature vectors of the corresponding level. Set a minimum sample number threshold for each level of candidate coding categories, and filter out candidate coding categories with a sample number lower than the minimum sample number threshold; For parent buckets containing only a single child-level encoding category, set them to single-label mode and return the unique child-level encoding directly during inference; for parent buckets with insufficient sample size for stable training, set them to majority class fallback mode and return the child-level encoding with the largest number of samples in the bucket.
8. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, When outputting the candidate code list, it is sorted by path score, including: The product of the predicted probabilities of each level in a single complete candidate path is used as the comprehensive score of the path, or the sum of the logarithms of the predicted probabilities of each level is used as the comprehensive score; the candidate codes are sorted from high to low according to the comprehensive scores, and a preset number of candidate codes are output.
9. The HS coding classification method based on hierarchical bucket rearrangement according to claim 1, characterized in that, The multi-level hierarchical label has four levels, which are generated by HS encoding by truncating the characters from front to back according to their length. The first two characters are the first four characters, the first six characters, and the first eight characters are the first character. The prefix of the next level of encoding is the same as that of the previous level of encoding. The labels of each level form a parent-child relationship from top to bottom.
10. An HS coding classification system based on hierarchical bin rearrangement, characterized in that, include: The hierarchical tag extraction module is used to extract multi-level hierarchical tags from the HS code according to the encoding length. The tags at each level have a top-down parent-child relationship. The field enhancement module is used to enhance the commodity fields and extract specification features from historical declaration data to generate basic enhanced text. For each lower level except the highest level, the corresponding parent level code is used as the path constraint information, and the corresponding enhanced text for each lower level is generated based on the basic enhanced text. The feature extraction module is used to extract text statistical features from the enhanced text corresponding to each level, and obtain the feature vector corresponding to each level; The model training module is used to divide the samples of each level into buckets based on the corresponding parent code, and to train the classification model of each level based on the feature vector of the corresponding level; the classification model is used to output the classification probability of each candidate code within the corresponding level range; The rearrangement correction module is used to filter candidate code sets based on the classification probabilities output by each level of classification model, perform multi-level rearrangement correction on the candidate code sets to correct the candidate order, and obtain the corrected candidate code order result. The classification output module is used to extract features from the product fields of the products to be classified, load the corresponding trained classification models and rearrangement correction logic in a hierarchical order from top to bottom, use the parent code output from the previous level as the input constraint for the next level, and finally output the HS code classification result and candidate code list.