A sequence retrieval and classification method based on domain rule knowledge and data
By combining domain rule knowledge with data, a standardized chapter structure tree was constructed and the loss function was optimized, which solved the problem of the ineffective integration of document retrieval and classification methods, and improved the accuracy and consistency of document retrieval and classification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- RENMIN UNIVERSITY OF CHINA
- Filing Date
- 2024-05-28
- Publication Date
- 2026-07-24
AI Technical Summary
Existing document retrieval and classification methods have failed to integrate effectively, resulting in inaccurate and opaque retrieval results and making it difficult to leverage domain expertise to guide predictions.
By combining domain rule knowledge and data with a key text extraction module, a canonical structure tree module, and a modified loss module, a canonical structure tree is constructed to generate domain-aware semantic identifiers. The model is then optimized through a modified loss function to achieve dual prediction for text classification and retrieval.
It improves the accuracy and consistency of document retrieval and classification, ensuring that the model can simultaneously perform text classification and predict related documents in a single inference process.
Smart Images

Figure CN118520112B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer science, and more specifically, to a sequence retrieval and classification method based on domain rule knowledge and data. Background Technology
[0002] In text processing systems with domain-specific rule knowledge, document retrieval and document classification are two core tasks. In practical applications, determining whether two documents share the same classification label is crucial for establishing their relevance in the retrieval task. However, current document retrieval research often neglects the importance of document classification or relies on implicit training objectives that expect documents to be appropriately arranged in the vector space according to their classification labels. These existing methods fail to provide explicit proofs of classification consistency for relevance modeling, leading to inaccurate and opaque retrieval results.
[0003] Existing document retrieval technologies mainly include network-based precedent methods, text similarity-based classification methods, and end-to-end generative retrieval methods. Network-based methods typically use precedent networks to determine the association between documents; text-based methods typically use the BERT model to calculate the similarity between document paragraphs; generative retrieval methods achieve end-to-end retrieval by assigning semantic identifiers to documents and using language models to generate identifiers.
[0004] The drawback of these existing technologies lies in their failure to explicitly integrate the context-based document classification task with the document retrieval task. Typically, document retrieval and document classification are treated as two separate machine learning problems—retrieval and classification. This approach makes it difficult for retrieval models to predict the appropriate classification labels for documents and to leverage classification predictions to improve retrieval performance. Furthermore, the inherent complexity of documents leads to retrieval efficiency issues and makes it difficult to generate shared and information-rich representations for each document for both tasks. Finally, these tasks rely on specialized domain rule knowledge, and effectively incorporating domain expertise to guide predictions for both tasks remains a challenge. Summary of the Invention
[0005] The purpose of this disclosure is to provide a sequence retrieval and classification method based on domain rule knowledge and data, aiming to evaluate and enhance the robustness of the model by combining it with other basic adversarial example generation techniques. Traditional adversarial example generation techniques mainly focus on averaging the attack effect of multiple models, without fully considering the contribution of differences between models to the attack. Existing techniques cannot effectively adapt to the characteristics of different models, nor can they provide adversarial examples with strong adaptability and high generalization ability.
[0006] In general, this paper provides a sequence retrieval and classification method based on domain rule knowledge and data, including a key text extraction module, a standard chapter structure tree module, and a loss correction module.
[0007] The key text extraction module takes into account the candidate text sequence after manual review, the query text sequence, and the text sequence portion of the domain rule knowledge specification chapter to obtain the key text sequence E for each document; the specification chapter structure tree module takes into account the text knowledge in the domain rule knowledge specification chapter and uses the inherent hierarchical structure of the specification chapter to which the document belongs to guide the retrieval process; through the key text extraction module and the specification chapter structure tree module, it is possible to start from the root node in a single reasoning process, traverse through the intermediate classification nodes to the leaf node of a specific document, and thus perform dual prediction of text classification and related documents;
[0008] The corrected loss module calculates the loss by comparing the difference between the predicted document identifier and the actual labeled document identifier.
[0009] The key text extraction module is defined as f R Its workflow is as follows:
[0010] Step 1. Construct a domain rule knowledge corpus: First, construct a corpus B = {B1, B2, B3} based on the detailed definitions of categories in the domain rules. The corpus includes a keyword set B1 for scenario terms, a keyword set B2 for normative chapters, and an embedded set B3 of rule definition text content of normative chapters.
[0011] Step 2. Keyword Extraction: Segment the document into words at the word level, and select the most frequently occurring keywords k1 and k2 from B1 and B2 as key text. The formula is as follows:
[0012]
[0013] Step 3. Sentence Extraction: At the sentence level, for each sentence in the document, calculate its similarity to the domain rule terminology definition, and select the k3 sentences most relevant to the domain rule terminology as key texts E. s The formula is as follows:
[0014]
[0015] Where len() represents the sentence length; cos(·) represents the cosine similarity; assuming w∈s represents a word in sentence s, and tf represents the word frequency, then sim(·) is defined as follows:
[0016]
[0017] Step 4. Integration of key texts: The extracted key words and key sentence texts are integrated to form a key text sequence E for each document. These key texts replace the original documents as query inputs for subsequent retrieval and classification prediction processes.
[0018] The standard structure tree module is defined as f T Its workflow is as follows:
[0019] Step 1. Utilizing the hierarchical structure: This hierarchical structure is simulated by constructing a canonical constraint tree. A constraint tree T is built, and each candidate document a is assigned a domain-rule-aware semantic identifier id. a ;
[0020] Step 2. Semantic Identifier Assignment: The semantic identifier for each document is assigned according to its position in the hierarchical structure of the specification. If a document is associated with a clause in a specific chapter, the identifier of that clause becomes the prefix of the document identifier. For suffixes, this module assigns multiple identifiers to a document, each identifier corresponding to a specific category.
[0021] Step 3. Retrieval Process: Each identifier can point to either the corresponding candidate document or a category within the canonical text.
[0022] The loss correction module is defined as Its calculation method is as follows:
[0023] Step 1. Reward Mechanism: For each query, the generative model will generate a series of predicted document identifiers using the beam search algorithm, and then compare them with a series of truly labeled document identifiers. Formally, given a series of predicted identifiers (where one identifier can be represented as a list of integers)... And the corresponding label values; for query q, both have a length of L, compare their differences, and calculate the reward R for each step t∈[1,L]. t as follows:
[0024]
[0025] Step 2. Hierarchical Penalty Factor: Introduce the hierarchical penalty factor γ h This results in a larger penalty for predictions at the root of the tree and a smaller penalty for predictions at the leaf nodes.
[0026] Step 3. Ranking Penalty Factor: Introduce a ranking penalty factor γ. r This is used to enhance the relevance of documents at the top of the search list, and to impose a greater penalty if the identifier of a document that is predicted earlier is incorrect.
[0027] Step 4. Reward Definition: If the predicted identifier node and the label identifier node are the same, a positive reward is given; otherwise, a negative reward is calculated based on the location and level of the prediction error penalty factor.
[0028]
[0029] Where bz represents the size of the data beam, which is the number of documents that need to be retrieved for each query; Given q, predict and generate at layer t. The probability of λ; w It is the balance coefficient.
[0030] The innovation of this invention lies in:
[0031] This invention introduces a sequence retrieval and classification method based on domain rule knowledge and data, explicitly integrating text sequence classification into the retrieval task through domain rule knowledge. This method utilizes domain rule knowledge to extract key text from documents, ensuring the sharing of information between the two tasks and a rich representation of the information. Based on the inherent hierarchical structure of the canonical canon of domain rule knowledge, this method constructs a canonical canonical structure constraint tree and assigns a domain rule knowledge-aware semantic identifier to each document. These designs enable the method to perform dual prediction of text classification and related documents by starting from the root node, traversing through intermediate classification nodes, and reaching the leaf nodes of a specific document in a single inference process. With the proposed modified loss, this algorithm uniformly minimizes the difference between the identifiers of the predicted and labeled classified / retrieved documents, improving the accuracy and consistency of both tasks. Attached Figure Description
[0032] The above and other objects and features of this disclosure will become clearer from the following description taken in conjunction with the accompanying drawings.
[0033] Figure 1 This is a schematic diagram illustrating the architecture of a sequence retrieval and classification method based on domain rule knowledge and data according to an embodiment of the present disclosure. Detailed Implementation
[0034] The following detailed embodiments are provided to aid the reader in gaining a comprehensive understanding of the methods, apparatus, and / or systems described herein. However, various changes, modifications, and equivalents of the methods, apparatus, and / or systems described herein will become apparent upon understanding this disclosure. For example, the order of operations described herein is merely illustrative and is not limited to those orders set forth herein, but may be changed as will become clear upon understanding this disclosure, except for operations that must occur in a specific order. Furthermore, for clarity and conciseness, descriptions of features known in the art may be omitted.
[0035] The features described herein may be implemented in different forms and should not be construed as limited to the examples described herein. Rather, the examples described herein are provided only to illustrate some of the many feasible ways of implementing the methods, apparatus, and / or systems described herein, which will become clear upon understanding the disclosure of this application.
[0036] As used herein, the term “and / or” includes any one of the associated listed items and any combination of any two or more.
[0037] Although terms such as “first,” “second,” and “third” may be used herein to describe various components, assemblies, regions, layers, or parts, these components, assemblies, regions, layers, or parts should not be limited by these terms. Rather, these terms are used only to distinguish one component, assembly, region, layer, or part from another. Thus, without departing from the teaching of the examples described herein, the first component, first assembly, first region, first layer, or first part referred to as the first component, first assembly, first region, first layer, or first part may also be referred to as the second component, second assembly, second region, second layer, or second part.
[0038] In the specification, when an element (such as a layer, region, or substrate) is described as being "on" another element, "connected to," or "bonded to" another element, the element may be directly "on" another element, directly "connected to," or "bonded to" the other element, or one or more other elements may be present in between. Conversely, when an element is described as being "directly on" another element, "directly connected to," or "directly bonded to" another element, no other elements may be present in between.
[0039] The terminology used herein is for the purpose of describing various examples only and is not intended to limit disclosure. Unless the context clearly indicates otherwise, the singular form is intended to include the plural form as well. The terms “comprising,” “including,” and “having” indicate the presence of the described features, quantities, operations, components, elements, and / or combinations thereof, but do not preclude the presence or addition of one or more other features, quantities, operations, components, elements, and / or combinations thereof.
[0040] Unless otherwise defined, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains upon understanding this disclosure. Unless expressly defined herein, terms (such as those defined in a general dictionary) shall be interpreted as having a meaning consistent with their meaning in the context of the relevant field and in this disclosure, and shall not be interpreted in an idealized or overly formalistic manner.
[0041] Furthermore, in the description of the examples, detailed descriptions of well-known related structures or functions will be omitted when it is believed that such detailed descriptions would lead to a vague interpretation of this disclosure.
[0042] Figure 1 This is a schematic diagram illustrating a sequence retrieval and classification method based on domain rule knowledge and data according to an embodiment of the present disclosure.
[0043] This method mainly consists of three modules: a key text extraction module, a canonical structure tree module, and a loss correction module. These three modules are designed around a generative backbone model. The generative backbone model adopts the widely used sequence-to-sequence model T5.
[0044] The core idea of this method is to transform the retrieval process into generating domain-aware semantic identifiers, where each identifier not only represents a document related to the query, but also reflects its applicable category label.
[0045] The key text extraction module, the first module of this method, takes candidate text sequences, query text sequences, and text sequences from the domain rule knowledge specification as input, and outputs candidate sequences composed of key texts and query sequences composed of key key texts. Specifically, the key text extraction module first constructs a corpus based on the textual knowledge in the domain rule knowledge specification, and then extracts text content representing the key topics of each document from it. Subsequent models are trained using this key text content output by this module, rather than the original text sequences.
[0046] The canonical structure tree module, the second module of this method, outputs the directory structure of the domain rule knowledge canonical structure and a constraint tree structure object of document identifiers. The structure tree is a structured constraint tree created based on the inherent directory hierarchy in the domain rule knowledge canonical structure, assigning a hierarchical semantic identifier to each candidate document. For example, the identifier for the 709th document under category 267 in Chapter 2, Section 5 (part) will be represented as "0-2-5-267-709". The tree constructed from these identifier paths is output as this module and provided to the generative backbone model to constrain its generative search space. Furthermore, the identifier represents not only the document itself but also its category, enabling the model to make dual predictions for document classification results and related document retrieval in a single inference process.
[0047] The modified loss module, the third module of this method, takes the retrieval output of the generative backbone model as input and outputs a value that considers both hierarchical and ranking losses. The main component is a modified loss function. The optimizer reduces the loss value through gradient descent, uniformly minimizing the difference between the predicted and classification labels and the identifiers of the retrieved documents, thereby improving the accuracy and consistency of both tasks.
[0048] The three modules will be introduced in detail below.
[0049] Key text extraction module
[0050] The purpose of key text extraction is to ensure retrieval efficiency and provide shared, information-rich representations of documents, thus serving both document retrieval and document classification tasks simultaneously. The key text extraction module in this algorithm (denoted as f) R Instead of using the original document as input, it extracts key text E, which is text that represents the key information in the document at the word and sentence levels.
[0051] like Figure 1 As shown, the key text extraction module f R The workflow is as follows:
[0052] 1. Construct a domain rule knowledge corpus: First, construct a corpus B = {B1, B2, B3} based on the detailed definitions of categories in the domain rules. This corpus includes a keyword set B1 for scenario terms, a keyword set B2 for normative chapters, and an embedding set B3 of the rule definition text content of normative chapters.
[0053] 2. Keyword Extraction: At the word level, the document is segmented into words, and the most frequently occurring keywords k1 and k2 from B1 and B2 are selected as key text. The formula is as follows:
[0054]
[0055] 3. Sentence Extraction: At the sentence level, for each sentence in the document, calculate its similarity to the domain rule terminology definition, and select the k3 sentences most relevant to the domain rule terminology as key texts E. s The formula is as follows:
[0056]
[0057] Where len() represents the sentence length; cos(·) represents the cosine similarity; assuming w∈s represents a word in sentence s, and tf represents the word frequency, then sim(·) is defined as follows:
[0058]
[0059] 4. Integration of key texts: The extracted key words and key sentence texts are integrated to form a key text sequence E for each document. These key texts replace the original documents as query inputs for subsequent retrieval and classification prediction processes.
[0060] Through the steps described above, the method of this invention can extract concise and information-rich key text from documents governed by domain rules. This key text not only improves retrieval efficiency but also provides a shared representation with domain rule knowledge for document retrieval and classification tasks. This representation helps the model better understand and process rule-based text sequences, thereby improving the accuracy and consistency of predictions.
[0061] Standardized Structure Tree Module
[0062] The normative structure tree module is another core component of the method of this invention. It uses the inherent hierarchical structure of the normative structure to which the document belongs to guide the retrieval process.
[0063] like Figure 1 As shown, the normative structure tree module f T The workflow is as follows:
[0064] 1. Utilization of Hierarchical Structure: Considering domain rule knowledge, normative documents are typically organized according to a hierarchical structure such as "chapter-section-class-document details". This algorithm simulates this hierarchical structure by constructing a normative document constraint tree. A constraint tree T is constructed, and each candidate document a is assigned a domain rule knowledge-aware semantic identifier id. a .
[0065] 2. Semantic Identifier Assignment: Each document's semantic identifier is assigned based on its position in the hierarchical structure of the specification. For example, if a document is associated with a clause in a specific chapter, then the identifier of that clause becomes the prefix of the document's identifier. For suffixes, since a document may involve multiple categories within the specification, this module assigns multiple identifiers to the document, each corresponding to a specific category.
[0066] 3. Retrieval Process: During retrieval, the overall goal of the scheme is to enable the model to retrieve all identifiers of the target document, where each identifier can point to both the corresponding candidate document and a specific category within the canonical text. This design allows the model to perform dual predictions—classification and relevant document retrieval—simultaneously in a single inference process.
[0067] Loss Correction Module
[0068] The modified loss is a training objective proposed in this invention for generative models. It calculates the loss by comparing the difference between the document identifiers predicted by the model and the document identifiers labeled in reality, thereby enhancing the accuracy of the model in document retrieval and document classification prediction tasks.
[0069] like Figure 1 As shown, corrected loss The calculation method is as follows:
[0070] 1. Reward Mechanism: For each query, the generative model generates a series of predicted document identifiers using the beam search algorithm, and then compares them with a series of ground truth labeled document identifiers. Formally, given a series of predicted identifiers (where one identifier can be represented as a list of integers)... and the corresponding tag values (where one of the identifiers can be represented as a list of integers [id1, id2, ..., id...). L For query q, both have a length of L. This module compares their differences and calculates the reward R for each step t∈[1,L]. t as follows:
[0071]
[0072] 2. Hierarchical Penalty Factor: This method introduces a hierarchical penalty factor γ. hThis is used to penalize discrepancies between predictions and annotations at different levels of the canonical structure tree. Since reasoning about identifiers proceeds from high to low levels, successful predictions at high-level nodes are a necessary condition for successful predictions at low-level nodes. Therefore, the hierarchical penalty factor ensures that the model receives a larger penalty for predictions at the root of the tree (i.e., higher levels) and a smaller penalty for predictions at the leaf nodes of the tree (i.e., more specific document nodes).
[0073] 3. Ranking Penalty Factor: In addition to the hierarchical penalty factor, a ranking penalty factor γ is also introduced. r This is used to enhance the relevance of documents at the top of the search list, and to impose a greater penalty if the identifier of a document that is predicted earlier is incorrect.
[0074] 4. Reward definition: If the prediction identifier node and the label identifier node are the same, a positive reward is given; if they are not the same, a negative reward is calculated based on the location and level penalty factor of the prediction error.
[0075]
[0076] Where bz represents the size of the data beam, which is the number of documents that need to be retrieved for each query; Given q, predict and generate at layer t. The probability of λ; w It is the balance coefficient.
[0077] Model training
[0078] Following the basic paradigm of generative retrieval models, this invention introduces an identifier id based on the query text q to the related document r. r And candidate document c to its own identifier id c The basic loss functions for the two training tasks are:
[0079]
[0080] In summary, we utilize the hyperparameter λ l By controlling the proportion of the correction loss, the final loss is used to optimize all trainable parameters θ:
[0081]
[0082] While some embodiments of this disclosure have been shown and described, those skilled in the art will understand that modifications may be made to these embodiments without departing from the principles and spirit of this disclosure, which are defined by the claims and their equivalents.
Claims
1. A sequence retrieval and classification method based on domain rule knowledge and data, characterized in that, This includes a key text extraction module, a standard structure tree module, and a loss correction module; The key text extraction module takes into input the candidate text sequence after manual review, the query text sequence, and the text knowledge from the text sequence portion of the domain rule knowledge specification, and obtains the key text sequence that forms each document. The normative structure tree module takes into account the textual knowledge in the normative structure of the domain rule knowledge, and uses the inherent hierarchical structure of the normative structure to which the document belongs to guide the retrieval process; through the key text extraction module and the normative structure tree module, it realizes the dual prediction of text classification and related documents by starting from the root node, traversing through the intermediate classification nodes to the leaf node of the specific document in a single reasoning process; The corrected loss module calculates the loss by comparing the difference between the predicted document identifier and the actual labeled document identifier; The key text extraction module is defined as Its workflow is as follows: Step 1. Construct a domain rule knowledge corpus: First, construct a corpus based on the detailed definitions of categories in the domain rules. The corpus includes a set of keywords for scene terms. Keyword set of normative regulations And the embedded set of rule definition text content of normative codes and regulations. ; Step 2. Keyword Extraction: Segment the document into words at the word level, and extract keywords from... and Choose the one that appears most frequently and One keyword as key text The formula is as follows: ; Step 3. Sentence Extraction: At the sentence level, for each sentence in the document, calculate its similarity to the domain rule terminology definition, and select the sentence most relevant to the domain rule terminology. The sentence is used as the key text. The formula is as follows: , in, Indicates sentence length; Represent cosine similarity; assume Sentence In the word, tf represents word frequency, then The definition is as follows: . Step 4. Key Text Integration: Integrate the extracted keywords and key sentences to form a key text sequence for each document. These key texts replace the original documents as query inputs for subsequent retrieval and classification prediction processes; The normative structure tree module is defined as follows: Its workflow is as follows: Step 1. Utilizing the hierarchical structure: This hierarchical structure is simulated by constructing a canonical constraint tree. and for each candidate document Assign a semantic identifier for domain rule knowledge awareness ; Step 2. Semantic Identifier Assignment: The semantic identifier for each document is assigned according to its position in the hierarchical structure of the specification. If a document is associated with a clause in a specific chapter, the identifier of that clause becomes the prefix of the document identifier. For suffixes, this module assigns multiple identifiers to a document, each identifier corresponding to a specific category. Step 3. Retrieval process: Each identifier can point to either the corresponding candidate document or a category of the canonical text.
2. The sequence retrieval and classification method based on domain rule knowledge and data as described in claim 1, characterized in that, The loss correction module is defined as Its calculation method is as follows: Step 1. Reward Mechanism: For each query, the generative model will generate a series of predicted document identifiers using the beam search algorithm, and then compare them with a series of truly labeled document identifiers. Formally, given a series of predicted identifiers and their corresponding label values, where one identifier is represented as a list of integers... , , ..., ]; For queries Both are of length Compare the differences between them and calculate each step. Rewards as follows: Step 2. Hierarchical Penalty Factor: Introduce a hierarchical penalty factor. This results in a larger penalty for predictions at the root of the tree and a smaller penalty for predictions at the leaf nodes. Step 3. Ranking Penalty Factor: Introduce a ranking penalty factor. This is used to enhance the relevance of documents at the top of the search list, and to impose a greater penalty if the identifier of a document that is predicted earlier is incorrect. Step 4. Reward Definition: If the predicted identifier node and the label identifier node are the same, a positive reward is given; otherwise, a negative reward is calculated based on the location and level of the prediction error penalty factor. , in This indicates the size of the data bundle beam, which is the number of documents that need to be retrieved for each query; It is given at level t. Predictive generation The probability of; It is the balance coefficient.
Citation Information
Patent Citations
System standard retrieval method and system based on electric power knowledge base and readable storage medium
CN112307171A
Power grid operation rule knowledge graph construction system and method
CN113918512A