Retrieval enhancement generation method and system based on long-term memory and multi-source knowledge iterative fusion
By introducing an updatable long-term memory mechanism and a multi-source knowledge iterative fusion strategy, the shortcomings of existing retrieval enhancement generation technologies in long-term memory management and multi-source knowledge fusion are addressed, achieving highly relevant and reliable answer generation and improving the overall performance and reliability of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SCHOOL OF SOFTWARE ZHEJIANG UNIV (NINGBO) MANAGEMENT CENT (NINGBO SOFTWARE EDUCATION CENT)
- Filing Date
- 2025-12-17
- Publication Date
- 2026-05-08
AI Technical Summary
Existing retrieval enhancement generation technologies have shortcomings in long-term memory management, retrieval adaptability, and multi-source knowledge fusion, making it difficult to meet the requirements of complex task scenarios, multi-source knowledge utilization, and long-term learning. This results in limited system performance in repetitive tasks, user preference maintenance, and cross-session semantic consistency.
An updatable long-term memory mechanism, an adaptive retrieval strategy, and a multi-source knowledge iterative fusion mechanism are introduced. By triggering long-term memory database retrieval, external knowledge base retrieval, and internal knowledge generation of the large language model in parallel, conflict detection and fusion processing are performed. Iterative judgment is made based on confidence assessment, and finally a high-confidence answer is output, and the long-term memory database is updated.
It improves the accuracy and stability of the system's generated answers in multi-round interactions and complex task scenarios, reduces the risk of biased answers and factual deviations, and enhances the system's ability to utilize multi-source knowledge and its long-term learning ability.
Smart Images

Figure CN121996750A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a retrieval enhancement generation method and system based on the iterative fusion of long-term memory and multi-source knowledge. Background Technology
[0002] Large Language Models (LLMs), as a crucial foundational technology in the field of artificial intelligence in recent years, can learn language structure and semantic rules through training on large-scale corpora, possessing outstanding capabilities in text understanding, knowledge reasoning, and natural language generation. In various natural language processing tasks such as machine translation, intelligent question answering, text summarization, information retrieval assistance, and intelligent customer service, LLMs have demonstrated outstanding comprehensive performance and broad application value.
[0003] To further improve the reliability and accuracy of large language models in factual question answering, knowledge-intensive tasks, and complex reasoning scenarios, retrieval-augmented generation (RAG) technology has become one of the mainstream solutions. This technology typically retrieves knowledge relevant to the user's query from external databases or document collections and combines it with the generative capabilities of large language models to enhance the system's ability to utilize external knowledge. However, existing retrieval-augmented generation technologies still have several shortcomings in terms of long-term application support and multi-source knowledge integration.
[0004] First, existing RAG systems generally lack an accumulative and updatable long-term memory mechanism. Most systems rely solely on immediate retrieval triggered by a single query, failing to effectively manage long-term, multi-turn interaction information between users and the system. When reusable facts, user preferences, or contextual reasoning chains exist in historical interactions, the system cannot automatically extract stable memories, nor does it possess the ability to integrate, correct, or clean up old knowledge, making it difficult for the system to achieve continuous learning and personalized knowledge maintenance. This lack of long-term memory limits the system's performance in repetitive tasks, user preference maintenance, and cross-session semantic consistency.
[0005] Secondly, existing RAG systems generally lack adaptability in their retrieval strategies. Traditional methods employ a fixed top-k retrieval approach without considering the dynamic changes in similarity distribution. In actual retrieval, the search results often exhibit a "cliff-like drop" in similarity. A fixed k approach leads to a large amount of low-relevance or even noisy content being incorrectly included in the generation stage, increasing irrelevant information interference and reducing the model's inference accuracy and generation quality. The lack of detection of similarity trend changes and automatic truncation mechanisms is one of the performance bottlenecks of existing retrieval strategies.
[0006] Secondly, existing RAG systems have limited capabilities in multi-source knowledge fusion. Traditional methods typically employ single-round fusion, inputting query and retrieval content into a large language model for generation in one go. This lacks a systematic mechanism for deep integration, conflict detection, and evidence screening of knowledge from different sources (such as external knowledge base content, potential internal knowledge, and historical interaction information). When there is redundancy, inconsistency, or conflict among multi-source content, single-round fusion struggles to guarantee the logical consistency and factual reliability of the generated results. Furthermore, due to the lack of iterative optimization mechanisms based on confidence levels or generation quality, the model cannot correct and enhance the initial generated results through multi-round fusion, easily leading to one-sided answers, incomplete reasoning chains, or factual biases.
[0007] In summary, existing retrieval enhancement generation techniques still have shortcomings in key aspects such as long-term memory management, retrieval adaptability, and multi-source knowledge fusion, making it difficult to meet the requirements of complex task scenarios, multi-source knowledge utilization, and long-term learning in new applications. Therefore, it is necessary to propose a retrieval enhancement generation method that can simultaneously integrate long-term memory, external knowledge, and knowledge internal to large language models, and possess dynamic retrieval, adaptive truncation, conflict detection, and iterative fusion capabilities, in order to comprehensively improve the system's multi-source knowledge utilization capability, long-term learning capability, and the accuracy and stability of the generated results. Summary of the Invention
[0008] In view of the shortcomings of existing retrieval enhancement generation technologies in terms of long-term memory management, retrieval adaptability, and multi-source knowledge fusion, this invention proposes a retrieval enhancement generation method and system based on the iterative fusion of long-term memory and multi-source knowledge. By introducing an updatable long-term memory, an adaptive retrieval strategy, and an iterative fusion mechanism of multi-source knowledge, this invention achieves highly relevant and reliable answer generation, thereby improving the accuracy and stability of the system.
[0009] In a first aspect, the present invention provides a retrieval enhancement generation method based on the iterative fusion of long-term memory and multi-source knowledge, comprising the following steps:
[0010] After receiving a user's query, the system triggers parallel retrieval of the long-term memory database, retrieval of the external knowledge base, and generation of internal knowledge within the large language model to construct a multi-source candidate knowledge base that includes candidate memory, candidate external knowledge, and candidate internal knowledge.
[0011] The user query, along with candidate memories, candidate external knowledge, and candidate internal knowledge, are input into a large language model. The large language model performs conflict detection and fusion processing to generate candidate answers. Subsequently, confidence is evaluated based on the candidate answers, and iterative condition judgments are performed based on the confidence scores.
[0012] The answer with the highest confidence level is selected from the generated candidate answers and output as the final answer.
[0013] The user query and the final answer are combined into an interaction record, stored in a historical interaction record set, and a memory summary is generated. Then, the interaction record, historical interaction record, and memory summary are input into a large language model to extract candidate memory facts. At the same time, the old memories corresponding to the candidate memory facts are retrieved from the long-term memory bank. The candidate memory facts and the corresponding old memories are input into the large language model together, which determines the update operation of the long-term memory database.
[0014] Secondly, the present invention provides a retrieval enhancement generation system based on the iterative fusion of long-term memory and multi-source knowledge, comprising:
[0015] A multi-source knowledge base module is constructed to trigger parallel retrieval of long-term memory database, external knowledge base, and internal knowledge generation of large language model after the system receives user queries, so as to construct a multi-source candidate knowledge base containing candidate memory, candidate external knowledge, and candidate internal knowledge.
[0016] The conflict detection and fusion processing module is used to input the user query, candidate memory, candidate external knowledge, and candidate internal knowledge into the large language model. The large language model performs conflict detection and fusion processing to generate candidate answers. Then, confidence evaluation is performed based on the candidate answers, and iterative condition judgment is performed based on the confidence scores.
[0017] The final answer output module is used to select the answer with the highest confidence from the generated candidate answers as the final answer output;
[0018] The long-term memory database module is used to combine user queries and the final answers into an interaction record, store it in a historical interaction record set, and generate a memory summary. Then, the interaction record, historical interaction record, and memory summary are input into a large language model to extract candidate memory facts. At the same time, the old memories corresponding to the candidate memory facts are retrieved from the long-term memory database. The candidate memory facts and the corresponding old memories are input into the large language model, which determines the update operation of the long-term memory database.
[0019] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described retrieval enhancement generation method based on long-term memory and multi-source knowledge iterative fusion.
[0020] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described retrieval enhancement generation method based on long-term memory and multi-source knowledge iterative fusion.
[0021] The beneficial effects of this invention are:
[0022] This invention achieves continuous management of user historical interaction information, high relevance filtering of search results, and deep integration of multi-source knowledge by introducing an accumulative and updatable long-term memory mechanism, an adaptive retrieval method based on dynamic top-k values, and a multi-source knowledge iterative fusion strategy.
[0023] This invention can improve the accuracy and stability of generated answers in multi-round interactions and complex task scenarios, effectively reduce the risk of one-sided answers, incomplete reasoning or factual bias, and enhance the system's ability to utilize multi-source knowledge and its long-term learning ability, thereby significantly expanding the system's comprehensive performance and reliability in applications such as intelligent question answering, information retrieval assistance and text generation. Attached Figure Description
[0024] Figure 1 A flowchart illustrating a retrieval enhancement generation method based on iterative fusion of long-term memory and multi-source knowledge provided by this invention;
[0025] Figure 2 A schematic diagram of the multi-source knowledge iterative fusion process provided by the present invention;
[0026] Figure 3 This is a schematic diagram of the process for updating the long-term memory database provided by the present invention. Detailed Implementation
[0027] To describe the present invention in more detail, the technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0028] Conversely, this invention encompasses any substitutions, modifications, equivalent methods, and solutions made within the spirit and scope of the invention as defined in the claims. Furthermore, to provide a better understanding of the invention, certain specific details are described in detail below. However, those skilled in the art will fully understand the invention even without these detailed descriptions.
[0029] In response to the above problems, such as Figure 1 As shown, this application provides a retrieval enhancement generation method based on the iterative fusion of long-term memory and multi-source knowledge, including the following steps:
[0030] S1: Parallel Retrieval and Generation of Multi-Source Knowledge Based on User Inquiries
[0031] Optionally, after receiving a user query, the system simultaneously triggers three parallel processes: long-term memory database retrieval, external knowledge base retrieval, and internal knowledge generation within the large language model, to construct multi-source candidate knowledge. The specific steps are as follows:
[0032] S11: Long-term memory database retrieval: Based on user queries, an adaptive retrieval method based on dynamic top-k values is used to retrieve relevant content from the long-term memory database to obtain candidate memories;
[0033] S12: External knowledge base retrieval: Based on user queries, an adaptive retrieval method based on dynamic top-k values is used to retrieve relevant content from external knowledge bases to obtain candidate external knowledge;
[0034] S13: Internal knowledge generation of the large language model: The large language model directly generates responsive content based on user queries, obtaining candidate internal knowledge.
[0035] Optionally, the adaptive retrieval method based on dynamic top-k values in steps S11 and S12 includes the following sub-steps:
[0036] I. Based on user queries, retrieve the top k content items and their similarity score sequences from the database. , where k is the preset initial search quantity;
[0037] II. For the search results in step I, calculate the similarity ratio between each pair of adjacent items based on their similarity score sequence. The ratio is defined as follows:
[0038]
[0039] III. Each With preset threshold Compare, when a certain position i satisfies When k is truncated to i, the search results with sequence numbers greater than i are discarded to obtain the final valid search results;
[0040] IV. If all None exceeded the threshold If so, the original search results will be retained.
[0041] S2: Iteratively fuse the multi-source candidate knowledge obtained in S1.
[0042] Optionally, such as Figure 2 As shown, the specific implementation steps of S2 are as follows:
[0043] S21: Input the user query, along with the candidate memories, candidate external knowledge, and candidate internal knowledge obtained in S1, into the large language model;
[0044] S22: The large language model performs conflict detection and fusion processing on the input, including merging consistent information, separating conflicting information, and filtering irrelevant information, to generate one or more candidate answers;
[0045] S23: The large language model evaluates the confidence of each candidate answer obtained in S22 and obtains the corresponding confidence score;
[0046] S24: Based on the confidence score, perform iterative condition judgment. Specifically, calculate the change between the maximum confidence score of the current iteration round and the maximum confidence score of the previous iteration round. When the change is greater than a preset threshold, use the current candidate answer and its confidence score as new input and return to S22 to continue iterating. When the change is lower than the preset threshold, or the number of iterations reaches the preset maximum round T, determine that the candidate answer has become stable and terminate the iteration.
[0047] S3: Output the final answer
[0048] Optionally, the candidate answer with the highest confidence level is selected from the candidate answers obtained in S2 and output as the final answer.
[0049] S4: Update the long-term memory database based on the user's current interaction.
[0050] Optionally, such as Figure 3 As shown, the specific implementation steps of S4 are as follows:
[0051] S41: Combine the user's current query with the final answer obtained in S3 to form an interaction record;
[0052] S42: Store the interaction record into the historical interaction record set;
[0053] S43: The large language model generates a corresponding memory summary based on the historical interaction records;
[0054] S44: Input the interaction record formed in S41, the historical interaction record obtained in S42, and the memory summary generated in S43 into the large language model to extract candidate memory facts;
[0055] S45: Based on the candidate memory facts, an adaptive retrieval method based on dynamic top-k values is used to retrieve relevant content from the long-term memory database to obtain the old memory corresponding to each candidate memory fact;
[0056] S46: Input each candidate memory fact obtained in S44 and the corresponding old memory retrieved in S45 into the large language model, which will autonomously determine the update operation for the long-term memory database. The update operation includes adding a memory, modifying an old memory, deleting an old memory, or no update operation.
[0057] In one exemplary embodiment, a retrieval enhancement generation system based on the iterative fusion of long-term memory and multi-source knowledge is provided, comprising:
[0058] A multi-source knowledge base module is constructed to trigger parallel retrieval of long-term memory database, external knowledge base, and internal knowledge generation of large language model after the system receives user queries, so as to construct a multi-source candidate knowledge base containing candidate memory, candidate external knowledge, and candidate internal knowledge.
[0059] The conflict detection and fusion processing module is used to input the user query, candidate memory, candidate external knowledge, and candidate internal knowledge into the large language model. The large language model performs conflict detection and fusion processing to generate candidate answers. Then, confidence evaluation is performed based on the candidate answers, and iterative condition judgment is performed based on the confidence scores.
[0060] The final answer output module is used to select the answer with the highest confidence from the generated candidate answers as the final answer output;
[0061] The long-term memory database module is used to combine user queries and the final answers into an interaction record, store it in a historical interaction record set, and generate a memory summary. Then, the interaction record, historical interaction record, and memory summary are input into a large language model to extract candidate memory facts. At the same time, the old memories corresponding to the candidate memory facts are retrieved from the long-term memory database. The candidate memory facts and the corresponding old memories are input into the large language model, which determines the update operation of the long-term memory database.
[0062] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps in the above-described retrieval enhancement generation method based on iterative fusion of long-term memory and multi-source knowledge.
[0063] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described retrieval enhancement generation method based on iterative fusion of long-term memory and multi-source knowledge.
[0064] The above description of the embodiments is provided to enable those skilled in the art to understand and apply the present invention. Those skilled in the art can readily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative effort. Therefore, the present invention is not limited to the above embodiments, and any improvements and modifications made to the present invention by those skilled in the art based on the disclosure thereof should be within the scope of protection of the present invention.
Claims
1. A retrieval enhancement generation method based on iterative fusion of long-term memory and multi-source knowledge, characterized in that, Includes the following steps: After receiving a user's query, the system triggers parallel retrieval of the long-term memory database, retrieval of the external knowledge base, and generation of internal knowledge within the large language model to construct a multi-source candidate knowledge base that includes candidate memory, candidate external knowledge, and candidate internal knowledge. The user query, along with candidate memories, candidate external knowledge, and candidate internal knowledge, are input into a large language model. The large language model performs conflict detection and fusion processing to generate candidate answers. Subsequently, confidence is evaluated based on the candidate answers, and iterative condition judgments are performed based on the confidence scores. The answer with the highest confidence level is selected from the generated candidate answers and output as the final answer. The user query and the final answer are combined into an interaction record, stored in a historical interaction record set, and a memory summary is generated. Then, the interaction record, historical interaction record, and memory summary are input into a large language model to extract candidate memory facts. At the same time, the old memories corresponding to the candidate memory facts are retrieved from the long-term memory bank. The candidate memory facts and the corresponding old memories are input into the large language model together, which determines the update operation of the long-term memory database.
2. The method according to claim 1, characterized in that, According to user inquiries, both the long-term memory database retrieval and the external knowledge base retrieval adopt an adaptive retrieval method based on dynamic top-k values to generate candidate memories and candidate external knowledge, respectively.
3. The method according to claim 1 or 2, characterized in that, The large language model directly generates responsive content based on user queries, thereby obtaining candidate internal knowledge.
4. The method according to claim 2, characterized in that, The adaptive retrieval method based on dynamic top-k values includes the following steps: Based on user queries, the first k content items and their similarity score sequences are retrieved from the database. Based on the search results, the similarity ratio between each pair of adjacent items is calculated according to the similarity score sequence; Each similarity ratio is compared with a preset threshold to obtain the search results; If none of the similarity ratios exceed the threshold, the original search results will be retained.
5. The method according to claim 1, characterized in that, The conflict detection and fusion process includes merging consistent information, separating conflicting information, and filtering irrelevant information.
6. The method according to claim 1, characterized in that, The iterative condition judgment based on the confidence score includes: When the change exceeds the preset threshold, the current candidate answer and confidence score are re-entered, and the process returns to the conflict detection and fusion processing step to continue iterating. If the change is lower than the preset threshold or the iteration reaches the maximum number of rounds T, the answer is determined to be stable and the iteration is terminated.
7. The method according to claim 1 or 6, characterized in that, The update operation includes adding a memory, modifying an old memory, deleting an old memory, or no update operation.
8. A retrieval enhancement generation system based on iterative fusion of long-term memory and multi-source knowledge, characterized in that, include: A multi-source knowledge base module is constructed to trigger parallel retrieval of long-term memory database, external knowledge base, and internal knowledge generation of large language model after the system receives user queries, so as to construct a multi-source candidate knowledge base containing candidate memory, candidate external knowledge, and candidate internal knowledge. The conflict detection and fusion processing module is used to input the user query, candidate memory, candidate external knowledge, and candidate internal knowledge into the large language model. The large language model performs conflict detection and fusion processing to generate candidate answers. Then, confidence evaluation is performed based on the candidate answers, and iterative condition judgment is performed based on the confidence scores. The final answer output module is used to select the answer with the highest confidence from the generated candidate answers as the final answer output; The long-term memory database module is used to combine user queries and the final answers into an interaction record, store it in a historical interaction record set, and generate a memory summary. Then, the interaction record, historical interaction record, and memory summary are input into a large language model to extract candidate memory facts. At the same time, the old memories corresponding to the candidate memory facts are retrieved from the long-term memory database. The candidate memory facts and the corresponding old memories are input into the large language model, which determines the update operation of the long-term memory database.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Cited By
A reinforcement learning-based credit allocation modeling method for information source perception of search agents
CN122311476A