Method, system and equipment for retrieval enhancement generation based on large language model and medium
By performing chapter sharding and large language model processing on the text, multi-angle word vector data is generated, which solves the problem of low recall in search enhancement generation technology, improves the accuracy and logical coherence of semantic retrieval, and improves users Comprehensiveness of the questions and quality of answers.
Patent Information
- Application Number
- CN202411070464.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-15
AI Technical Summary
The recall rate in search enhancement generation technology is not high, the search results do not match the user's intention, and the logical coherence and semantic matching are insufficient.
By sharding the text in chapters, generating parent text blocks and child text blocks, and using large language models to summarize text and ask hypothetical questions, we can improve the logical coherence and semantic retrieval accuracy of text blocks, and build multi-angle word vector data supply Query.
It improves the logic and recall rate of query results, improves the accuracy and comprehensiveness of semantic retrieval, and enhances the understanding of user questions and the generation of answers.
Smart Images

Figure CN118964387A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, system, device and medium for retrieval enhancement generation based on a large language model. Background Art
[0002] Retrieval-Augmented Generation (RAG) is a technology that combines retrieval model and generation model, and is used by large language models to retrieve relevant information related to user queries from external knowledge sources. Figure 1 As shown. First, the knowledge text is segmented, and the segmented text is converted into word vectors through the embedded model (EmbeddingModel) and stored in the word vector library. When the user asks a question, the user's question text is first converted into a word vector, and then the embedded model is used to query the word vector database, returning the text block that is most similar to the user's question semantics. The text block is then input into the large language model (LLM), and the large language model generates an answer or output based on the retrieved context information. The retrieval enhancement generation technology uses the semantic relevance matching method to retrieve documents. In actual use, there are often problems where the retrieval results do not match the user's intentions and the recall rate is not high. Summary of the invention
[0003] Mainly aimed at the problem of low recall rate of retrieval enhancement generation technology, the present invention provides a method, system, device and medium for retrieval enhancement generation based on a large language model, which improves the contextual logical coherence of the query return text block by improving the text segmentation method. When building a document vector library, the data to be retrieved is generated from different angles of the document content to improve the accuracy of the query return results. The user's original question is generated into multiple related questions through a large language model to improve the comprehensiveness of the query.
[0004] The present invention discloses a method for retrieval enhancement generation based on a large language model, which comprises:
[0005] The text file is divided into pieces to obtain multiple parent text blocks, and a unique identifier is generated for each parent text block. All parent text blocks and their corresponding unique identifiers are stored in a relational database for database query;
[0006] Each parent text block is further fragmented into multiple child text blocks, each of which contains the unique identifier of its corresponding parent text block for backtracking query;
[0007] Performing a text summary on each parent text block to obtain multiple parent text block summary texts, each summary text containing a unique identifier of the parent text block for backtracking query;
[0008] Generate one or more hypothetical questions for each parent text block, where the text of each hypothetical question contains a unique identifier of the parent text block for backtracking query;
[0009] Vectorize the child text block, the summary text of the parent text block, and the hypothetical question of the parent text block, and store them in the vector database;
[0010] Based on the query question text input by the user, a query is performed in the vector database to obtain multiple child text blocks, parent text block summary texts and parent text block hypothetical questions with high semantic matching, and a unique identifier is extracted from them, and a number of parent text blocks are obtained from the relational database based on the unique identifier;
[0011] Several parent text blocks and the questions raised by the user are combined into prompt words and submitted to the large language model to generate the final answer.
[0012] Furthermore, the text file is segmented to obtain multiple parent text blocks, including:
[0013] The text file is segmented into chapters, and multiple parent text blocks are obtained after segmentation.
[0014] Furthermore, the text summary of each parent text block is performed to obtain a plurality of parent text block summary texts, including:
[0015] A large language model is used to summarize the text of each parent text block to obtain summary texts of multiple parent text blocks.
[0016] Furthermore, the step of generating one or more hypothetical questions for each parent text block includes:
[0017] For each parent text block, a large language model is used to generate one or more hypothetical questions.
[0018] Furthermore, the query question text input by the user is queried in the vector database to obtain multiple child text blocks, parent text block summary texts and parent text block hypothetical questions with high semantic matching, and a unique identifier is extracted from them. Based on the unique identifier, several parent text blocks are obtained from the relational database, including:
[0019] The user enters the query text in the interface, and the large language model is used to ask multiple questions from different angles based on the original question;
[0020] Using the embedded model, multiple questions are semantically queried in the vector database in sequence, and the query results are returned to obtain multiple sub-text blocks with high semantic matching, parent text summaries, and hypothetical questions about the parent text blocks;
[0021] The unique identifier of the corresponding parent text block is extracted from the multiple sub-text blocks with high semantic matching, the parent text summary and the hypothetical question of the parent text block.
[0022] Furthermore, the plurality of parent text blocks and the question raised by the user are combined into prompt words, submitted to the large language model, and the final answer is generated, including:
[0023] The unique identifier of the extracted parent text block is used as a query condition to perform a conditional query in a relational database storing the parent text block; based on the conditional query, multiple parent text blocks are returned;
[0024] Multiple parent text blocks and questions raised by users are combined into prompt words and submitted to the large language model. The large language model generates the final answer based on the prompt words.
[0025] The present invention also discloses a system for retrieval enhancement generation based on a large language model, which is used to implement any of the above-mentioned methods for retrieval enhancement generation based on a large language model, and comprises:
[0026] The first sharding module is used to shard the text file to obtain multiple parent text blocks, generate a unique identifier for each parent text block, and store all parent text blocks and their corresponding unique identifiers in a relational database for database query;
[0027] A second sharding module is used to shard each parent text block again to obtain multiple child text blocks, each child text block contains a unique identifier of its corresponding parent text block for backtracking query;
[0028] A summary module is used to summarize each parent text block to obtain a plurality of parent text block summary texts, each summary text contains a unique identifier of the parent text block for backtracking query;
[0029] A generation module, used for generating one or more hypothetical questions for each parent text block, wherein the text of each hypothetical question contains a unique identifier of the parent text block for backtracking query;
[0030] A vectorization module is used to vectorize the child text block, the summary text of the parent text block, and the hypothetical question of the parent text block, and store them in a vector database;
[0031] A query module is used to query the vector database based on the query question text input by the user, obtain multiple child text blocks, parent text block summary texts and parent text block hypothetical questions with high semantic matching, extract unique identifiers from them, and obtain several parent text blocks from the relational database based on the unique identifiers;
[0032] The answer generation module is used to combine several parent text blocks and the questions raised by the user into prompt words, submit them to the large language model, and generate the final answer.
[0033] The present invention also discloses a computer device, comprising: a processor and a memory for storing executable instructions of the processor; wherein the processor is used to execute the executable instructions to implement any of the above-mentioned methods for retrieval enhancement generation based on a large language model.
[0034] The present invention also discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned methods for retrieval enhancement generation based on a large language model is implemented.
[0035] Due to the adoption of the above technical solution, the present invention has the following advantages:
[0036] 1. The present invention improves the technology of segmenting text according to fixed length in the retrieval enhancement generation technology, and improves the logic of querying and recalling text by segmenting the original text according to chapters.
[0037] 2. When constructing a word vector library, the present invention generates word vector data for retrieval from multiple angles, such as text segmentation of the original text, generation of text block summaries by a large language model, and generation of hypothetical questions based on text blocks by a large language model, thereby improving the accuracy of semantic retrieval and the query recall rate.
[0038] 3. The present invention uses a large language model to generate multiple questions from different angles for the user's original query questions, thereby improving the comprehensiveness of the user's questions and thus improving the accuracy and recall rate of semantic retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0040] Figure 1 A schematic diagram of the working principle of the retrieval enhancement generation technology in the prior art;
[0041] Figure 2 The present invention is a flowchart of a method for retrieval enhancement generation based on a large language model according to an embodiment of the present invention. DETAILED DESCRIPTION
[0042] The present invention is further described in conjunction with the accompanying drawings and embodiments, and the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field should fall within the scope of protection of the embodiments of the present invention.
[0043] See also Figure 2 The present invention provides an embodiment of a method for retrieval enhancement generation based on a large language model, which comprises the following steps:
[0044] 1. The text file to be stored in the knowledge base is fragmented according to chapters. After fragmentation, multiple parent text blocks are obtained, and a UUID is generated for each parent text block (UUID is used as the unique identifier of each parent text block for database query).
[0045] 2. Store multiple UUIDs and parent text blocks in a relational database.
[0046] 3. Each parent text block is further fragmented to obtain multiple child text blocks. Each child text block contains the UUID of the parent text block for backtracking query.
[0047] 4. Use the large language model to summarize the text of each parent text block to obtain multiple parent text block summary texts. Each summary text contains the UUID of the parent text block for backtracking query.
[0048] 5. Use the large language model to generate one or more hypothetical questions for each parent text block. The text of each question contains the UUID of the parent text block for backtracking query.
[0049] 6. The sub-text blocks, parent text block summary text, and parent text block hypothetical questions generated in steps 3, 4, and 5 are vectorized and stored in a vector database.
[0050] 7. The user enters the query text in the interface, and uses the large language model to ask multiple questions from different angles based on the original question (to improve the comprehensiveness of the question semantics).
[0051] 8. Use the embedded model to perform semantic queries on multiple questions in the vector database in sequence.
[0052] 9. Return the query results, and obtain multiple sub-text blocks with high semantic matching, parent text summaries, and parent text hypothetical questions.
[0053] 10. Extract the UUID of the parent text block corresponding to the result returned in step 9.
[0054] 11. Use the UUID in step 10 as the query condition and perform a conditional query in the database storing the parent text block.
[0055] 12. Based on the conditional query, return multiple parent text blocks.
[0056] 13. Combine multiple parent text blocks and the questions raised by the user into prompt words and submit them to the large language model.
[0057] 14. The large language model generates the final answer based on the prompt words.
[0058] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for retrieval enhancement generation based on a large language model, characterized in that: include: The text file is divided into pieces to obtain multiple parent text blocks, and a unique identifier is generated for each parent text block. All parent text blocks and their corresponding unique identifiers are stored in a relational database for database query; Each parent text block is further fragmented into multiple child text blocks, each of which contains the unique identifier of its corresponding parent text block for backtracking query; Performing a text summary on each parent text block to obtain multiple parent text block summary texts, each summary text containing a unique identifier of the parent text block for backtracking query; One or more hypothetical questions are generated for each parent text block, and the text of each hypothetical question contains a unique identifier of the parent text block for backtracking query; Vectorize the child text block, the summary text of the parent text block, and the hypothetical question of the parent text block, and store them in the vector database; Based on the query question text input by the user, a query is performed in the vector database to obtain multiple child text blocks, parent text block summary texts and parent text block hypothetical questions with high semantic matching, and a unique identifier is extracted from them, and a number of parent text blocks are obtained from the relational database based on the unique identifier; Several parent text blocks and the questions raised by the user are combined into prompt words and submitted to the large language model to generate the final answer.
2. The method for retrieval enhancement generation based on a large language model according to claim 1, characterized in that: The text file is segmented to obtain multiple parent text blocks, including: The text file is segmented into chapters, and multiple parent text blocks are obtained after segmentation.
3. The method for retrieval enhancement generation based on a large language model according to claim 1, characterized in that: The text summary of each parent text block is performed to obtain a plurality of parent text block summary texts, including: A large language model is used to summarize the text of each parent text block to obtain summary texts of multiple parent text blocks.
4. The method for retrieval enhancement generation based on a large language model according to claim 1, characterized in that: The step of generating one or more hypothetical questions for each parent text block includes: For each parent text block, a large language model is used to generate one or more hypothetical questions.
5. The method for retrieval enhancement generation based on a large language model according to claim 1, characterized in that: The query question text input by the user is queried in the vector database to obtain multiple child text blocks, parent text block summary texts and parent text block hypothetical questions with high semantic matching, and a unique identifier is extracted from them. Based on the unique identifier, several parent text blocks are obtained from the relational database, including: The user enters the query text in the interface, and the large language model is used to ask multiple questions from different angles based on the original question; Using the embedded model, multiple questions are semantically queried in the vector database in sequence, and the query results are returned to obtain multiple sub-text blocks with high semantic matching, parent text summaries, and hypothetical questions about the parent text blocks; The unique identifier of the corresponding parent text block is extracted from the multiple sub-text blocks with high semantic matching, the parent text summary and the hypothetical question of the parent text block.
6. The method for retrieval enhancement generation based on a large language model according to claim 1, characterized in that: The method combines several parent text blocks with the question raised by the user to form prompt words, submits them to the large language model, and generates the final answer, including: The unique identifier of the extracted parent text block is used as a query condition to perform a conditional query in a relational database storing the parent text block; based on the conditional query, multiple parent text blocks are returned; Multiple parent text blocks and questions raised by users are combined into prompt words and submitted to the large language model. The large language model generates the final answer based on the prompt words.
7. A system for retrieval enhancement generation based on a large language model, used to implement the method for retrieval enhancement generation based on a large language model according to any one of claims 1 to 6, characterized in that: include: The first sharding module is used to shard the text file to obtain multiple parent text blocks, generate a unique identifier for each parent text block, and store all parent text blocks and their corresponding unique identifiers in a relational database for database query; A second sharding module is used to shard each parent text block again to obtain multiple child text blocks, each child text block contains a unique identifier of its corresponding parent text block for backtracking query; A summary module is used to summarize each parent text block to obtain a plurality of parent text block summary texts, each summary text contains a unique identifier of the parent text block for backtracking query; A generation module, used for generating one or more hypothetical questions for each parent text block, wherein the text of each hypothetical question contains a unique identifier of the parent text block for backtracking query; A vectorization module is used to vectorize the child text block, the summary text of the parent text block, and the hypothetical question of the parent text block, and store them in a vector database; A query module is used to query the vector database based on the query question text input by the user, obtain multiple child text blocks, parent text block summary texts and parent text block hypothetical questions with high semantic matching, extract unique identifiers from them, and obtain several parent text blocks from the relational database based on the unique identifiers; The answer generation module is used to combine several parent text blocks and the questions raised by the user into prompt words, submit them to the large language model, and generate the final answer.
8. A computer device, characterized in that: include: A processor and a memory for storing executable instructions of the processor; wherein the processor is used to execute the executable instructions to implement the method for retrieval enhancement generation based on a large language model according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for retrieval enhancement generation based on a large language model according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
LLM-based intelligent questioning and answering method, system and equipment in power field and medium
CN118277521A
Cited By
Document retrieval method and device and storage medium
CN119357318A
Document retrieval method, device and storage medium
CN119357318B
Text generation method and device, electronic equipment and computer readable storage medium
CN119647406A
Text generation method, device, electronic device and computer-readable storage medium
CN119647406B
Document dialogue method, system and equipment based on large language model and medium
CN120011521A
