Retrieval enhancement generation system and method based on query reconstruction and routing
By introducing query reconstruction and the combination of routing modules and multiple RAG technologies in the RAG system, the problems of retrieval accuracy and response speed of existing RAG technologies are solved, and more efficient document retrieval and user experience are achieved.
Patent Information
- Application Number
- CN202411858327.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-11
AI Technical Summary
Existing RAG technologies have problems with retrieval accuracy and response speed when dealing with large documents, especially when dealing with complex queries and issues requiring extensive text understanding.
By introducing query reconstruction and routing modules, user query problems are analyzed and reconstructed, and appropriate RAG submodules are selected according to the query type for searching. Combined with the use of a variety of RAG technologies such as traditional RAG, Raptor and Graph RAG, they give full play to their respective advantages.
It effectively improves the accuracy of retrieving content related to user query from a large document, improves the system response speed and user experience, especially when processing complex queries, can quickly generate answers.
Smart Images

Figure CN119807361A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a retrieval enhancement generation system and method based on query reconstruction and routing. Background Art
[0002] Retrieval-augmented generation (RAG) is a technology that combines information retrieval with language generation. RAG improves the ability of large language models (LLMs) to handle knowledge-intensive tasks by calling information from external knowledge bases, and has been widely used in systems such as question answering, text summarization, and content generation. In system applications, when LLMs need to answer questions or generate text, RAG first retrieves the text content that is most relevant to the customer's question or need from a large document set, and then inputs the retrieved information as prompts to LLMs to guide LLMs to generate the final text.
[0003] The advantage of RAG is that it ensures that the answers are generated based on the latest information by accessing and utilizing the latest information in external knowledge bases in real time; in addition, the RAG model can also reference its external sources to support its responses, increasing the interpretability and credibility of the generated answers.
[0004] Existing RAG technologies include traditional RAG, Raptor, a recursive abstract processing method based on a tree-like retrieval mechanism, and Graph RAG, a retrieval enhancement generation method based on a knowledge graph. Existing RAG technologies have their own advantages and disadvantages: traditional RAG has advantages in processing large amounts of text data, but suffers from flat retrieval, contextual defects, and scalability issues. Raptor improves the ability to handle complex problems by building a recursive document tree, making it easier to answer complex problems involving multiple documents and details, but with high computational complexity and resource consumption. Graph RAG uses knowledge graphs for information retrieval and representation, and can retrieve relevant information more accurately and comprehensively, but is not good at handling problems that require extensive text understanding. Therefore, how to leverage the advantages of multiple RAG technologies to improve the accuracy of retrieving text content related to user query questions in large documents and improve system response speed and user experience is a problem that needs to be solved in the application of RAG-based LLMs. Summary of the invention
[0005] The purpose of the present invention is to provide a retrieval enhancement generation method based on query reconstruction and routing to solve the problems raised in the prior art.
[0006] To achieve the above object, the present invention provides the following technical solution, a retrieval enhancement generation method based on query reconstruction and routing, the method comprising:
[0007] Step S1: the query module receives the query question input by the user and sends the query question to the query reconstruction and routing module;
[0008] Step S2: The query reconstruction and routing module receives the query question input from the user, analyzes and reconstructs the query question, and sends the query instruction to the RAG module through the query routing;
[0009] Step S3: The RAG module receives the query instruction sent by the query reconstruction and routing module, and calls the corresponding RAG submodule according to the query instruction;
[0010] Step S4: the prompt word module receives the search results from the RAG module, and the prompt word module re-ranks the search results using a re-ranking technique, placing the documents most relevant to the query question at the top;
[0011] Commonly used reranking techniques include statistical reranking techniques, deep learning model-based reranking techniques, multi-stage reranking techniques, multi-feature fusion reranking techniques, and reranking techniques that introduce external knowledge sources;
[0012] Step S5: the large language model module receives the query question from the query module and the document output by the prompt word module, and generates an answer to the query question;
[0013] The query reconstruction and routing module in the above steps is the core of the present invention, which is implemented based on large language models LLMs. Compared with the LLMs in the large language model module used later in the system, the LLMs used for the query reconstruction and routing module are relatively smaller in scale. The use of smaller-scale LLMs can improve the reasoning speed when analyzing and reconstructing user query questions, because the purpose of the query reconstruction and routing module is to analyze the grammatical structure, semantics, and user intent of user query questions, and then determine the type of user query questions and perform necessary reconstruction, rather than answering user query questions.
[0014] Furthermore, in step S2, the query question is analyzed, the analysis content includes the semantic content of the query question, the user intention and the required reasoning steps, and the query type of the query question is determined according to the analysis content, wherein the query type includes simple query and complex query;
[0015] The judgment basis for simple queries is that the semantic content of the query question is direct and clear, the user's intention is clear and the required information is single, and the large model can quickly retrieve or generate answers from the knowledge base according to the reasoning steps;
[0016] The basis for judging complex queries is that the semantic content of the query question contains multiple knowledge points or requires cross-domain reasoning, the user's intention is unclear and requires further inquiry or clarification, and according to the reasoning steps, the large model needs to comprehensively use multiple knowledge bases or reasoning rules to generate answers;
[0017] The simple queries mentioned above refer to user queries that usually involve direct and clear information extraction or basic logical reasoning, with clear user intentions and a single piece of information to be queried. Complex queries involve multiple knowledge points or require certain logical reasoning and contextual understanding, and user intentions may be more vague or need to be refined.
[0018] Further, the query type of the query question is determined according to the analysis content. If the query type is a simple query, the simple query is reconstructed and analyzed according to the grammatical structure. If the simple query does not need to be reconstructed, the query reconstruction and routing module directly sends the simple query to the RAG module through routing.
[0019] Let's take an example to illustrate whether the above-mentioned simple query needs to be reconstructed. For example, if the user's query is "How many people are there in Fuzhou?", then this query does not need to be reconstructed. For example, if the user's query is "Which city has a larger population, Fuzhou or Quanzhou?", then this query can be reconstructed into "What is the population of Fuzhou?" "What is the population of Quanzhou?" "Compare which city has a larger population based on the query results."
[0020] Further, the query type of the query question is determined according to the analysis content, and if the query type is a complex query, whether the complex query is a general query is determined according to the analysis content;
[0021] The judgment basis for general queries is that the semantic content of the query question requires comprehensive, inductive or summarized information. The user's intention is to obtain a concise and clear answer rather than a detailed explanation or reasoning process. According to the reasoning steps, the large model needs to screen, integrate and summarize the knowledge points or information.
[0022] Let's take an example of the above general query. For example, the user's query question is "What are the applications of deep learning in the field of artificial intelligence? Please give examples." The user's intention is obvious. The key content of the query is what are the applications of deep learning in the field of artificial intelligence, so there is no need to reconstruct it.
[0023] If the complex query is a general query, reconstruction is not required, and the query reconstruction and routing module sends the general query to the RAG module through query routing;
[0024] If the complex query is a non-generalized query, the query reconstruction and routing module sends the non-generalized query to the RAG module through query routing;
[0025] The non-generalized queries mentioned above include multi-hop relationship queries, knowledge reasoning queries, hidden relationship queries, etc., such as queries such as "a friend of a friend", "starting from Beijing, wanting to visit the Confucius Temple and Sun Yat-sen Mausoleum in Nanjing, and staying in Shanghai for one night, and finally returning to Beijing, how should I plan the itinerary?".
[0026] If the content of the complex query includes two or more query types, the query reconstruction and query routing module reconstructs the complex query, divides the complex query into multiple query types, and sends the multiple query types to the RAG module;
[0027] An example is given for the complex query above, which contains two or more query types. For example, "What is the principle of deep learning and what are its applications in the field of artificial intelligence?" The first half is a simple query and the second half is a general query. For this type of query, the query reconstruction and routing module divides it into two queries. The simple query in the first half, "What is the principle of deep learning?", is directly routed to the RAG module. The RAG module calls the traditional RAG submodule to search it. The general query in the second half, "What are the applications of deep learning in the field of artificial intelligence?", is also routed to the RAG module. The RAG module calls the Raptor algorithm submodule to search it. The advantage of this is that the traditional RAG submodule consumes less resources and searches faster, and can get answers quickly, while the Raptor algorithm submodule consumes more resources and searches slower. LLMs can first generate answers from the search results of "What are the principles of deep learning?" and display them to users. In the process, it waits for the search results of "What are the applications of deep learning in the field of artificial intelligence?" and then generates answers and displays them to customers, thereby reducing user waiting time and improving user experience.
[0028] Further, in step S3, the RAG module calls the corresponding RAG submodule according to the query type sent by the query reconstruction and routing module;
[0029] If the query type is a simple query, the RAG module calls the traditional RAG algorithm submodule to retrieve the query question;
[0030] If the query type is a general query, the RAG module calls the Raptor algorithm submodule to retrieve the query question;
[0031] If the query type is a non-generalized query, the RAG module calls the Graph RAG algorithm submodule to retrieve the query question;
[0032] The RAG module includes but is not limited to the traditional RAG algorithm submodule, the Raptor algorithm submodule and the Graph RAG algorithm submodule, and two or more RAG submodules can be called simultaneously to search for the query question and output the search results to the prompt word module.
[0033] In order to better implement the above method, a retrieval enhancement generation system based on query reconstruction and routing is also proposed. The system includes a query module, a query reconstruction and routing module, a RAG module, a prompt word module, a large language module and an answer module;
[0034] The query module is responsible for receiving the query questions input by the user;
[0035] The query reconstruction and routing module is responsible for analyzing the query content of the query question and reconstructing the query question, and then sending the reconstructed query question to the RAG module;
[0036] The RAG module is responsible for calling the corresponding RAG submodule to search the query question and find the document with the highest relevance to the query question;
[0037] The prompt word module is responsible for receiving the documents input from the RAG module and sorting the documents according to their relevance to the query question;
[0038] The large language module receives the query questions input by the user and the documents output by the prompt word module, and generates the answers corresponding to the query questions input by the user;
[0039] The answer module outputs the answer corresponding to the query question entered by the user.
[0040] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention analyzes and reconstructs user queries through query reconstruction and routing modules, and routes query results to different RAG sub-modules according to a certain strategy. By combining the use of multiple RAG technologies and giving full play to their respective advantages, the accuracy of retrieving content related to user queries from a large document collection is effectively improved; different RAG technologies differ in computational complexity and resource consumption. By reconstructing user queries, some complex queries are reduced to simple queries, thereby selecting RAG technologies with low computational complexity and low resource consumption, thereby improving the speed of system response; in particular, when the user has sufficient computing power resources and has extremely high requirements for retrieval accuracy, the system can simultaneously use multiple RAG technologies to retrieve documents, and then fuse the retrieval results and provide them to LLMs to guide LLMs to generate answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1This is a module composition diagram of a retrieval enhancement generation system and method based on query reconstruction and routing of the present invention. DETAILED DESCRIPTION
[0042] Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making any creative work shall fall within the scope of protection of the present invention.
[0043] Example: Figure 1 As shown, the present invention provides a technical solution, a retrieval enhancement generation method based on query reconstruction and routing, the method comprising:
[0044] Step S1: the query module receives the query question input by the user and sends the query question to the query reconstruction and routing module;
[0045] Step S2: The query reconstruction and routing module receives the query question input from the user, analyzes and reconstructs the query question, and sends the query instruction to the RAG module through the query routing;
[0046] In step S2, the query question is analyzed, and the analysis content includes the semantic content of the query question, the user's intention, and the required reasoning steps. The query type of the query question is determined according to the analysis content, wherein the query type includes a simple query and a complex query;
[0047] The judgment basis for simple queries is that the semantic content of the query question is direct and clear, the user's intention is clear and the required information is single, and the large model can quickly retrieve or generate answers from the knowledge base according to the reasoning steps;
[0048] The basis for judging complex queries is that the semantic content of the query question contains multiple knowledge points or requires cross-domain reasoning, the user's intention is unclear and requires further inquiry or clarification, and according to the reasoning steps, the large model needs to comprehensively use multiple knowledge bases or reasoning rules to generate answers;
[0049] The query type of the query question is determined according to the analysis content. If the query type is a simple query, the simple query is reconstructed and analyzed according to the grammatical structure. If the simple query does not need to be reconstructed, the query reconstruction and routing module directly sends the simple query to the RAG module through routing.
[0050] wherein, judging the query type of the query question according to the analysis content, and if the query type is a complex query, judging whether the complex query is a general query according to the analysis content;
[0051] The judgment basis for general queries is that the semantic content of the query question requires comprehensive, inductive or summarized information. The user's intention is to obtain a concise and clear answer rather than a detailed explanation or reasoning process. According to the reasoning steps, the large model needs to screen, integrate and summarize the knowledge points or information.
[0052] If the complex query is a general query, reconstruction is not required, and the query reconstruction and routing module sends the general query to the RAG module through query routing;
[0053] If the complex query is a non-generalized query, the query reconstruction and routing module sends the non-generalized query to the RAG module through query routing;
[0054] If the content of the complex query includes two or more query types, the query reconstruction and query routing module reconstructs the complex query, divides the complex query into multiple query types, and sends the multiple query types to the RAG module;
[0055] Step S3: The RAG module receives the query instruction sent by the query reconstruction and routing module, and calls the corresponding RAG submodule according to the query instruction;
[0056] Wherein, in step S3, the RAG module calls the corresponding RAG submodule according to the query type sent by the query reconstruction and routing module;
[0057] If the query type is a simple query, the RAG module calls the traditional RAG algorithm submodule to retrieve the query question;
[0058] If the query type is a general query, the RAG module calls the Raptor algorithm submodule to retrieve the query question;
[0059] If the query type is a non-generalized query, the RAG module calls the Graph RAG algorithm submodule to retrieve the query question;
[0060] The RAG module includes but is not limited to the traditional RAG algorithm submodule, the Raptor algorithm submodule and the GraphRAG algorithm submodule, and two or more RAG submodules can be called simultaneously to search the query question and output the search results to the prompt word module;
[0061] Step S4: the prompt word module receives the search results from the RAG module, and the prompt word module re-ranks the search results using a re-ranking technique, placing the documents most relevant to the query question at the top;
[0062] Step S5: the large language model module receives the query question from the query module and the document output by the prompt word module, and generates an answer to the query question;
[0063] In order to better implement the above method, a retrieval enhancement generation system based on query reconstruction and routing is also proposed. The system includes a query module, a query reconstruction and routing module, a RAG module, a prompt word module, a large language module and an answer module;
[0064] The query module is responsible for receiving the query questions input by the user;
[0065] The query reconstruction and routing module is responsible for analyzing the query content of the query question and reconstructing the query question, and then sending the reconstructed query question to the RAG module;
[0066] The RAG module is responsible for calling the corresponding RAG submodule to search the query question and find the document with the highest relevance to the query question;
[0067] The prompt word module is responsible for receiving the documents input from the RAG module and sorting the documents according to their relevance to the query question;
[0068] The large language module receives the query questions input by the user and the documents output by the prompt word module, and generates the answers corresponding to the query questions input by the user;
[0069] The answer module outputs the answer corresponding to the query question entered by the user.
[0070] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A retrieval enhancement generation method based on query reconstruction and routing, characterized in that: The method comprises: Step S1: the query module receives the query question input by the user and sends the query question to the query reconstruction and routing module; Step S2: The query reconstruction and routing module receives the query question input from the user, analyzes and reconstructs the query question, and sends the query instruction to the RAG module through the query routing; Step S3: The RAG module receives the query instruction sent by the query reconstruction and routing module, and calls the corresponding RAG submodule according to the query instruction; Step S4: the prompt word module receives the search results from the RAG module, and the prompt word module re-ranks the search results using a re-ranking technique, placing the documents most relevant to the query question at the top; Step S5: The large language model module receives the query question from the query module and the document output by the prompt word module, and generates an answer to the query question.
2. The query reconstruction and routing-based search enhancement generation method according to claim 1, characterized in that: In step S2, the query question is analyzed, and the analysis content includes the semantic content of the query question, the user's intention, and the required reasoning steps, and the query type of the query question is determined according to the analysis content, wherein the query type includes simple query and complex query; The judgment basis of the simple query is that the semantic content of the query question is direct and clear, the user's intention is clear and the required information is single, and according to the reasoning step large model, the answer can be quickly retrieved or generated from the knowledge base; The basis for judging the complex query is that the semantic content of the query question contains multiple knowledge points or requires cross-domain reasoning, the user's intention is unclear and requires further questioning or clarification, and according to the reasoning steps, the large model needs to comprehensively use multiple knowledge bases or reasoning rules to generate an answer.
3. The query reconstruction and routing-based search enhancement generation method according to claim 2, characterized in that: The query type of the query question is determined according to the analysis content. If the query type is a simple query, the simple query is reconstructed and analyzed according to the grammatical structure. If the simple query does not need to be reconstructed, the query reconstruction and routing module sends the simple question directly to the RAG module through routing.
4. The query reconstruction and routing-based search enhancement generation method according to claim 2, characterized in that: Determining the query type of the query question according to the analysis content, and if the query type is a complex query, determining whether the complex query is a general query according to the analysis content; The judgment basis of the general query is that the semantic content of the query question requires comprehensive, inductive or summarized information, the user's intention is to obtain a concise and clear answer rather than a detailed explanation or reasoning process, and according to the reasoning steps, the large model needs to screen, integrate and summarize the knowledge points or information; If the complex query is a general query, reconstruction is not required, and the query reconstruction and routing module sends the general query to the RAG module through query routing; If the complex query is a non-generalized query, the query reconstruction and routing module sends the non-generalized query to the RAG module through query routing; If the content of the complex query includes two or more query types, the query reconstruction and query routing module reconstructs the complex query, divides the complex query into multiple query types, and sends the multiple query types to the RAG module.
5. The query reconstruction and routing-based search enhancement generation method according to claim 1, characterized in that: In step S3, the RAG module calls the corresponding RAG submodule according to the query type sent by the query reconstruction and routing module; If the query type is a simple query, the RAG module calls the traditional RAG algorithm submodule to retrieve the query question; If the query type is a general query, the RAG module calls the Raptor algorithm submodule to retrieve the query question; If the query type is a non-generalized query, the RAG module calls the Graph RAG algorithm submodule to retrieve the query question; The RAG module includes but is not limited to the traditional RAG algorithm submodule, the Raptor algorithm submodule and the Graph RAG algorithm submodule, and two or more RAG submodules can be called simultaneously to search the query question and output the search results to the prompt word module.
6. A query reconstruction and routing-based retrieval enhancement generation system, used to execute a query reconstruction and routing-based retrieval enhancement generation method according to any one of claims 1 to 5, characterized in that: The system includes a query module, a query reconstruction and routing module, a RAG module, a prompt word module, a large language module and an answer module; The query module is responsible for receiving the query questions input by the user; The query reconstruction and routing module is responsible for analyzing the query content of the query question and reconstructing the query question, and then sending the reconstructed query question to the RAG module; The RAG module is responsible for calling the corresponding RAG submodule to search the query question and find the document with the highest relevance to the query question; The prompt word module is responsible for receiving documents input from the RAG module and sorting the documents according to their relevance to the query question; The large language module receives the query question input by the user and the document output by the prompt word module, and generates an answer corresponding to the query question input by the user; The answer module outputs the answer corresponding to the query question input by the user.
Citation Information
Cited By
Multi-intelligent-agent physical examination enhancement generation system and question answering method, equipment and product thereof
CN120706536A
Access method and device for heterogeneous retrieval enhancement generation (RAG) platform
CN121257672A
A method and apparatus for accessing a heterogeneous search augmented generation (RAG) platform
CN121257672B
Retrieval system and method based on retrieval enhancement generation
CN121935302A