Knowledge enhancement recall method, device and system and storage medium
By dividing professional knowledge documents into structured data and building a tree-shaped index structure, the problem of poor RAG recall effect is solved, the answer accuracy of large language models in professional fields is improved, and the integrity of knowledge data and vector database is ensured. Function.
Patent Information
- Application Number
- CN202411216934.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-11-26
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The poor recall effect of knowledge-enhancing based on RAG results in insufficient answer accuracy of the general large language model in professional fields, especially when processing content with many entries and little relevance, the recall content is missing.
By dividing professional knowledge documents into structured data, building a tree-shaped index structure, and writing them into vectorized databases and ElasticSearch databases, user problems are vectorized and related data is extracted from the database using vector recall algorithm as prompt words Enter a large language model to improve answer accuracy.
The problem of incomplete knowledge of RAG recall has been optimized, the accuracy of answers has been improved, the integrity of knowledge data has been ensured, and the recall function of the vector database has been not affected.
Smart Images

Figure CN119025658A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of RAG recall technology, and in particular, relates to a knowledge enhanced recall method and device, system, and storage medium. Background Art
[0002] At present, since the birth of large language models in the field of natural language processing in artificial intelligence, they have demonstrated extremely powerful semantic understanding and logical capabilities, subverting many natural language processing tasks that traditional small models could not complete in the past and quickly refreshing the SOTA of various subtasks. Intelligent dialogue assistants based on general large language models cannot meet the usage needs of professional fields due to the lack of knowledge in a certain professional field. At present, the general large language model is enhanced with knowledge based on RAG, but for content such as industrial production materials and operating procedures that have many functional description items and little relevance, there are problems such as poor RAG recall effect and missing recall content. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a knowledge enhancement recall method and device, system, and storage medium to assist RAG in recalling all relevant content and improve the accuracy of the answers of the large model.
[0004] To achieve the above object, the present invention adopts the following technical solution:
[0005] A knowledge enhanced recall method, comprising:
[0006] Step S1, data preparation stage, including:
[0007] Step S11, dividing the professional knowledge documents into different knowledge bases, segmenting the professional knowledge documents, and obtaining a plurality of structured data;
[0008] Step S12: construct a tree index structure according to the content of the structured data to obtain tree structure data;
[0009] Step S13, writing the tree structure data into the vectorized database;
[0010] Step S14, writing the tree structure data into the ElasticSearch database;
[0011] Step S2, user questioning stage, includes:
[0012] Step S21, vectorizing the user question;
[0013] Step S22: extracting structured data corresponding to the topk closest vectors from the user selected knowledge base;
[0014] Step S23: extract the extracted structured data from the ElasticSearch database according to the tree index structure, and extract the content of the same branch and the next level;
[0015] Step S24: Through the sequential search of vector recall, the data recalled from the ElasticSearch database is integrated and input into the large language model as prompt words to complete the answer to the user's question.
[0016] Preferably, in step S12, regular matching is performed on the structured data to match the titles of each paragraph in the document, and a tree index structure is constructed.
[0017] Preferably, in step S22, structured data corresponding to the topk closest vectors are extracted from the user selected knowledge base through a vectorized similarity comparison algorithm.
[0018] The present invention also provides a knowledge enhancement recall device, comprising:
[0019] The first processing module is used to divide the professional knowledge documents into different knowledge bases, segment the professional knowledge documents, and obtain multiple structured data;
[0020] The second processing module is used to construct a tree index structure according to the content of the structured data to obtain tree structure data;
[0021] The third processing module is used to write the tree structure data into the vectorized database;
[0022] The fourth processing module is used to write the tree structure data into the ElasticSearch database;
[0023] The fifth processing module is used to vectorize the user questions;
[0024] The sixth processing module is used to extract structured data corresponding to the topk closest vectors from the user selected knowledge base;
[0025] The seventh processing module is used to extract the extracted structured data from the ElasticSearch database according to the tree index structure, and the content of the same branch and the next level;
[0026] The eighth processing module is used to merge the data recalled from the ElasticSearch database through vector recall, and input it into the large language model as prompt words to complete the answer to the user's question.
[0027] Preferably, the second processing module performs regular expression matching on the structured data, matches the titles of each paragraph in the document, and constructs a tree index structure.
[0028] Preferably, the sixth processing module extracts structured data corresponding to the closest topk vectors from the user selection knowledge base through a vectorized similarity comparison algorithm.
[0029] The present invention also provides a knowledge enhancement recall system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes the knowledge enhancement recall method when executed by the processor.
[0030] The present invention also provides a storage medium, on which a computer program is stored, and the computer program executes the knowledge enhancement recall method when running.
[0031] The beneficial effects of the present invention are:
[0032] 1. Optimized the problem of incomplete knowledge in traditional RAG recall and improved accuracy.
[0033] 2. Use structured data to split and ensure the integrity of knowledge data.
[0034] 3. Use ElasticSearch to complete the remaining data recall, which has little intrusion on the vector database and does not affect the vector recall function BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0036] Figure 1 A flowchart of a knowledge enhancement recall method according to an embodiment of the present invention;
[0037] Figure 2 A flowchart for the data preparation phase;
[0038] Figure 3 Flowchart of the user questioning phase. DETAILED DESCRIPTION
[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] Embodiment 1:
[0042] like Figure 1 , 2 As shown in , 3, an embodiment of the present invention provides a knowledge enhancement recall method including:
[0043] Step S1, data preparation stage:
[0044] Step S11, dividing the professional knowledge documents into different knowledge bases, adopting different segmentation methods for the professional knowledge documents according to different professional knowledge document formats, and constructing multiple structured data;
[0045] Step S12: construct a tree index structure according to the content of the structured data, classify the content, and obtain tree structure data;
[0046] Step S13: vectorize the tree structure data through the SOTA-level Embedding model and store it in the local vectorization database;
[0047] Step S14, inputting the tree structure data into the ElasticSearch database; wherein, constructing an index associated with the vector database in ElasticSearch, and writing the data into the corresponding index;
[0048] Step S2: User questioning stage:
[0049] Step S21, vectorizing the user question by processing the Embedding model of the knowledge base data;
[0050] Step S22: extracting structured data corresponding to the topk closest vectors from the user selected knowledge base through a vectorized similarity comparison algorithm;
[0051] Step S23: extract the extracted structured data from the ElasticSearch database according to the tree index structure, and extract the content of the same branch and the next level;
[0052] Step S24: Through the sequential search of vector recall, the data recalled from the ElasticSearch database is integrated and input into the large language model as prompt words to complete the answer to the user's question.
[0053] As an implementation method of an embodiment of the present invention, in step S12, regular matching is performed on the structured data to match the titles of each paragraph in the document, and a tree index structure is constructed. A single link of the tree index structure is as follows: first-level title-second-level title-third-level title-content.
[0054] As an implementation method of an embodiment of the present invention, in step S22, a similarity comparison is performed with the segmented professional knowledge document content data in the knowledge base, and vector cosine similarity is calculated to calculate the data with high similarity in the vector knowledge base, and the topk knowledge base data are returned.
[0055] As an implementation of the embodiment of the present invention, in step S23, based on the returned knowledge base data, the index in ElasticSearch related to the vector library is queried, and based on the tree index structure, the related data of the same level and the next level are returned.
[0056] As an implementation method of an embodiment of the present invention, in step S24, the data recalled from the vector knowledge base and the data recalled from ElasticSearch are deduplicated according to the tree structure index, and the returned results are reordered according to their positions in the original document, so that the returned data is ordered and input into the large language model as a prompt project to complete the answer.
[0057] The embodiment of the present invention adopts enhanced recall based on tree index, utilizes structured data segmentation, constructs tree index, and realizes efficient RAG knowledge retrieval enhancement through the combination of vector database and Elasticsearch database.
[0058] Embodiment 2:
[0059] The embodiment of the present invention further provides a knowledge enhancement recall device, comprising:
[0060] The first processing module is used to divide the professional knowledge documents into different knowledge bases, segment the professional knowledge documents, and obtain multiple structured data;
[0061] The second processing module is used to construct a tree index structure according to the content of the structured data to obtain tree structure data;
[0062] The third processing module is used to write the tree structure data into the vectorized database;
[0063] The fourth processing module is used to write the tree structure data into the ElasticSearch database;
[0064] The fifth processing module is used to vectorize the user questions;
[0065] The sixth processing module is used to extract structured data corresponding to the topk closest vectors from the user selected knowledge base;
[0066] The seventh processing module is used to extract the extracted structured data from the ElasticSearch database according to the tree index structure, and the content of the same branch and the next level;
[0067] The eighth processing module is used to merge the data recalled from the ElasticSearch database through vector recall, and input it into the large language model as prompt words to complete the answer to the user's question.
[0068] As an implementation method of the embodiment of the present invention, the second processing module performs regular matching on the structured data, matches the titles of each paragraph in the document, and constructs a tree index structure.
[0069] As an implementation method of the embodiment of the present invention, the sixth processing module extracts structured data corresponding to the most similar topk vectors from the user selection knowledge base through a vectorized similarity comparison algorithm.
[0070] Embodiment 3:
[0071] An embodiment of the present invention further provides a knowledge enhancement recall system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a knowledge enhancement recall method when executed by the processor.
[0072] Embodiment 4:
[0073] An embodiment of the present invention further provides a storage medium, on which a computer program is stored, and the computer program executes the knowledge enhancement recall method when running.
[0074] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A knowledge enhanced recall method, characterized in that: include: Step S1, data preparation stage, including: Step S11, dividing the professional knowledge documents into different knowledge bases, segmenting the professional knowledge documents, and obtaining a plurality of structured data; Step S12: construct a tree index structure according to the content of the structured data to obtain tree structure data; Step S13, writing the tree structure data into the vectorized database; Step S14, writing the tree structure data into the ElasticSearch database; Step S2, user questioning stage, includes: Step S21, vectorizing the user question; Step S22: extracting structured data corresponding to the topk closest vectors from the user selected knowledge base; Step S23: extract the extracted structured data from the ElasticSearch database according to the tree index structure, and extract the content of the same branch and the next level; Step S24: Through the sequential search of vector recall, the data recalled from the ElasticSearch database is integrated and input into the large language model as prompt words to complete the answer to the user's question.
2. The knowledge enhancement recall method according to claim 1, characterized in that: In step S12, regular expression matching is performed on the structured data to match the titles of each paragraph in the document, and a tree index structure is constructed.
3. The knowledge enhancement recall method according to claim 3, characterized in that: In step S22, the structured data corresponding to the topk closest vectors are extracted from the user selection knowledge base through a vectorized similarity comparison algorithm.
4. A knowledge enhancement recall device, characterized in that: include: The first processing module is used to divide the professional knowledge documents into different knowledge bases, segment the professional knowledge documents, and obtain multiple structured data; The second processing module is used to construct a tree index structure according to the content of the structured data to obtain tree structure data; The third processing module is used to write the tree structure data into the vectorized database; The fourth processing module is used to write the tree structure data into the ElasticSearch database; The fifth processing module is used to vectorize the user questions; The sixth processing module is used to extract structured data corresponding to the topk closest vectors from the user selected knowledge base; The seventh processing module is used to extract the extracted structured data from the ElasticSearch database according to the tree index structure, and the content of the same branch and the next level; The eighth processing module is used to merge the data recalled from the ElasticSearch database through vector recall, and input it into the large language model as prompt words to complete the answer to the user's question.
5. The knowledge enhancement recall device according to claim 4, characterized in that: The second processing module performs regular matching on the structured data, matches the titles of each paragraph in the document, and constructs a tree index structure.
6. The knowledge enhancement recall device according to claim 5, characterized in that: The sixth processing module extracts the structured data corresponding to the topk closest vectors from the user selection knowledge base through a vectorized similarity comparison algorithm.
7. A knowledge-enhanced recall system, characterized in that: include: A memory and a processor, wherein the memory stores a computer program executed by the processor, and when the computer program is executed by the processor, the knowledge enhancement recall method as described in any one of claims 1 to 3 is executed.
8. A storage medium, characterized in that: The storage medium stores a computer program, which, when run, executes the knowledge enhancement recall method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Medical auxiliary question and answer method and system based on knowledge calibration and retrieval enhancement
CN117573843A
Online intelligent question answering method and device based on instruction fine tuning and retrieval enhancement generation
CN117688163A
LLM-based intelligent questioning and answering method, system and equipment in power field and medium
CN118277521A
Multi-modal multi-scale multi-recall large language model retrieval enhancement generation method
CN118296120A
De-duplication method for text recall multi-source knowledge in RAG
CN118446201A
Cited By
Document question and answer method and system and storage medium
CN119396983A
Document question and answer method, system and storage medium
CN119396983B
