Coding specification-based domain knowledge chain retrieval method
By building a dictionary tree and coding specifications, combining knowledge coding and reordering models, the search process of large language models is optimized, and the problems of irrelevant text block recall and key information omissions are solved, improving the search efficiency and text generated.
Patent Information
- Application Number
- CN202511029400.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-07-25
AI Technical Summary
Existing large language models are prone to recalling irrelevant text blocks when generating text, missing key information, and are interfered with irrelevant text blocks when searching across documents, making the calculation efficiency in inaccurate.
The dictionary tree is constructed and the encoding specification is adopted. By calculating the summary similarity of the embedded vector of the query text and the document tree, combining knowledge coding and reordering models, the search process is optimized, and a variety of ranking and score calculation methods are used.
It effectively avoids recall of irrelevant text blocks, improves the accuracy and efficiency of search results, reduces interference with irrelevant documents, and improves the quality of generated text.
Smart Images

Figure CN120523928A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a retrieval method, and more particularly to a retrieval method for a domain knowledge chain based on coding specifications. Background Art
[0002] A large language model is a neural network model with a large number of parameters and a certain level of language capability. A large language model can generate relevant text based on human instructions. However, text directly generated by a large language model may contain content that is inconsistent with the facts, a phenomenon known as large language model hallucination. Retrieval-augmented generation technology first queries the knowledge base based on human instructions. The retrieved text and the human instructions are then fed into the large language model, providing it with accurate, specialized, and up-to-date knowledge, thereby improving the quality of the text generated by the large language model.
[0003] A naive retrieval-augmented generation method first segments the document into text chunks and then uses an embedding model to generate an embedding vector for each chunk. For each user query, the naive retrieval-augmented generation method first uses the embedding model to generate an embedding vector for the user's query text. It then calculates the cosine similarity between the query embedding vector and the embedding vectors of each chunk, and recalls the chunks with the highest similarity.
[0004] Naive retrieval-augmentation methods still have many drawbacks. First, they are limited by the capabilities of the embedding model, making them prone to recalling text blocks irrelevant to the query and missing blocks containing critical information. Second, when performing cross-document retrieval, naive retrieval-augmentation methods are susceptible to interference from similar text blocks in unrelated documents, which can affect recall results. Finally, naive retrieval-augmentation methods require calculating the cosine similarity between the query text embedding vector and the embedding vector of each text block, which is time-consuming. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of the present invention is to provide a retrieval method for domain knowledge chains based on coding standards that can effectively avoid the above disadvantages.
[0006] To achieve the above-mentioned purpose, the present invention provides the following technical solution: a method for retrieving domain knowledge chains based on coding standards, comprising the following steps: Step 1: Define the corresponding coding standards for different fields, and then build a dictionary tree , the dictionary tree Contains summary , the abstract It is the parent node of all top-level text blocks; Step 2: Dictionary tree built based on step 1 , by calculating the query text Embedding vector of , and then calculate the embedding vector of the query text and a summary of all document trees The knowledge chain is retrieved by measuring the similarity of the two.
[0007] As a further improvement of the present invention, the specific steps of performing knowledge chain retrieval in step 2 are as follows: Step 21: Calculate the query text Embedding vector of , and then generate an encoding of the knowledge needed to answer the query , Step 22: Encode based on knowledge The given path gets with the longest common prefix documents and calculate the embedding vector of the query text and a summary of all document trees and select the one with the highest similarity The tree gets the selected text block set as , Step 2 and 3: Calculate the embedding vector and the cosine similarity ranking of the embedding vectors of all candidate text blocks, and and the BM25 ranking of all candidate text blocks; Step 24: Use the RRF algorithm to calculate the comprehensive score and update the candidate text block set to the one with the highest score in the current set. a text block; Step 25: Collect the candidate text blocks and calculate the query text The similarity between the text blocks and the merged candidate text block set is the highest similarity. The text blocks are returned as search results.
[0008] As a further improvement of the present invention, the dictionary tree is constructed in step 1. The specific steps are as follows: Step 1: Maintain a dictionary tree ; Steps 1 and 2: For each document to be built , without breaking the sentence, split it into several text blocks according to length , Indicates the The 0th level of the document tree a text block; Step 1 and 3: Use the embedding model to calculate the embedding vectors of all text blocks, where The first document The embedding vector of a text block is ; Step 14: Document No. Layer, using Gaussian mixture clustering algorithm to embed vector Perform clustering; Step 15: Group the text blocks according to the clustering results, and the text blocks in each group belong to the same category; Step 16, then, traverse each group and use the large language model to Group text blocks to create summaries, and the resulting summaries serve as the next level of text blocks , the text block is The parent node of all text blocks in the group; Step 17: Repeat steps 13 to 15 for the preset number of times, and then use the large language model to create summaries for all the top-level text blocks at this time as the summary of the document tree. , It is the parent node of all top-level text blocks; Step 18: Use the summary of the document tree As well as a description of the encoding standards in the current scenario, use the large language model to create the knowledge encoding of the document tree , and add the code to the dictionary tree middle.
[0009] As a further improvement of the present invention, the query text is calculated in step 21. Embedding vector of , and then generate an encoding of the knowledge needed to answer the query The specific method is: first use the embedding model to calculate the query text Embedding vector of , and then use the large language model, according to and a description of the encoding specifications for the current scenario, generating the encoding of the knowledge required to answer the query .
[0010] As a further improvement of the present invention, the embedding vector of the query text is calculated in step 22. and a summary of all document trees and select the one with the highest similarity The tree gets the selected text block set as The specific method is: first, along the knowledge encoding Given the path, in the dictionary tree The search continues downward until a leaf node is found or the next bit of the knowledge code does not exist in the child nodes of the current node in the dictionary tree. This search link is the knowledge chain. By tracing back along the knowledge chain, we can get with the longest common prefix documents, and then use the reranking model to calculate the embedding vector of the query text and a summary of all document trees and select the one with the highest similarity For each selected document tree, the candidate text block set is initialized as .
[0011] As a further improvement of the present invention, in step 22, the initialization candidate text block set is obtained as Finally, the candidate text block set is updated to be the set of child nodes of all nodes in the current set.
[0012] As a further improvement of the present invention, in step 24, the candidate text block set is updated to the one with the highest score in the current set. After the text blocks, we repeat the step 2 to calculate the embedding vector of the query text using the reranking model. and a summary of all document trees and select the one with the highest similarity For each selected document tree, the candidate text block set is initialized as Steps, until the node in the candidate text block set is a leaf node.
[0013] As a further improvement of the present invention, in step 24, the candidate text block set is updated to the one with the highest score in the current set. After the text blocks, we repeat the step 2 to calculate the embedding vector of the query text using the reranking model. and a summary of all document trees and select the one with the highest similarity For each selected document tree, the candidate text block set is initialized as Steps, until the node in the candidate text block set is a leaf node.
[0014] The beneficial effect of the present invention is that compared with the simple search enhancement generation method mentioned in the background technology, the present invention constructs a dictionary tree Combined with a series of operations such as encoding standards, it effectively avoids the problem of recalling irrelevant text blocks and missing key information text blocks due to the limitations of the embedding model. In terms of cross-document retrieval, through knowledge encoding and dictionary tree The search and other steps reduce the interference of similar text blocks in irrelevant documents, improving the accuracy of recall results. Furthermore, in the process of calculating similarity, multiple ranking and comprehensive scoring methods are used, rather than simply calculating cosine similarity. This optimizes time costs to a certain extent, improves retrieval efficiency and the quality of generated text, and overcomes many of the shortcomings of naive retrieval enhancement generation methods. Compared with existing methods, the method of the present invention reduces the interference of irrelevant text blocks in related documents on recall results, thereby improving the quality of large-scale model answers. It also reduces the interference of similar text blocks in irrelevant documents on recall results, thereby improving the quality of large-scale model answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 A schematic diagram of coding standards defined in different fields; Figure 2 For dictionary tree A schematic diagram of the construction process; Figure 3 Schematic diagram of the retrieval method of domain knowledge chain based on coding standards. DETAILED DESCRIPTION
[0016] The present invention will be further described below with reference to the embodiments shown in the accompanying drawings.
[0017] Reference Figures 1 to 3 As shown, a method for retrieving a domain knowledge chain based on coding standards in this embodiment mainly includes coding standard definition, construction and retrieval.
[0018] The encoding standard in this embodiment is called knowledge encoding and is defined as follows: Knowledge encoding should consist of two parts that appear in sequence: Six-digit universal code, two digits per group.
[0019] Optional variable-length extension code, two digits per group.
[0020] The value range of each code is 00~99.
[0021] The first group of general codes is the major field category codes, for example, 06 represents technology.
[0022] The second group of general codes is the field subcategory codes, which are further subdivided under the field represented by the first group. For example, if the first group is 06, the second group 01 represents medicine.
[0023] The third group of the general code is the subdivision direction. For example, when the first two groups are 06-01, the third group 16 represents the disease.
[0024] Extended coding is used to further subdivide knowledge. For example, when the general coding is 06-01-16, the first group of extended coding 01 represents cardiovascular disease.
[0025] Extended codes can continuously subdivide knowledge according to actual needs. For example, in the case of medical knowledge questions and answers, the document segmentation to cardiovascular disease is still too broad, and the next extended code 02 can be added to represent thrombosis.
[0026] In summary, the knowledge code for a document related to thrombosis prevention should be 06-01-16-01-02.
[0027] Based on this set of encoding standards, the more relevant the content of a document is, the longer the common prefix of its knowledge encoding will be.
[0028] For general fields, this coding standard is compatible with the Dewey Decimal Classification and the Chinese Library Classification, and can be used directly for comparison.
[0029] For specific professional fields, experts in the corresponding fields can be organized to define the semantics of each bit of coding to achieve the classification of segmented documents.
[0030] The build process consists of the following steps: Maintaining a dictionary tree .
[0031] For each document to be built , without breaking the sentence, split it into several text blocks according to length , Indicates the The 0th level of the document tree A block of text.
[0032] Use the embedding model to calculate the embedding vectors of all text blocks, where The first document The embedding vector of a text block is .
[0033] For documents No. Layer, using Gaussian mixture clustering algorithm to embed vector Perform clustering.
[0034] The text blocks are grouped according to the clustering results, and the text blocks in each group belong to the same category.
[0035] Then, traverse each group and use the large language model to Group text blocks to create summaries, and the resulting summaries serve as the next level of text blocks , the text block is The parent node of all text blocks in the group.
[0036] Repeat steps 3-5 for the specified number of times, and then use the large language model to create summaries for all the text blocks at the top level at this time as the summary of the document tree , It is the parent node of all top-level text blocks.
[0037] Use the summary of this document tree As well as a description of the encoding standards in the current scenario, use the large language model to create the knowledge encoding of the document tree , and add the code to the dictionary tree middle.
[0038] The search process consists of the following steps: Calculate query text using embedding model Embedding vector of .
[0039] Using a large language model, according to and a description of the encoding specifications for the current scenario, generating the encoding of the knowledge required to answer the query .
[0040] Along the knowledge encoding Given the path, in the dictionary tree The search continues downward until a leaf node is found or the next bit of the knowledge code does not exist in the child nodes of the current node in the dictionary tree. This search link is the knowledge chain. By tracing back along the knowledge chain, we can get with the longest common prefix documents.
[0041] Use the reranking model to calculate the embedding vector of the query text and a summary of all document trees and select the one with the highest similarity A tree.
[0042] For each selected document tree, initialize the candidate text block set to .
[0043] Update the candidate text block set to the set of child nodes of all nodes in the current set.
[0044] calculate and the cosine similarity ranking of the embedding vectors of all candidate text blocks, and And the BM25 ranking of all candidate text blocks, and then use the RRF algorithm to calculate the comprehensive score.
[0045] Update the candidate text block set to the one with the highest score in the current set A block of text.
[0046] Repeat steps (4)-(5) until the node in the candidate text block set is a leaf node.
[0047] Merge the candidate text block sets obtained from all trees.
[0048] Calculate query text using reranking model The similarity between the merged candidate text blocks and all the text blocks in the set.
[0049] The most similar The text blocks are returned as search results.
[0050] In summary, the retrieval method of the domain knowledge chain based on coding standards in this embodiment is superior to the naive retrieval enhancement generation method in the prior art. The method of this embodiment and the naive retrieval enhancement generation method were tested on the UltraDomain-CS dataset. The test method is as follows: Extract all references in the UltraDomain-CS dataset.
[0051] For the simple search enhancement generation method, all references are split into several text blocks according to their length without destroying the sentences. During the search, the bce-embdding_v1 model is first used as the embedding model to find the top 100 text blocks with the highest cosine similarity. Then, the bce-rerank_v1 model is used as the reranking model to re-rank the top 100 text blocks with the highest cosine similarity. The top three text blocks with the highest similarity are used as the search results. For the method proposed in this embodiment, the Qwen2.5-72B-Instruct-AWQ model is used as the large language model, the bce-embdding_v1 model is used as the embedding model, the bce-rerank_v1 model is used as the reranking model, the number of tree layers is specified to be 2, the maximum number of categories is 20, and the parameters during retrieval are .
[0052] After obtaining the retrieval results using the two methods, the Qwen2.5-72B-Instruct-AWQ model is used as the large language model to answer questions based on the questions in the dataset and the retrieval results.
[0053] The Qwen2.5-72B-Instruct-AWQ model was used as the large language model to determine the quality of the answers obtained from the two search results. If the search results from the two methods were the same, the results were considered a tie.
[0054] The test results show that the method proposed in this embodiment has 57 wins, 40 losses and 3 draws over the simple retrieval enhancement generation method, which shows that the method proposed in this embodiment has obvious advantages.
[0055] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiment. All technical solutions based on the concept of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A method for retrieving domain knowledge chains based on coding standards, characterized by: The steps include: Step 1: Define the corresponding coding standards for different fields, and then build a dictionary tree , the dictionary tree Contains summary , the abstract It is the parent node of all top-level text blocks; Step 2: Dictionary tree built based on step 1 , by calculating the query text Embedding vector of , and then calculate the embedding vector of the query text and a summary of all document trees The knowledge chain is retrieved by measuring the similarity of the two.
2. The method for retrieving domain knowledge chains based on coding standards according to claim 1, characterized in that: The specific steps for performing knowledge chain retrieval in step 2 are as follows: Step 21: Calculate the query text Embedding vector of , and then generate an encoding of the knowledge needed to answer the query , Step 22: Encode based on knowledge The given path gets with the longest common prefix documents and calculate the embedding vector of the query text and a summary of all document trees and select the one with the highest similarity The tree gets the selected text block set as , Step 2 and 3: Calculate the embedding vector and the cosine similarity ranking of the embedding vectors of all candidate text blocks, and and the BM25 ranking of all candidate text blocks; Step 24: Use the RRF algorithm to calculate the comprehensive score and update the candidate text block set to the one with the highest score in the current set. a text block; Step 25: Collect the candidate text blocks and calculate the query text The similarity between the text blocks and the merged candidate text block set is the highest similarity. The text blocks are returned as search results.
3. The method for retrieving domain knowledge chains based on coding standards according to claim 1, characterized in that: In the step 1, a dictionary tree is constructed The specific steps are as follows: Step 1: Maintain a dictionary tree ; Steps 1 and 2: For each document to be built , without breaking the sentence, split it into several text blocks according to length , Indicates the The 0th level of the document tree a text block; Step 1 and 3: Use the embedding model to calculate the embedding vectors of all text blocks, where The first document The embedding vector of a text block is ; Step 14: Document No. Layer, using Gaussian mixture clustering algorithm to embed vector Perform clustering; Step 15: Group the text blocks according to the clustering results, and the text blocks in each group belong to the same category; Step 16, then, traverse each group and use the large language model to Group text blocks to create summaries, and the resulting summaries serve as the next level of text blocks , the text block is The parent node of all text blocks in the group; Step 17: Repeat steps 13 to 15 for the preset number of times, and then use the large language model to create summaries for all the top-level text blocks at this time as the summary of the document tree. , It is the parent node of all top-level text blocks; Step 18: Use the summary of the document tree As well as a description of the encoding standards in the current scenario, use the large language model to create the knowledge encoding of the document tree , and add the code to the dictionary tree middle.
4. The method for retrieving domain knowledge chains based on coding standards according to claim 2, characterized in that: In step 21, the query text is calculated Embedding vector of , and then generate an encoding of the knowledge needed to answer the query The specific method is: first use the embedding model to calculate the query text Embedding vector of , and then use the large language model, according to and a description of the encoding specifications for the current scenario, generating the encoding of the knowledge required to answer the query .
5. The method for retrieving domain knowledge chains based on coding standards according to any one of claims 2 to 4, characterized in that: In step 22, the embedding vector of the query text is calculated and a summary of all document trees and select the one with the highest similarity The tree gets the selected text block set as The specific method is: first, along the knowledge encoding Given the path, in the dictionary tree The search continues downward until a leaf node is found or the next bit of the knowledge code does not exist in the child nodes of the current node in the dictionary tree. This search link is the knowledge chain. By tracing back along the knowledge chain, we can get with the longest common prefix documents, and then use the reranking model to calculate the embedding vector of the query text and a summary of all document trees and select the one with the highest similarity For each selected document tree, the candidate text block set is initialized as .
6. The method for retrieving domain knowledge chains based on coding standards according to claim 5, characterized in that: In step 22, the set of initialized candidate text blocks is obtained as Finally, the candidate text block set is updated to be the set of child nodes of all nodes in the current set.
7. The method for retrieving domain knowledge chains based on coding standards according to claim 5, characterized in that: In step 24, the candidate text block set is updated to the one with the highest score in the current set. After the text blocks, we repeat the step 2 to calculate the embedding vector of the query text using the reranking model. and a summary of all document trees and select the one with the highest similarity For each selected document tree, the candidate text block set is initialized as Steps, until the node in the candidate text block set is a leaf node.
8. The method for retrieving domain knowledge chains based on coding standards according to any one of claims 2 to 4, characterized in that: The candidate text block set obtained in step 25 is used to calculate the query text The similarity between the text blocks and the merged candidate text block set is the highest similarity. The specific method of returning a text block as a search result is: merging the candidate text block sets obtained from all trees, and using the re-ranking model to calculate the query text The similarity between the text blocks and the merged candidate text block set is the highest similarity. The text blocks are returned as search results.
Citation Information
Patent Citations
Engineering project digital archive management method and system based on BIM
CN118820563A
Short text query expansion enhancement retrieval method based on knowledge base hierarchical tree structure
CN118861088A
Document knowledge question-answering method, document knowledge storage method and document knowledge question-answering device
CN119669429A
RAG knowledge base large model enhanced dialogue method and system for financial bank
CN119938823A