A method, system and computer program product for retrieval augmented generation

By employing hierarchical retrieval and intelligent truncation technologies, the problems of uncontrolled retrieval scope and difficulty in recognizing complex query intents in existing retrieval enhancement generation systems have been solved, improving retrieval accuracy and efficiency and generating more accurate answers.

CN121935356BActive Publication Date: 2026-07-07江西博微新技术有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
江西博微新技术有限公司
Filing Date
2026-03-30
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing search enhancement generation systems are prone to losing control over the search scope, have difficulty identifying complex query intents, and easily lose core information, resulting in low search efficiency and insufficient accuracy.

Method used

By establishing a hierarchical mechanism, user queries are broken down into subqueries with limited knowledge boundaries, and text retrieval is performed within a specific scope. Combined with language models, intent recognition and hybrid retrieval are carried out, and redundant information is intelligently truncated to ensure retrieval accuracy and efficiency.

Benefits of technology

It achieves efficient identification of fuzzy or compound queries, improves retrieval accuracy and efficiency, avoids the loss of core information, and generates more accurate answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121935356B_ABST
    Figure CN121935356B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of retrieval, and provides a retrieval enhancement generation method, a retrieval enhancement generation system and a computer. The retrieval enhancement generation method comprises the following steps: acquiring a knowledge base and a language model, dividing a plurality of knowledge text groups, and constructing a plurality of question and answer metadata groups; acquiring a query question, and extracting a plurality of intention texts; performing mixed retrieval on the plurality of knowledge text groups to select a matched text group, and establishing a matched metadata group; converting the query question into a plurality of sub-query questions based on the matched metadata group, and retrieving a plurality of knowledge segments; obtaining an initial context segment based on the query question and the plurality of knowledge segments, removing redundant segments to obtain a final context segment, and inputting the final context segment into the language model to generate an answer to the question. Through the above method, the technical problems that the retrieval range is out of control, it is difficult to identify a composite query intention, and core information is easily lost in the prior art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of retrieval technology, and in particular to a retrieval enhancement generation method, system, and computer. Background Technology

[0002] With the development of large language model technology, the integration of large language models into information retrieval technology has become increasingly widespread. These large language models are trained on large-scale corpora and have the ability to learn deep semantics, thereby significantly improving retrieval quality.

[0003] Existing large language models suffer from the illusion problem, meaning they tend to generate information that is inconsistent with or irrelevant to reality. To address this, Retrieval-Augmented Generation (RAG) systems can help reduce this illusion. By connecting questions to specific databases, they provide high-quality sources of search results, thereby optimizing domain-specific knowledge within the large model. This achieves the effects of optimizing queries and improving the accuracy of search results with a smaller amount of data.

[0004] Existing retrieval enhancement systems generally employ a single-layer, flat retrieval model. This model vectorizes user queries and performs a global similarity search on the underlying text fragments of the entire knowledge base. The retrieved results are then used as context input to a large language model to generate the answer. However, this approach suffers from problems such as a lack of control over the retrieval scope, low retrieval accuracy, severe context pollution, and low retrieval efficiency. Furthermore, directly using user queries for retrieval makes it difficult to identify complex intents in fuzzy or complex queries. When the length of the generated context exceeds the processing limit of the large model, existing models use mechanical truncation methods, which can easily lead to the loss of core information. Consequently, the overall retrieval answer is incomplete and inaccurate, failing to meet user needs. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention aims to provide a retrieval enhancement generation method, system, and computer. This invention establishes a hierarchical mechanism by performing semantic domain localization and knowledge boundary delineation on user queries before retrieving underlying text fragments. It decomposes user queries into several sub-queries with limited knowledge boundaries, and performs text retrieval on each sub-query within a specific range of the underlying text database. This significantly improves the ability to identify fuzzy and complex queries, enhancing retrieval accuracy and efficiency. Intelligent truncation is performed on context exceeding the processing limits of large models, thus avoiding the loss of core information. This invention aims to solve the technical problems in existing retrieval enhancement generation systems, such as uncontrollable retrieval scope, difficulty in identifying complex query intent, and easy loss of core information, leading to low retrieval efficiency, low retrieval result accuracy, and severe context pollution.

[0006] To achieve the above objectives, the present invention is implemented through the following technical solution:

[0007] A retrieval enhancement generation method includes the following steps:

[0008] A knowledge base and language model are acquired. Based on the knowledge base, several knowledge concept texts are acquired. The several knowledge concept texts are divided into several knowledge text groups according to several knowledge domains. Several question-and-answer metadata groups are constructed based on the several knowledge text groups. The question-and-answer metadata groups correspond to several knowledge regions in the knowledge base. The question-and-answer metadata groups are used to describe the question and answer range corresponding to the knowledge text groups.

[0009] The system obtains the user's query question, performs intent recognition on the query question using the language model, and extracts several intent texts from the query question.

[0010] Based on several intent texts and the language model, a mixed retrieval is performed in several knowledge text groups to select a matching text group from the several knowledge text groups, and the question-and-answer metadata group corresponding to the matching text group is established as the matching metadata group;

[0011] Based on the matching metadata group, the query question is converted into several sub-query questions, and based on the several sub-query questions, several knowledge fragments are retrieved from the knowledge base;

[0012] Based on the query question and several knowledge fragments, an initial context fragment is obtained. It is then determined whether there are redundant fragments in the initial context fragment. If there are redundant fragments in the initial context fragment, the redundant fragments are removed to obtain a final context fragment. The final context fragment is then input into the language model to generate the question answer.

[0013] Furthermore, the step of obtaining the user's query question includes:

[0014] Obtain the user's original question;

[0015] Obtain the term replacement identifier, and determine whether to perform term replacement based on the term replacement identifier;

[0016] If terminology replacement is performed, a preset business terminology database is obtained, and based on the preset business terminology database and the language model, the original question is converted into a query question;

[0017] If no terminology substitution is performed, the original question is established as a query question.

[0018] Furthermore, the step of performing intent recognition on the query question using the language model to extract several intent texts from the query question includes:

[0019] The intent of the query question is identified by the language model, and query rules and several keywords are extracted from the query question. The query rules and several keywords are then combined to form the intent text.

[0020] Furthermore, the step of performing a mixed retrieval based on several intent texts and the language model within several knowledge text groups to select matching text groups from the several knowledge text groups includes:

[0021] Based on several intent texts and the language model, a mixed retrieval is performed in several knowledge text groups according to dense semantics and sparse keywords to obtain several candidate text groups;

[0022] Several candidate text groups are input into the language model to obtain the intent matching degree of several candidate text groups. Based on the intent matching degree, a matching text group is selected from several candidate text groups.

[0023] Furthermore, the matching metadata group includes several question-and-answer metadata, each of which corresponds to a knowledge region. The step of converting the query question into several sub-query questions based on the matching metadata group, and retrieving several knowledge fragments from the knowledge base based on the several sub-query questions, includes:

[0024] The query question and the question metadata are input into the language model to convert the query question into several sub-query questions, and the several sub-query questions correspond one-to-one with the several question and answer metadata.

[0025] Based on the subquery question, knowledge fragments are retrieved from the knowledge region corresponding to the subquery question in the knowledge base.

[0026] Furthermore, after the step of inputting several sets of question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions, wherein the several sub-query questions correspond one-to-one with several sets of question-and-answer metadata, the method further includes:

[0027] Input several of the question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions to be confirmed;

[0028] The system returns several subqueries to be confirmed to the user, obtains the user's confirmation identifier, and determines whether to confirm the current conversion result based on the confirmation identifier.

[0029] If the current conversion result is not confirmed, the question and answer metadata, the query question, and several sub-query questions to be confirmed are input into the language model to obtain several updated sub-query questions. The several updated sub-query questions are then returned to the user to obtain the updated confirmation identifier.

[0030] If the current transformation result is confirmed, then the several subquery problems to be confirmed will be established as several subquery problems.

[0031] Furthermore, the step of obtaining the initial context fragment based on the query question and several knowledge fragments includes:

[0032] Obtain a preset number of dialogue rounds and several historical dialogue rounds, and divide the several historical dialogue rounds into a first historical dialogue group and a second historical dialogue group based on the preset number of dialogue rounds;

[0033] Based on several knowledge segments and the language model, several relevance scores are obtained for several knowledge segments, and the knowledge segment with the highest relevance score is established as the first knowledge segment, and the remaining several knowledge segments are established as several second knowledge segments.

[0034] The query question, the first historical dialogue group, the first knowledge fragment, the second historical dialogue group, and several second knowledge fragments are sequentially sorted and combined into an initial context fragment.

[0035] Furthermore, the step of determining whether there are redundant segments in the initial context segment, and removing the redundant segments to obtain the final context segment if redundant segments exist in the initial context segment, includes:

[0036] Based on the input constraints of the language model, a context length threshold is obtained, and the length of the initial context segment is compared with the context length threshold to determine whether there are redundant segments in the initial context segment;

[0037] If there are redundant segments in the initial context segment, then based on the order of the query question, the first historical dialogue group, the first knowledge segment, the second historical dialogue group, and several second knowledge segments, the segments in the initial context segment that exceed the context length threshold are identified as redundant segments, and the redundant segments are removed to form the final context segment.

[0038] A retrieval enhancement generation system, employing the retrieval enhancement generation method described in the above technical solution, the system comprising:

[0039] The acquisition module is used to acquire a knowledge base and a language model, acquire several knowledge concept texts based on the knowledge base, divide the several knowledge concept texts into several knowledge text groups according to several knowledge domains, construct several question and answer metadata groups based on the several knowledge text groups, the question and answer metadata groups correspond to several knowledge regions in the knowledge base, and the question and answer metadata groups are used to describe the question and answer range corresponding to the knowledge text groups;

[0040] The recognition module is used to obtain the user's query question, and to perform intent recognition on the query question through the language model in order to extract several intent texts from the query question;

[0041] The matching module is used to perform mixed retrieval in several knowledge text groups based on several intent texts and the language model, so as to select a matching text group from the several knowledge text groups, and establish the question-answer metadata group corresponding to the matching text group as the matching metadata group;

[0042] The retrieval module is used to convert the query question into several sub-query questions based on the matching metadata group, and to retrieve several knowledge fragments from the knowledge base based on the several sub-query questions;

[0043] The generation module is used to obtain an initial context fragment based on the query question and several knowledge fragments, determine whether there are redundant fragments in the initial context fragment, remove the redundant fragments if there are redundant fragments in the initial context fragment, obtain a final context fragment, and input the final context fragment into the language model to generate the question answer.

[0044] A computer includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the retrieval enhancement generation method as described above.

[0045] Compared with the prior art, the beneficial effects of the present invention are as follows: By grouping several knowledge concept texts into multiple knowledge text groups according to different knowledge domains, and setting several question-and-answer metadata groups, each question-and-answer metadata group corresponds to several knowledge regions, the knowledge text groups can be matched first during querying, and then the search can be performed in the underlying text library within a range according to the knowledge text groups. That is, hierarchical search is performed in the knowledge library, the search is orderly, and the search range is precise and controllable, which greatly improves the efficiency compared with the global search in the underlying text library in the traditional method; by extracting multiple intent texts from the query question through the language model, it is beneficial to comprehensively segment and structure the user's intent for fuzzy or complex questions, and combine multiple intent texts to retrieve the most matching text group. The matching metadata group corresponding to the matching text group then plays a role in... This system instructs users on the scope and location of the search within the knowledge base, preventing the retrieval of irrelevant information based on vague intentions. Furthermore, it precisely breaks down the query into multiple targeted questions based on the matching metadata group. Each sub-query has question-and-answer metadata pointing to a specific search location. Parallel retrieval of multiple sub-queries significantly improves search accuracy and efficiency. By retrieving multiple knowledge fragments and acquiring multiple rounds of historical dialogue, the text fragments are sorted according to the matching degree of the search results and the time rounds of the historical dialogue to form the initial context fragment. When redundant fragments need to be removed, the initial context fragment is truncated according to the sorting, prioritizing the removal of secondary information. This avoids the loss of core information caused by mechanical truncation in traditional methods, greatly improving the accuracy of the final generated answer and meeting user needs. Attached Figure Description

[0046] Figure 1 This is a flowchart of the retrieval enhancement generation method in the first embodiment of the present invention;

[0047] Figure 2 This is a structural block diagram of the retrieval enhancement generation system in the second embodiment of the present invention;

[0048] The following detailed description, in conjunction with the accompanying drawings, will further illustrate the present invention. Detailed Implementation

[0049] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Several embodiments of the invention are illustrated in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.

[0050] It should be noted that when a component is said to be "fixed to" another component, it can be directly on the other component or there may be an intervening component. When a component is said to be "connected to" another component, it can be directly connected to the other component or there may be an intervening component. The terms "vertical," "horizontal," "left," "right," and similar expressions used in this document are for illustrative purposes only.

[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0052] Please see Figure 1 The retrieval enhancement generation method in the first embodiment of the present invention includes the following steps:

[0053] Step S10: Obtain a knowledge base and language model. Based on the knowledge base, obtain several knowledge concept texts. Divide the several knowledge concept texts into several knowledge text groups according to several knowledge domains. Construct several question-and-answer metadata groups based on the several knowledge text groups. The question-and-answer metadata groups correspond to several knowledge regions in the knowledge base. The question-and-answer metadata groups are used to describe the question and answer range corresponding to the knowledge text groups.

[0054] Preferably, the knowledge base is a low-level text library, the language model is a Large Language Model (LLM), and several question-and-answer metadata groups form a metadata layer. The knowledge text group and the question-and-answer metadata group serve as a high-level knowledge index, which can depict the knowledge boundary of a specific business scenario. When searching in the knowledge base, a hierarchical search is performed. The question-and-answer metadata group defines the scope of questions that can be answered by several corresponding knowledge regions. Furthermore, the method for corresponding the question-and-answer metadata group with several knowledge regions is to set a knowledge base pointer pointing to the knowledge region based on the metadata. The knowledge base pointer can be in the form of "kb_id" or "doc_id".

[0055] Step S20: Obtain the user's query question, and perform intent recognition on the query question through the language model to extract several intent texts from the query question;

[0056] Understandably, extracting multiple intent texts from the query question through the language model is beneficial for comprehensively segmenting and structurally refining the user's intent for fuzzy or complex questions.

[0057] Step S20 includes:

[0058] S210: Obtain the user's original question;

[0059] S220: Obtain the term replacement identifier, and determine whether to perform term replacement based on the term replacement identifier;

[0060] S230: If terminology replacement is performed, a preset business terminology database is obtained, and the original question is converted into a query question based on the preset business terminology database and the language model;

[0061] S240: If no term substitution is performed, the original question is established as a query question.

[0062] S250: The intent of the query question is identified through the language model, query rules and several keywords are extracted from the query question, and the query rules and several keywords are combined to form intent text.

[0063] Preferably, in steps S210-S250, the system can be configured to enable terminology replacement. The preset business terminology library is used to replace colloquial and non-standard expressions input by the user, which can eliminate misidentification caused by non-standard expressions. For more ambiguous or complex query questions, extracting multiple key texts is helpful in identifying the user's true intent. For example, for the question "Our general manager's assistant went on a business trip to Beijing. What are the standards?", the extracted keywords are "business trip" and "Beijing".

[0064] Step S30: Based on several intent texts and the language model, perform a mixed search in several knowledge text groups to select matching text groups from the several knowledge text groups, and establish the question-and-answer metadata group corresponding to the matching text group as the matching metadata group;

[0065] Preferably, based on the intent extracted from the question "What are the standards for our general manager's assistant going on a business trip to Beijing?", after retrieval and LLM filtering, the matching text group is confirmed to be "travel expense management regulations," and the matching metadata group defines the scope of the answer to this question as "transportation standards," "accommodation standards," etc. The knowledge base pointer can then point to several knowledge areas in the knowledge base corresponding to "transportation standards" and "accommodation standards." Understandably, by forming a hierarchical abstraction mechanism through the matching text group and the matching metadata group, the retrieval enhancement generation system possesses preliminary planning capabilities. Compared to the "query-match" method used in traditional retrieval enhancement generation systems, the method in this embodiment clarifies which knowledge area to search before answering the user, thereby solving the problems of scope control and context pollution in retrieval enhancement generation systems.

[0066] S310: Based on several intent texts and the language model, perform a mixed search on several knowledge text groups according to dense semantics and sparse keywords to obtain several candidate text groups;

[0067] S320: Input several candidate text groups into the language model to obtain the intent matching degree of several candidate text groups, and select a matching text group from several candidate text groups based on the intent matching degree.

[0068] Preferably, performing hybrid retrieval and filtering and outputting the intent matching degree uses different sub-modules in the LLM model. Selecting the matching text groups in a hierarchical manner is beneficial to further improve retrieval accuracy.

[0069] Step S40: Based on the matching metadata group, the query question is converted into several sub-query questions, and based on the several sub-query questions, several knowledge fragments are retrieved from the knowledge base;

[0070] Preferably, for example, regarding the "transportation standards" and "accommodation standards" defined by the matching metadata group, the query question can be transformed into two sub-questions: "Transportation standards for the General Manager's Assistant in Beijing" and "Accommodation standards for the General Manager's Assistant in Beijing." Parallel retrieval tasks are established based on several sub-query questions. The search is then performed only within a small range of documents within a specified knowledge area using the knowledge base pointer, thus achieving physical scope limitation. Understandably, this transforms the user's vague and complex intent into a series of precise, efficient, and executable retrieval tasks.

[0071] Step S40 includes:

[0072] S410: Input several of the question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions, and the several sub-query questions correspond one-to-one with several of the question-and-answer metadata;

[0073] Following S410, the following is also included:

[0074] S4110: Input several of the question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions to be confirmed;

[0075] S4120: Return several of the subquery questions to be confirmed to the user, obtain the user's confirmation identifier, and determine whether to confirm the current conversion result based on the confirmation identifier;

[0076] S4130: If the current conversion result is not confirmed, the question and answer metadata, the query question, and several sub-query questions to be confirmed are input into the language model to obtain several updated sub-query questions. The several updated sub-query questions are then returned to the user to obtain the updated confirmation identifier.

[0077] S4140: If the current transformation result is confirmed, then the several subquery problems to be confirmed are established as several subquery problems.

[0078] Preferably, a user confirmation function is provided. Each time the query question is converted into several sub-questions, the sub-questions are displayed on the user interface. Based on the user's operation, the user confirms whether to execute the retrieval task according to the conversion result, which helps to further confirm the user's intention and meet the user's needs.

[0079] S420: Based on the subquery question, retrieve knowledge fragments from the knowledge region corresponding to the subquery question in the knowledge base.

[0080] Preferably, the knowledge region corresponding to the question-and-answer metadata can be found by reading the knowledge base pointer at the physical layer. The knowledge base pointer is, for example, "kb_id: financial system knowledge base" or "doc_id: Official_Travel_Policy.pdf".

[0081] Step S50: Based on the query question and several knowledge fragments, an initial context fragment is obtained. It is determined whether there are redundant fragments in the initial context fragment. If there are redundant fragments in the initial context fragment, the redundant fragments are removed to obtain the final context fragment. The final context fragment is input into the language model to generate the question answer.

[0082] Preferably, all retrieved information and historical dialogues are intelligently synthesized into the initial context fragment. Since the LLM model has an input limit, when the initial context fragment exceeds the limit, its text length needs to be adjusted before it can be input into the LLM model for text generation. The mechanical truncation methods used in the prior art (such as first-in-first-out, discarding low-level segments) cannot distinguish the structural information of the dialogue, the authoritative information of the evidence, and the historical background information. Indiscriminate truncation strategies are prone to discarding core information that is crucial to generating coherent and accurate answers. Understandably, by judging the redundant fragments, the text is intelligently truncated to obtain the final context fragment, which can avoid generating errors or irrelevant answers due to the loss of core information.

[0083] Step S50 includes:

[0084] S510: Obtain a preset number of dialogue rounds and several rounds of historical dialogue, and divide the several rounds of historical dialogue into a first historical dialogue group and a second historical dialogue group based on the preset number of dialogue rounds;

[0085] Preferably, the historical dialogues include user questions and AI answers. If the preset number of dialogue rounds is 2, then the most recent 2 rounds of historical dialogues form the first historical dialogue group, and the historical dialogues in the previous few rounds form the second historical dialogue group.

[0086] S520: Based on several knowledge segments and the language model, obtain several relevance scores for several knowledge segments, and establish the knowledge segment with the highest relevance score as the first knowledge segment, and the remaining several knowledge segments as several second knowledge segments;

[0087] Preferably, the optimal knowledge fragment is extracted based on relevance so that it can be prioritized in the context.

[0088] S530: The query question, the first historical dialogue group, the first knowledge fragment, the second historical dialogue group, and several second knowledge fragments are sequentially sorted and combined into an initial context fragment.

[0089] Preferably, the information is sorted from highest to lowest priority, with the first priority being the query question, the second priority being the first historical dialogue group, the third priority being the knowledge fragment with the highest relevance, i.e., the first knowledge fragment, and the fourth priority being the earlier historical dialogues and several knowledge fragments with slightly lower relevance, i.e., the second historical dialogue group and several second knowledge fragments.

[0090] S540: Based on the input constraints of the language model, obtain the context length threshold, compare the length of the initial context segment with the context length threshold, and determine whether there are redundant segments in the initial context segment;

[0091] Preferably, the initial context segment length is calculated; if it exceeds the limit, then redundant segments exist.

[0092] S550: If there are redundant segments in the initial context segment, then based on the order of the query question, the first historical dialogue group, the first knowledge segment, the second historical dialogue group and several second knowledge segments, the segments in the initial context segment that exceed the context length threshold are identified as redundant segments, and the redundant segments are removed to form the final context segment.

[0093] Preferably, truncation starts from the lowest priority and proceeds upwards, i.e., starting with the text corresponding to the fourth priority, then truncating the third priority, second priority, and so on, until the total length meets the input length of the LLM model. Specifically, starting from the oldest dialogue, the AI ​​assistant's answer is removed. If it still exceeds the limit, the process continues from the oldest dialogue, removing the user's question. If it still exceeds the limit, the knowledge fragment with the lowest relevance score is discarded. In all cases, the text corresponding to the first and second priorities is retained to ensure the integrity of the core question and short-term dialogue memory. Finally, the final answer is generated in a streaming manner.

[0094] Please see Figure 2 The retrieval enhancement generation system provided in the second embodiment of the present invention applies the retrieval enhancement generation method described in the first embodiment above, and the system includes:

[0095] The acquisition module 10 is used to acquire a knowledge base and a language model, acquire several knowledge concept texts based on the knowledge base, divide the several knowledge concept texts into several knowledge text groups according to several knowledge domains, construct several question and answer metadata groups based on the several knowledge text groups, the question and answer metadata groups correspond to several knowledge regions in the knowledge base, and the question and answer metadata groups are used to describe the question and answer range corresponding to the knowledge text groups;

[0096] The recognition module 20 is used to obtain the user's query question, and to perform intent recognition on the query question through the language model in order to extract several intent texts from the query question;

[0097] The identification module 20 includes:

[0098] The first unit is used to obtain the user's original question;

[0099] The second unit is used to obtain the term replacement identifier and determine whether to perform term replacement based on the term replacement identifier.

[0100] The third unit is used to obtain a preset business terminology database if terminology replacement is to be performed, and to convert the original question into a query question based on the preset business terminology database and the language model.

[0101] The fourth unit is used to establish the original question as a query question if no term substitution is performed.

[0102] The fifth unit is used to perform intent recognition on the query question through the language model, extract query rules and several keywords from the query question, and combine the query rules and several keywords into intent text.

[0103] The matching module 30 is used to perform mixed retrieval in several knowledge text groups based on several intent texts and the language model, so as to select a matching text group from the several knowledge text groups, and establish the question-and-answer metadata group corresponding to the matching text group as the matching metadata group;

[0104] The sixth unit is used to perform a mixed retrieval of dense semantics and sparse keywords in several knowledge text groups based on several intent texts and the language model to obtain several candidate text groups;

[0105] The seventh unit is used to input several candidate text groups into the language model, obtain the intent matching degree of several candidate text groups, and select a matching text group from several candidate text groups based on the intent matching degree.

[0106] The retrieval module 40 is used to convert the query question into several sub-query questions based on the matching metadata group, and to retrieve several knowledge fragments from the knowledge base based on the several sub-query questions;

[0107] The retrieval module 40 includes:

[0108] The eighth unit is used to input several of the question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions, and the several sub-query questions correspond one-to-one with several of the question-and-answer metadata;

[0109] The eighth unit is specifically used for:

[0110] Input several of the question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions to be confirmed;

[0111] The system returns several subqueries to be confirmed to the user, obtains the user's confirmation identifier, and determines whether to confirm the current conversion result based on the confirmation identifier.

[0112] If the current conversion result is not confirmed, the question and answer metadata, the query question, and several sub-query questions to be confirmed are input into the language model to obtain several updated sub-query questions. The several updated sub-query questions are then returned to the user to obtain the updated confirmation identifier.

[0113] If the current transformation result is confirmed, then the several subquery problems to be confirmed will be established as several subquery problems.

[0114] The ninth unit is used to retrieve knowledge fragments from the knowledge region corresponding to the subquery question in the knowledge base, based on the subquery question.

[0115] The generation module 50 is used to obtain an initial context fragment based on the query question and several knowledge fragments, determine whether there are redundant fragments in the initial context fragment, remove the redundant fragments if there are redundant fragments in the initial context fragment, obtain a final context fragment, and input the final context fragment into the language model to generate the question answer.

[0116] The generation module 50 includes:

[0117] The tenth unit is used to obtain a preset number of dialogue rounds and several historical dialogue rounds, and to divide the several historical dialogue rounds into a first historical dialogue group and a second historical dialogue group based on the preset number of dialogue rounds.

[0118] The eleventh unit is used to obtain several relevance scores of several knowledge segments based on several knowledge segments and the language model, and to establish the knowledge segment with the highest relevance score as the first knowledge segment, and the remaining several knowledge segments as several second knowledge segments.

[0119] The twelfth unit is used to sequentially sort and combine the query question, the first historical dialogue group, the first knowledge fragment, the second historical dialogue group, and several second knowledge fragments into an initial context fragment.

[0120] The thirteenth unit is used to obtain a context length threshold based on the input constraints of the language model, and compare the length of the initial context segment with the context length threshold to determine whether there are redundant segments in the initial context segment;

[0121] The fourteenth unit is used to identify redundant fragments in the initial context fragment if there are redundant fragments, based on the order of the query question, the first historical dialogue group, the first knowledge fragment, the second historical dialogue group and several second knowledge fragments, and remove the redundant fragments to form the final context fragment.

[0122] A third embodiment of the present invention provides a computer, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the retrieval enhancement generation method as described in the first embodiment.

[0123] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0124] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.

Claims

1. A retrieval enhancement generation method, characterized in that, Includes the following steps: A knowledge base and language model are acquired. Based on the knowledge base, several knowledge concept texts are acquired. The several knowledge concept texts are divided into several knowledge text groups according to several knowledge domains. Several question-and-answer metadata groups are constructed based on the several knowledge text groups. The question-and-answer metadata groups correspond to several knowledge regions in the knowledge base. The question-and-answer metadata groups are used to describe the question and answer range corresponding to the knowledge text groups. The system obtains the user's query question, performs intent recognition on the query question using the language model, and extracts several intent texts from the query question. Based on several intent texts and the language model, a mixed retrieval is performed in several knowledge text groups to select a matching text group from the several knowledge text groups, and the question-and-answer metadata group corresponding to the matching text group is established as the matching metadata group; Based on the matching metadata group, the query question is converted into several sub-query questions, and based on the several sub-query questions, several knowledge fragments are retrieved from the knowledge base; Based on the query question and several knowledge fragments, an initial context fragment is obtained. It is then determined whether there are redundant fragments in the initial context fragment. If there are redundant fragments in the initial context fragment, the redundant fragments are removed to obtain a final context fragment. The final context fragment is then input into the language model to generate the question answer. The step of obtaining the initial context fragment based on the query question and several knowledge fragments includes: Obtain a preset number of dialogue rounds and several historical dialogue rounds, and divide the several historical dialogue rounds into a first historical dialogue group and a second historical dialogue group based on the preset number of dialogue rounds; Based on several knowledge segments and the language model, several relevance scores are obtained for several knowledge segments, and the knowledge segment with the highest relevance score is established as the first knowledge segment, and the remaining several knowledge segments are established as several second knowledge segments. The query question, the first historical dialogue group, the first knowledge fragment, the second historical dialogue group, and several second knowledge fragments are sequentially sorted and combined into an initial context fragment; The step of determining whether there is a redundant segment in the initial context segment, and removing the redundant segment to obtain the final context segment if the initial context segment contains a redundant segment, includes: Based on the input constraints of the language model, a context length threshold is obtained, and the length of the initial context segment is compared with the context length threshold to determine whether there are redundant segments in the initial context segment; If there are redundant segments in the initial context segment, then based on the order of the query question, the first historical dialogue group, the first knowledge segment, the second historical dialogue group, and several second knowledge segments, the segments in the initial context segment that exceed the context length threshold are identified as redundant segments, and the redundant segments are removed to form the final context segment.

2. The retrieval enhancement generation method according to claim 1, characterized in that, The steps for obtaining the user's query question include: Obtain the user's original question; Obtain the term replacement identifier, and determine whether to perform term replacement based on the term replacement identifier; If terminology replacement is performed, a preset business terminology database is obtained, and based on the preset business terminology database and the language model, the original question is converted into a query question; If no terminology substitution is performed, the original question is established as a query question.

3. The retrieval enhancement generation method according to claim 1, characterized in that, The step of performing intent recognition on the query question using the language model to extract several intent texts from the query question includes: The intent of the query question is identified by the language model, and query rules and several keywords are extracted from the query question. The query rules and several keywords are then combined to form the intent text.

4. The retrieval enhancement generation method according to claim 1, characterized in that, The step of performing a mixed retrieval based on several intent texts and the language model within several knowledge text groups to select matching text groups from the several knowledge text groups includes: Based on several intent texts and the language model, a mixed retrieval is performed in several knowledge text groups according to dense semantics and sparse keywords to obtain several candidate text groups; Several candidate text groups are input into the language model to obtain the intent matching degree of several candidate text groups. Based on the intent matching degree, a matching text group is selected from several candidate text groups.

5. The retrieval enhancement generation method according to claim 1, characterized in that, The matching metadata group includes several question-and-answer metadata, each of which corresponds to a knowledge region. The step of converting the query question into several sub-query questions based on the matching metadata group, and retrieving several knowledge fragments from the knowledge base based on the several sub-query questions, includes: The query question and the question metadata are input into the language model to convert the query question into several sub-query questions, and the several sub-query questions correspond one-to-one with the several question and answer metadata. Based on the subquery question, knowledge fragments are retrieved from the knowledge region corresponding to the subquery question in the knowledge base.

6. The retrieval enhancement generation method according to claim 5, characterized in that, After the step of inputting several sets of question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions, and the several sub-query questions corresponding one-to-one with several sets of question-and-answer metadata, the method further includes: Input several of the question-and-answer metadata and the query question into the language model to convert the query question into several sub-query questions to be confirmed; The system returns several subqueries to be confirmed to the user, obtains the user's confirmation identifier, and determines whether to confirm the current conversion result based on the confirmation identifier. If the current conversion result is not confirmed, the question and answer metadata, the query question, and several sub-query questions to be confirmed are input into the language model to obtain several updated sub-query questions. The several updated sub-query questions are then returned to the user to obtain the updated confirmation identifier. If the current transformation result is confirmed, then the several subquery problems to be confirmed will be established as several subquery problems.

7. A retrieval enhancement generation system, employing the retrieval enhancement generation method as described in any one of claims 1 to 6, characterized in that, The system includes: The acquisition module is used to acquire a knowledge base and a language model, acquire several knowledge concept texts based on the knowledge base, divide the several knowledge concept texts into several knowledge text groups according to several knowledge domains, construct several question and answer metadata groups based on the several knowledge text groups, the question and answer metadata groups correspond to several knowledge regions in the knowledge base, and the question and answer metadata groups are used to describe the question and answer range corresponding to the knowledge text groups; The recognition module is used to obtain the user's query question, and to perform intent recognition on the query question through the language model in order to extract several intent texts from the query question; The matching module is used to perform mixed retrieval in several knowledge text groups based on several intent texts and the language model, so as to select a matching text group from the several knowledge text groups, and establish the question-answer metadata group corresponding to the matching text group as the matching metadata group; The retrieval module is used to convert the query question into several sub-query questions based on the matching metadata group, and to retrieve several knowledge fragments from the knowledge base based on the several sub-query questions; The generation module is used to obtain an initial context fragment based on the query question and several knowledge fragments, determine whether there are redundant fragments in the initial context fragment, remove the redundant fragments if there are redundant fragments in the initial context fragment, obtain a final context fragment, and input the final context fragment into the language model to generate the question answer.

8. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the retrieval enhancement generation method as described in any one of claims 1 to 6.