A hierarchical search classification method based on constraint rules and query rewriting

CN122527328BActive Publication Date: 2026-10-09GUSU LAB OF MATERIALS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611015449.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-09
Publication Date
2026-10-09
Estimated Expiration
2046-07-09

AI Technical Summary

Technical Problem

[0004]然而,现有技术难以同时处理强层级结构、显式法规约束与边界敏感场景,无法有效融合规则、阈值、排除条款及例外条件进行稳定判定,分类结果可解释性与可审计性不足,难以满足法规合规类场景的严格使用需求

Benefits of technology

[0016]According to a fourth aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the hierarchical search classification method based on constraint rules and query rewriting described above.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122527328B_ABST
    Figure CN122527328B_ABST
Patent Text Reader

Abstract

The application discloses a hierarchical search classification method based on constraint rules and query rewriting. The method comprises the following steps: constructing a hierarchical classification tree, the hierarchical classification tree comprising hierarchical nodes, node relationships, and constraint information associated with the hierarchical nodes; structurally extracting a rule corpus through a large language model to obtain rule texts and the constraint information, and filling the hierarchical classification tree based on the rule texts and the constraint information; obtaining a text to be classified, performing a single round of search from a root node, and inputting candidate node information, the text to be classified, and the constraint information into the large language model to determine a next-hop node or a termination node; performing query rewriting and multi-round retrieval based on a historical search path, updating the search path according to newly added search information and a search state, and aggregating nodes and evidence obtained through the multi-round search; and outputting a target classification result, a standardized classification code, and corresponding search paths and constraint information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of natural language processing, and in particular relates to a hierarchical search classification method based on constraint rules and query rewriting. Background Technology

[0002] In recent years, large-scale models, semantic retrieval, and retrieval enhancement generation technologies have been widely applied in text classification, question answering, and knowledge-intensive tasks. In practical scenarios such as customs code classification, export control classification, dangerous goods transportation classification, medical coding, and chemical compliance classification, there is a common type of regulation-driven hierarchical classification task.

[0003] Existing technologies for hierarchical classification tasks mainly employ three approaches: the first is flat text classification methods, which place all categories in the same space for a one-time label prediction; the second is traditional hierarchical classification methods, which construct multi-level classification models based on a hierarchical category structure and determine the target category through layer-by-layer probability prediction; the third is semantic retrieval or retrieval enhancement generation methods, which recall relevant text or candidate categories through vector matching and complete the determination based on semantic similarity. These methods typically focus on semantic features, achieving classification and retrieval through model training or vector matching. Some methods incorporate hierarchical structures to implement a top-down, layer-by-layer determination process.

[0004] However, existing technologies struggle to simultaneously handle strong hierarchical structures, explicit regulatory constraints, and boundary-sensitive scenarios. They cannot effectively integrate rules, thresholds, exclusion clauses, and exceptions for stable judgment, resulting in insufficient interpretability and auditability of classification results, making it difficult to meet the stringent usage requirements of regulatory compliance scenarios. Summary of the Invention

[0005] This invention provides a hierarchical search classification method based on constraint rules and query rewriting for regulatory compliance scenarios, enabling precise fine-grained hierarchical classification search based on the retrieved text.

[0006] One objective of this application is to demonstrate how to achieve accurate path decision-making for hierarchical nodes during the hierarchical classification process based on constraint rules, query rewriting, and multi-round searches, thereby improving the classification accuracy and search efficiency of complex text.

[0007] According to a first aspect of the present invention, a hierarchical search classification method based on constraint rules and query rewriting is provided, comprising: Construct a hierarchical classification tree, which includes hierarchical nodes, node relationships, and associated constraint information for the hierarchical nodes; The rule corpus is structured and extracted using a large language model to obtain the rule text and the constraint information, and a hierarchical classification tree is populated based on the rule text and the constraint information. The text to be classified is obtained, a single-round search is performed starting from the root node, and the candidate node information, the text to be classified, and the constraint information are input into the large language model to determine the next hop node or the termination node. The system performs query rewriting and multi-round retrieval based on historical search paths, updates search paths according to new search information and search status, and aggregates nodes and evidence obtained from multiple rounds of search. Output the target classification result, normalized classification code, and corresponding search path and constraint information for the text to be classified.

[0008] In some possible embodiments, the constraint information includes rule descriptions, exclusion clauses, defining provisions, and fragments of evidence.

[0009] In some possible embodiments, a single-round search is performed starting from the root node, and candidate node information, the text to be classified, and the constraint information are input into a large language model to determine the next hop node or the termination node, including: Keyword extraction is performed on the text to be classified, and a query vector is generated based on the keywords; The similarity between the current node's child nodes is calculated based on the query vector to recall candidate nodes; The text to be classified, the current node, the candidate nodes and the corresponding constraint information are input into the large language model to perform path reasoning and determine the next hop node. The single-round search stops when the first preset termination condition is met. A summary of the classification results is generated and output based on the search path nodes and their corresponding constraint information.

[0010] In some possible embodiments, the first preset termination condition includes: The large language model outputs a stop signal, including when the large language model determines that the current level needs to stop continuing to execute the search for the next level node, and / or when the matching confidence of the candidate node is lower than a first preset threshold, the stop signal is generated. The current node has no child nodes; The current search depth has reached the preset maximum depth.

[0011] In some possible embodiments, a classification result summary is generated and output based on the search path nodes and corresponding constraint information, including: Obtain the historical nodes of a single-round search, the corresponding constraint information, and the query vector; The similarity is recalculated based on the corresponding constraint information and the query vector; The constraint information is merged and deduplication and filtering are performed based on similarity scores to generate the classification result summary.

[0012] In some possible embodiments, query rewriting and multi-round retrieval are performed based on historical search paths, and the search path is updated according to new search information and search status, including: Obtain the historical search path, corresponding constraint information, query vector, and classification result summary to generate historical search information; Based on the text to be classified and the historical search information, a rewritten query text is generated, and keywords are extracted and vectorized from the rewritten query text to obtain a retrieval query vector. Based on the retrieval query vector, the single-round search is re-executed, and subsequent search planning is performed. When the second preset termination condition is met, the multi-round search is stopped.

[0013] In some possible embodiments, the second preset termination condition includes: The matching confidence of the target node is not lower than the second preset threshold, and the evidence fragment corresponding to the target node meets the preset evidence sufficiency conditions; The number of rounds of the multi-round search reaches a third preset threshold; The multi-round search did not acquire any new nodes and / or new evidence fragments within a preset number of rounds.

[0014] According to a second aspect of the present invention, a hierarchical search classification system based on constraint rules and query rewriting is provided, comprising: The acquisition module is used to acquire the text to be classified. The structured processing module is used to extract structured data from the rule corpus using a large language model to obtain rule text and constraint information, construct a hierarchical classification tree, the hierarchical classification tree includes hierarchical nodes and node relationships, the hierarchical nodes are associated with the constraint information, and the hierarchical classification tree is populated based on the rule text and the constraint information to generate corresponding node indexes; The search module is used to call the node index during the online retrieval phase, perform a single-round search starting from the root node, and input the candidate node information, the text to be classified, and the constraint information into the large language model to determine the next hop node or the termination node; perform query rewriting and multi-round retrieval based on the historical search path, update the search path according to the new search information and search status, and aggregate the nodes and evidence obtained from the multi-round search. The output module is used to output the target classification result, normalized classification code, and corresponding search path and constraint information for the text to be classified.

[0015] According to a third aspect of the present invention, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the hierarchical search classification method based on constraint rules and query rewriting described above.

[0016] According to a fourth aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the hierarchical search classification method based on constraint rules and query rewriting described above.

[0017] According to the present invention, by constructing and filling a hierarchical classification tree with associated constraint information, and simultaneously aggregating single-round constraint search, query rewriting, and multi-round retrieval, the classification process strictly follows the constraint information, thereby effectively solving the problems of ambiguous classification boundaries and insufficient basis in strong rule scenarios, and thus improving the stability and accuracy of classification judgment, and realizing interpretable and auditable fine-grained hierarchical classification in regulatory compliance scenarios.

[0018] Furthermore, by using large-scale model path reasoning logic, clear single-round and multi-round termination conditions, and completing deduplication and result summary generation based on similarity and constraint information, the hierarchical search process becomes more accurate and controllable, and the classification basis becomes more complete and sufficient. This further improves classification confidence and retrieval efficiency, thereby reducing misjudgment and duplicate retrieval, and achieving stable hierarchical classification results driven by rules and optimized in multiple rounds.

[0019] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, the preferred embodiments of the present invention are described in detail below. Attached Figure Description

[0020] Figure 1 A schematic flowchart of a hierarchical search classification method based on constraint rules and query rewriting according to an embodiment of the present invention is shown. Figure 2 It shows Figure 1 A flowchart illustrating step S300; Figure 3 A structural block diagram of a hierarchical search classification system based on constraint rules and query rewriting according to an embodiment of the present invention is shown; Figure 4 A schematic structural diagram of a computer device according to an embodiment of the present invention is shown. Detailed Implementation

[0021] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the specific embodiments of this application will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, it should be noted that, for ease of description, only the parts relevant to this application are shown in the accompanying drawings, not the entire structure. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this application.

[0022] The terms “comprising” and “having”, and any variations thereof, used in this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.

[0023] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0024] It should be noted that the purpose of this application is to provide a hierarchical search and classification scheme that is adaptable to strong constraint rules, hierarchical structures, and fuzzy descriptive text. Specifically, in various rule-based business scenarios such as customs commodity classification, export control classification, dangerous goods classification, and compliance text review, this application no longer relies solely on semantic similarity or traditional model probabilities for classification. Instead, it comprehensively considers rule clauses, exclusions, definition annotations, evidence chains, and classification accuracy for overall optimization. For example, in the application scenario of customs commodity classification, customs regulations are filled into a hierarchical classification tree along with specific regulatory constraint information for each commodity. Then, hierarchical classification is performed based on the commodity description text, finally yielding the accurate classification and regulatory constraint information of the commodity.

[0025] In one exemplary embodiment, such as Figure 1 As shown, a hierarchical search classification method based on constraint rules and query rewriting is provided, including the following steps S100 to S500: Step S100: Construct a hierarchical classification tree, which includes hierarchical nodes, node relationships, and hierarchical node association constraint information.

[0026] In this embodiment, constraint information is represented as a set of judgment conditions and bases bound to each node in the hierarchical classification tree and used to guide classification decisions. It is used to perform compliance verification, exclusion filtering and evidence matching on candidate nodes during the hierarchical search process to avoid misclassification caused by relying solely on semantic similarity.

[0027] Furthermore, the nodes in this embodiment not only correspond to the final node category, but also allow intermediate structural nodes such as document nodes, chapter nodes, category nodes, sub-category nodes, and reference nodes.

[0028] In some possible embodiments, constraint information includes rule descriptions, exclusion clauses, defining provisions, and fragments of evidence.

[0029] Among them, the defining clauses are the original text statements in the corresponding level nodes that define the scope of the classified objects, key attributes, or judgment conditions; the rule descriptions are the classification definitions, applicable conditions, and classification requirements of the corresponding level nodes; the exclusion clauses are the exceptions, inapplicable objects, and boundary limiting conditions that explicitly prohibit classification into the current node or lower-level nodes; and the evidence fragments are the original text statements, annotation clauses, and example descriptions extracted from the constraint text that can directly support the classification judgment.

[0030] Specifically, in the customs commodity classification application scenario, there is a node "grains", and the corresponding constraint information states that "must contain grains, whether or not they are ears or with stalks", and the exclusion clause is "excluding grains that have been hulled or otherwise processed, such as hulled, milled, polished, varnished, semi-ripe or broken rice". The evidence fragment is "durum wheat refers to wheat of the genus durum and interspecific hybrids of wheat species with the same chromosome number in that genus".

[0031] According to the scheme of this application, by binding constraint information with hierarchical nodes, the classification decision is made to better fit the rule requirements, reduce semantic misjudgment, thereby improving the classification accuracy and realizing interpretable and auditable fine-grained hierarchical classification.

[0032] Step S200: The rule corpus is structured and extracted using a large language model to obtain rule text and constraint information, and the hierarchical classification tree is populated based on the rule text and constraint information.

[0033] This embodiment includes the following steps: The rule-based corpus is processed into text blocks, resulting in several text blocks, each containing a title, source file, page number, and main text content.

[0034] Remove non-business information such as titles, source documents, and page numbers, and retain only the main text content for subsequent structured extraction.

[0035] A large language model is used to perform structured extraction on each text block, identifying and extracting information such as chapters, categories, subcategories, descriptions, definitions, and exclusions to form several classification nodes.

[0036] Each node is associated with a corresponding evidence fragment, which is a text segment extracted from the original rule text to support the classification decision.

[0037] The extracted classification nodes are recursively written into the hierarchical classification tree to complete the tree structure construction.

[0038] The classification nodes and evidence fragments are vectorized separately for subsequent similarity calculation and retrieval matching.

[0039] Step S300: Obtain the text to be classified, perform a single-round search starting from the root node, and input the candidate node information, the text to be classified, and the constraint information into the large language model to determine the next hop node or the termination node.

[0040] In this embodiment, a single-round search refers to a continuous retrieval process that starts from the root node of the hierarchical classification tree and determines the nodes layer by layer from top to bottom. This retrieval process is associated with the constraint information of each node.

[0041] Figure 2 It shows Figure 1 A schematic flowchart of the method for step S300 is shown. Figure 2 As shown, the process includes the following steps S301 to S304: Step S301: Extract keywords from the text to be classified and generate a query vector based on the keywords.

[0042] In this embodiment, keyword extraction is used to retain the most crucial information for hierarchical positioning, such as the name, material, process, purpose, and limiting words of the text to be classified, in order to reduce the interference of redundant descriptions on vector recall. It should be noted that the text to be classified will change during each subsequent round of search, except for the initial search.

[0043] Specifically, in the customs commodity classification application scenario, the text to be classified is "query=cationically modified guar gum, obtained from guar beans through chemical modification, viscosity 300-1000mPa.s, industrial grade 6-digit HS code", and the extracted keywords are "cationically modified guar gum, guar beans, chemical modification, viscosity, 300-1000mPa.s, industrial grade, HS code".

[0044] Step S302: Calculate the similarity of the current node's child nodes based on the query vector to recall candidate nodes.

[0045] Specifically, when calculating the cosine similarity of child nodes based on the query vector, constraint information is included in the similarity calculation.

[0046] Specifically, during the vector matching calculation process, corresponding node vectors are generated based on the category code, title, node text, rule description, exclusion clauses, and defining clauses corresponding to the child nodes. Candidate nodes are then recalled based on the similarity between the query vector of the text to be classified and the node vectors corresponding to each child node, ensuring that the similarity matching results align with the compliance constraints of the nodes. In some embodiments, node vectors can be pre-generated using a vectorization model and directly invoked during the retrieval phase to improve node retrieval efficiency.

[0047] It should be noted that evidence fragments do not participate in vector similarity calculations; they are only used in subsequent large-scale model inference decisions, evidence aggregation, and result interpretation. This similarity calculation process implements hierarchical and phased access to constraint information, unlike existing technologies that rely solely on node names and basic text for unconstrained general similarity matching. Furthermore, based on the similarity calculation results, subsequent candidate selection of child nodes is performed, choosing child nodes corresponding to high-scoring results; the number of child nodes selected is not specifically limited.

[0048] For example, the similarity calculation of sub-nodes for "cationically modified guar gum" yielded three sub-nodes with the highest similarity scores: "Chapter 35 Protein Substances, Modified Starch, Gum, Enzyme (0.494)", "Chapter 13 Shellac, Gum, Resin and Other Plant Sap (0.454)", and "Chapter 40 Rubber and Its Products (0.429)".

[0049] Step S303: Input the text to be classified, the current node, candidate nodes and corresponding constraint information into the large language model to perform path reasoning and determine the next hop node. Stop the single-round search when the first preset termination condition is met.

[0050] In this embodiment, after calculating the similarity, the node selection is not directly sorted according to the similarity score. Instead, a candidate package is constructed based on the constraint information corresponding to the selected node. The classified text, the current node, the candidate package containing the candidate node and the corresponding constraint information are sent to the large language model for path reasoning.

[0051] The large language model will assess the confidence of candidate nodes based on evidence fragments in the constraint information to ultimately determine the search path.

[0052] For example, for the text to be classified, "cationically modified guar gum", the candidate node "Chapter 35 Proteins, Modified Starch, Gum, Enzyme" is selected, and the confidence score is "confidence=0.800". The path "stop=false" is executed to continue the path, and the reason is "reason=The query product is a chemically modified gum, Chapter 35 clearly contains gum, and its subheadings involve modified starch and gums with it as the basic component, which is highly relevant to the product description".

[0053] It should be noted that the first preset termination condition may include multiple conditions in different application scenarios and can be flexibly adjusted. Meeting any one of the conditions is sufficient to determine that the first preset termination condition is met. This first preset termination condition is used to fully indicate that there is no need to continue searching, reasoning, and classifying downwards in the current level branch.

[0054] In some possible embodiments, the first preset termination condition includes: The large language model outputs a stop signal, including when the large language model determines that the current level needs to stop continuing to search for lower-level nodes, and / or when the matching confidence of a candidate node is lower than a first preset threshold.

[0055] The current node has no child nodes.

[0056] The current search depth has reached the preset maximum depth.

[0057] The first preset threshold is used to define the validity of candidate nodes, and the preset maximum depth is used to limit the upper limit of the downward traversal level in a single round of search. In practical applications, each value can be flexibly set according to the complexity of the scenario. This solution does not limit the specific values. For example, the first preset threshold can be set to 0.6, and the preset maximum depth can be set to 5.

[0058] It should be noted that the stop signal can be actively output by the large language model based on the path analysis results of the current level node to terminate the search for the next level node; it can also be triggered when the matching confidence of the candidate node in the current level is lower than the first preset threshold.

[0059] Step S304: Generate and output a summary of the classification results based on the search path nodes and corresponding constraint information.

[0060] The classification result summary is a collection of evidence fragments obtained by integrating and filtering the evidence fragments in the constraint information corresponding to the search path nodes. It serves as the final set of supporting evidence for the input text to be classified in this round.

[0061] In some possible embodiments, a classification result summary is generated and output based on the search path nodes and corresponding constraint information, including: Obtain the historical nodes of a single-round search, the corresponding constraint information, and the query vector; The similarity is recalculated based on the corresponding constraint information and query vector; Constraint information is merged and deduplication and filtering are performed based on similarity scores to generate a summary of classification results.

[0062] In a single-round search, different path nodes may be associated with multiple constraint information and evidence fragments with the same content or similar semantics. Therefore, in order to avoid duplicate evidence interfering with the classification results, this embodiment performs evidence fusion processing on the obtained constraint information.

[0063] Specifically, similarity scores are calculated between multiple constraint information pieces and the query vector, and the constraint information is sorted based on the similarity scores. When multiple path nodes hit the same evidence fragment or semantically repetitive constraint information, the constraint information with higher similarity scores is retained. Constraint information with duplicate content or low similarity is deduplicated or filtered. Subsequently, a preset number of highly relevant constraint information pieces are retained as core evidence based on the sorting results. The calculation of this similarity and preset number of related information pieces can be extended and improved based on the limitations in the first preset termination condition.

[0064] For example, when performing a single-round hierarchical search on the text to be classified, “Catonic modified guar gum, obtained from guar beans through chemical modification, viscosity 300-1000 mPa.s, industrial grade 6-digit HS code”, the query vector is generated based on the node “Chapter 13 Shellac, gums, resins and other plant sap and juice” and its heading node “Plant sap and extracts, pectin, pectinates and pectic acid esters, agar, other syrups and thickeners derived from plant products, whether or not modified”, combined with the constraint information such as the rules and exclusion clauses associated with the nodes and the text to be classified. After recalculating the similarity, relevant evidence fragments are recalled. Through the inference of the large language model, the product meets the definition of the subheading “syrups and thickeners derived from locust beans, locust bean seeds or guar beans, whether or not modified”, with a matching confidence of 0.8. A classification result summary containing the complete hierarchical path, node constraint information and corresponding evidence fragments is generated, and it is finally determined to be classified under this subheading.

[0065] In some possible embodiments, core evidence may include rule definitions, conditional restrictions, exclusion clauses, and highly relevant content from historical matching results. By employing this approach, the interference of redundant evidence on the path reasoning of large language models can be reduced, the information relevance and evidence consistency of classification result summaries can be improved, thereby enhancing the accuracy and interpretability of hierarchical search classification results.

[0066] Step S400: Execute query rewriting and multi-round retrieval based on historical search paths, update the search path according to newly added search information and search status, and aggregate the nodes and evidence obtained from multiple rounds of search.

[0067] In this embodiment, query rewriting means expanding and extending the text to be classified. The new search information includes new hierarchical nodes, new evidence fragments, and / or new constraint information relative to the historical search trajectory.

[0068] It should be explained that after the query is rewritten, the aforementioned single-round search steps are executed again, and this process is repeated to form multiple rounds of retrieval. In addition, at the beginning of each round of search, a judgment is made on whether new search information has been obtained. If no new nodes or new evidence fragments are obtained within a preset number of consecutive rounds, it is determined that the multi-round search has made no progress and the subsequent search is stopped.

[0069] This includes query rewriting and multi-round retrieval based on historical search paths, and updating the search path according to new search information and search status, including: Obtain historical search paths, corresponding constraint information, query vectors, and classification result summaries to generate historical search information.

[0070] The query text is rewritten based on the text to be classified and historical search information. A corresponding query vector is generated based on the rewritten query text. The single-round search is re-executed based on the query vector, and subsequent search planning is performed. The multi-round search is stopped when the second preset termination condition is met.

[0071] In this embodiment, query rewriting means generating the next round of query text based on historical search paths, corresponding constraint information, classification result summaries, and text to be classified, and extracting keywords from the next round of query text to generate a corresponding query vector. Then, the aforementioned single-round search steps are executed based on the query vector to perform multiple rounds of retrieval in a loop.

[0072] In some embodiments, the second preset termination condition includes: The matching confidence of the target node is not lower than the second preset threshold.

[0073] The number of rounds of multi-round search has reached the third preset threshold.

[0074] No new nodes and / or new evidence fragments were obtained within the preset number of rounds of searching.

[0075] The second preset threshold indicates whether the evidence fragments in the current classification result summary are sufficient, with a value ranging from 0.8 to 0.9. The specific value can be flexibly adjusted according to the application scenario, for example, a value of 0.85. The third preset threshold indicates the upper limit of the number of rounds of multi-round search, with a value range that can be flexibly adjusted according to the application scenario, for example, 5 times. The preset number of rounds is used to tolerate the state of no progress without acquiring new nodes and new evidence fragments, and its value can be 2 times. New nodes are hierarchical nodes added relative to the historical search path, and new evidence fragments are evidence content added relative to the historical search trajectory. When no new nodes or new evidence fragments are acquired within a consecutive preset number of rounds, it is determined that the multi-round search has made no progress, and subsequent searches are stopped.

[0076] For example, for the text to be classified, “Catonic modified guar gum, obtained from guar beans through chemical modification, viscosity 300-1000 mPa.s, industrial grade 6-digit HS code”, the candidate nodes “Chapter 35 Protein Substances, Modified Starch, Gum, Enzyme” and subheading “350520 (Gum)” were selected in the first round of single-round search. The matching confidence score was 0.8, and the path was judged to be “stop=false”. The reason was that “the query product is a chemically modified gum, Chapter 35 clearly includes gum, and its subheading involves modified starch and gums with it as the basic component, which is highly relevant to the product description”. However, the search evidence did not explicitly mention the classification rules for plant gums such as guar gum. It was determined that the query needed to be rewritten, and a new query was generated: “Guar gum, guar bean gum, HS, code, classification, plant gum, chemical modification, cationic modification”, focusing on supplementing the category distinction rules between plant gums and starch-based gums.

[0077] In the second round of single-round search, the rewritten query still points to "Chapter 35" and subheading "350520". The matching confidence level is increased to 0.85, and the path is judged as "stop=false". However, after the search, it was found that the newly added evidence still did not cover the specific classification basis of guar gum, and there were no new nodes or evidence fragments to supplement it. This triggered the termination condition of "no new nodes or new evidence fragments were obtained within the preset round". Based on the multi-round search path and aggregated evidence, the system re-sorted the hierarchical logic and finally corrected the classification direction, clarifying that the product should be classified into the original category.

[0078] It should be noted that although the matching confidence of some candidate nodes in the current round is high, the system can still determine that the current search results do not meet the classification requirements by combining historical search paths, evidence sufficiency and constraint matching, and continue to perform subsequent rounds of search and result aggregation.

[0079] In addition, after multiple rounds of searching, the system selects the optimal round by sorting the results of each round in lexicographical order: the optimal round is determined by comparing a quadruple consisting of sufficiency marker b, confidence p, path depth d, and number of evidence m.

[0080] For example, the parameters for each round are: Round 1 (b1=0, p1=0.2, d1=4, m1=2), Round 2 (b2=0, p2=0.2, d2=4, m2=3), and Round 3 (b3=0, p3=0.2, d3=4, m3=4). After lexicographical comparison, the optimal round is Round 3.

[0081] The system then aggregates and determines the results. First, it deduplicates and merges the hit nodes and evidence fragments from all rounds to obtain an aggregated node set and an aggregated evidence set. Then, it selects the subsequent strategy based on the state of the optimal round. If the optimal round satisfies "high confidence and sufficient evidence," its answer is directly adopted; otherwise, it performs a final answer synthesis using the aggregated nodes and evidence.

[0082] In this example, the confidence level of the optimal round 3 is 0.2, which is relatively low, and the sufficiency is marked as 0, indicating that the evidence cannot independently support a reliable answer. Therefore, the system did not directly adopt the result of this round, but instead aggregated the nodes and corresponding evidence of the 3 rounds with the root node and corresponding evidence to obtain an aggregated node containing 4 nodes and an aggregated evidence set containing 4 pieces of evidence, which was used as the final classification result.

[0083] Step S500: Output the target classification result, normalized classification code, and corresponding search path and constraint information for the text to be classified.

[0084] The standardized classification code includes hierarchical classification codes extracted and standardized from the target classification results, such as the six-digit HS code in the customs commodity classification scenario.

[0085] According to the present invention, by constructing and populating a hierarchical classification tree with associated constraint information, and simultaneously aggregating single-round constraint search, query rewriting, and multi-round retrieval, the classification process strictly follows the constraint information. This effectively solves the problems of ambiguous classification boundaries and insufficient basis in strong rule scenarios, thereby improving the stability and accuracy of classification judgment and achieving interpretable and auditable fine-grained hierarchical classification in regulatory compliance scenarios. Furthermore, through large-scale model path reasoning logic, clear single-round and multi-round termination conditions, and deduplication and result summary generation based on similarity and constraint information, the hierarchical search process becomes more precise and controllable, and the classification basis becomes more sufficient and complete. This further improves classification confidence and retrieval efficiency, thereby reducing misjudgments and duplicate retrievals, and achieving a stable hierarchical classification effect driven by rules and optimized in multiple rounds.

[0086] like Figure 3 As shown, a hierarchical search and classification system based on constraint rules and query rewriting is also provided, including an acquisition module S601, a structured processing module S602, a search module S603, and an output module S604. The acquisition module S601 is used to acquire the text to be classified; The structured processing module S602 is used to construct a hierarchical classification tree, which includes hierarchical nodes, node relationships, and hierarchical node association constraint information; and to populate the hierarchical classification tree based on rule text and constraint information. The search module S603 is used to extract structured data from rule corpora using a large language model to obtain rule text and constraint information; it performs a single-round search starting from the root node and inputs candidate node information, text to be classified, and constraint information into the large language model to determine the next hop node or termination node; it performs query rewriting and multi-round retrieval based on historical search paths, updates the search path according to new search information and search status, and aggregates the nodes and evidence obtained from multiple rounds of search. In some embodiments, the structured processing module S602 can perform structured processing on the rule text, constraint information, and evidence content corresponding to the hierarchical nodes in the offline stage, and generate corresponding node indexes. The search module S603 calls the node indexes in the online retrieval stage to perform similarity search and candidate node recall.

[0087] The output module S604 is used to output the target classification result, normalized classification code, and corresponding search path and constraint information of the text to be classified.

[0088] The other features of this hierarchical search classification system based on constraint rules and query rewriting are consistent with the hierarchical search classification method based on constraint rules and query rewriting described above, and will not be repeated here.

[0089] The modules in the hierarchical search classification system based on constraint rules and query rewriting described above can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0090] In one embodiment, Figure 4 A schematic structural diagram of a computer device according to an embodiment of the present invention is shown, such as Figure 4 As shown, the computer device can be a terminal, and its internal structure diagram can be as follows. Figure 4As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a hierarchical search classification method based on constraint rules and query rewriting. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0091] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0092] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the hierarchical search classification method based on constraint rules and query rewriting described above.

[0093] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the hierarchical search classification method based on constraint rules and query rewriting described above.

[0094] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0095] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0096] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0097] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A hierarchical search classification method based on constraint rules and query rewriting, characterized in that, include: Construct a hierarchical classification tree, which includes hierarchical nodes, node relationships, and associated constraint information for the hierarchical nodes; The rule corpus is structured and extracted using a large language model to obtain the rule text and the constraint information, and a hierarchical classification tree is populated based on the rule text and the constraint information. The process involves: acquiring the text to be classified; performing a single-round search starting from the root node; inputting candidate node information, the text to be classified, and the constraint information into a large language model to determine the next-hop node or the termination node; extracting keywords from the text to be classified and generating a query vector based on the keywords; calculating the similarity between the current node's child nodes based on the query vector to recall candidate nodes; wherein, during the vector matching calculation, corresponding node vectors are generated based on the category code, title, node text, rule description, exclusion clause, and definition clause corresponding to the child nodes, and candidate nodes are recalled based on the similarity between the query vector of the text to be classified and the node vectors corresponding to each child node, with evidence fragments not participating in the vector similarity calculation; inputting the text to be classified, the current node, candidate nodes, and corresponding constraint information into the large language model to perform path reasoning and determine the next-hop node, stopping the single-round search when a first preset termination condition is met; wherein, the large language model performs confidence judgment on candidate nodes based on evidence fragments in the constraint information to ultimately determine the search path; and generating and outputting a classification result summary based on the search path nodes and corresponding constraint information. The process involves rewriting queries and performing multiple rounds of retrieval based on historical search paths. The search path is updated according to newly added search information and search status, and the nodes and evidence obtained from multiple rounds of search are aggregated. This includes: obtaining the historical search path, corresponding constraint information, query vector, and classification result summary to generate historical search information; generating rewritten query text based on the text to be classified and the historical search information; extracting keywords and vectorizing the rewritten query text to obtain a retrieval query vector; re-executing the single-round search based on the retrieval query vector and performing subsequent search planning; and stopping the multi-round search when a second preset termination condition is met. The newly added search information includes newly added hierarchical nodes, newly added evidence fragments, and / or newly added constraint information relative to the historical search trajectory. Output the target classification result, normalized classification code, and corresponding search path and constraint information for the text to be classified.

2. The method according to claim 1, characterized in that, The constraint information includes rule descriptions, exclusion clauses, defining provisions, and evidence fragments.

3. The method according to claim 1, characterized in that, The first preset termination condition includes: The large language model outputs a stop signal, including when the large language model determines that the current level needs to stop continuing to execute the search for the next level node, and / or when the matching confidence of the candidate node is lower than a first preset threshold, the stop signal is generated. The current node has no child nodes; The current search depth has reached the preset maximum depth.

4. The method according to claim 3, characterized in that, Based on the search path nodes and corresponding constraint information, a classification result summary is generated and output, including: Obtain the historical nodes of a single-round search, the corresponding constraint information, and the query vector; The similarity is recalculated based on the corresponding constraint information and the query vector; The constraint information is merged and deduplication and filtering are performed based on similarity scores to generate the classification result summary.

5. The method according to claim 1, characterized in that, The second preset termination condition includes: The matching confidence of the target node is not lower than the second preset threshold, and the evidence fragment corresponding to the target node meets the preset evidence sufficiency conditions; The number of rounds of the multi-round search reaches a third preset threshold; The multi-round search did not acquire any new nodes and / or new evidence fragments within a preset number of rounds.

6. A hierarchical search and classification system based on constraint rules and query rewriting, characterized in that, include: The acquisition module is used to acquire the text to be classified. The structured processing module is used to extract structured data from the rule corpus using a large language model to obtain rule text and constraint information, construct a hierarchical classification tree, the hierarchical classification tree includes hierarchical nodes and node relationships, the hierarchical nodes are associated with the constraint information, and the hierarchical classification tree is populated based on the rule text and the constraint information to generate corresponding node indexes; Keyword extraction is performed on the text to be classified, and a query vector is generated based on the keywords; The similarity between the current node's child nodes is calculated based on the query vector to recall candidate nodes. During vector matching, corresponding node vectors are generated based on the category code, title, node text, rule description, exclusion clauses, and defining clauses of each child node. Candidate nodes are recalled based on the similarity between the query vector of the text to be classified and the node vectors corresponding to each child node. Evidence fragments are not included in the vector similarity calculation. The text to be classified, the current node, candidate nodes, and corresponding constraint information are input into a large language model to perform path reasoning and determine the next hop node. The single-round search stops when a first preset termination condition is met. The large language model performs confidence assessment on candidate nodes based on evidence fragments in the constraint information to ultimately determine the search path. A classification result summary is generated and output based on the search path nodes and corresponding constraint information. The search module is used to invoke the node index during the online retrieval phase, perform a single-round search starting from the root node, and input candidate node information, the text to be classified, and the constraint information into a large language model to determine the next hop node or the termination node; perform query rewriting and multi-round retrieval based on the historical search path, update the search path according to the new search information and search status, and aggregate the nodes and evidence obtained from the multi-round search; the query rewriting and multi-round retrieval based on the historical search path, and update the search path according to the new search information and search status, including: obtaining the historical search path, corresponding constraint information, query vector, and classification result summary to generate historical search information; generating a rewritten query text based on the text to be classified and the historical search information, and extracting keywords and vectorizing the rewritten query text to obtain a retrieval query vector; re-executing the single-round search based on the retrieval query vector and performing subsequent search planning; stopping the multi-round search when a second preset termination condition is met; the new search information includes new hierarchical nodes, new evidence fragments, and / or new constraint information relative to the historical search trajectory; The output module is used to output the target classification result, normalized classification code, and corresponding search path and constraint information for the text to be classified.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the hierarchical search classification method based on constraint rules and query rewriting as described in any one of claims 1-5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the hierarchical search classification method based on constraint rules and query rewriting as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Hierarchical retrieval enhancement generation method and system

    CN119621919A

  • Multilayer structure perception retrieval enhancement generation method and system oriented to law document

    CN122132427A