A query-aware graph enhancement memory method and device for long-term dialogue agents
By constructing a long-term memory pool and a local memory graph, the problems of high computational cost and low response quality in long-term dialogues of large language models are solved, achieving more efficient utilization of historical information and accurate answer generation.
Patent Information
- Application Number
- CN202611406698.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-10
- Publication Date
- 2026-11-17
AI Technical Summary
Large Language Models (LLMs) struggle to efficiently preserve and utilize user preferences, historical events, and information updates in long-term dialogues, leading to high computational costs and decreased response quality.
We construct a searchable and traceable long-term memory pool, select working memory through hybrid retrieval and event-constrained priority ranking, dynamically construct a local memory graph, and convert it into a graph memory representation for input into a large language model.
It improves the accuracy of responses from long-term dialogue agents in fact recall, multi-evidence combination, temporal reasoning, and information update processing, while reducing interference from irrelevant historical information.
Smart Images

Figure CN123115346A_ABST
Abstract
Description
Technical Field
[0001] This disclosure generally relates to the field of natural language processing technology, and more specifically, to a query-aware graph enhancement memory method and apparatus for long-term dialogue agents. Background Technology
[0002] In related fields, Large Language Models (LLMs) are widely used in tasks such as natural language understanding, question answering, intelligent search, code generation, task planning, and Retrieval Augmentation (RAG). As LLMs are increasingly applied to continuous interaction scenarios such as intelligent assistants, intelligent customer service, personal assistants, and task-oriented dialogue systems, these systems need to save and utilize user preferences, personal facts, historical events, task status, time arrangements, and information updates during cross-turn and cross-session interactions to improve the continuity, accuracy, and personalization of the system's responses.
[0003] However, LLMs cannot directly handle all historical dialogue content generated during long-term interactions. Directly inputting the complete historical dialogue into an LLM would significantly increase input length, computational cost, and inference latency, and could introduce a large amount of historical information irrelevant to the current question, affecting the LLM's understanding and response quality.
[0004] Therefore, how to efficiently improve LLM's understanding and response quality to current problems has become one of the important issues in the long-term research field of dialogue agents. Summary of the Invention
[0005] The embodiments of this disclosure provide a query-aware graph-enhanced memory method and apparatus for long-term dialogue agents, the purpose of which is at least to solve how to efficiently improve the LLM's understanding and response quality to the current question in long-term dialogue scenarios.
[0006] In one general aspect, a query-aware graph-enhanced memory method for long-term dialogue agents is provided, comprising: receiving historical user input and current user query input through multi-turn dialogue; constructing a long-term memory pool comprising multiple searchable and traceable atomic memory units based on the historical user dialogue input; determining a working memory corresponding to the current user query input from the long-term memory pool by performing hybrid retrieval, event-constrained priority ranking, and memory reordering on the current user query input; dynamically constructing a local memory graph based solely on the working memory using a pre-trained graph encoder; converting the local memory graph into a graph memory representation recognizable by a predefined large language model using a pre-trained projector; and inputting the graph memory representation, textual evidence in the working memory, and the current user query input into the predefined large language model to obtain a final answer corresponding to the current user query input.
[0007] Optionally, the plurality of atomic memory units may include memory content, source evidence, related entities, related locations, fact time, discourse time, and structured fact records, and each atomic memory unit may be constructed to store the corresponding source evidence in association with an independent fact, event, state, preference, plan, or task information.
[0008] Optionally, the step of constructing a long-term memory pool comprising multiple searchable and traceable atomic memory units based on the historical user dialogue input may include: segmenting the historical user dialogue input based on a sliding window, identifying facts, preferences, events, plans, requests, and state changes in the historical user dialogue input as multiple independently searchable and traceable atomic memory units, thereby constructing a long-term memory pool comprising the multiple atomic memory units.
[0009] Optionally, the step of determining the working memory of the current answer corresponding to the current user query input from the long-term memory pool by performing hybrid retrieval, event constraint priority sorting, and memory reordering on the current user query input may include: selecting a predetermined number of atomic memory units associated with the current user query input from the long-term memory pool by performing query condition parsing processing, candidate memory recall processing, condition constraint sorting processing, and reordering selection processing on the current user query input; and obtaining the current answer corresponding to the current user query input based on the predetermined number of atomic memory units, which serves as the working memory of the current answer corresponding to the current user query input.
[0010] Optionally, the step of dynamically constructing a local memory graph based solely on the working memory using a pre-trained graph encoder may include: mapping people, organizations, items, locations, tasks, events, and / or states contained in the working memory to nodes in a first memory graph; mapping factual relationships, action relationships, subordinate relationships, temporal order relationships, state update relationships, and / or evidence support relationships to edges between nodes; and using source evidence, factual time information, and discourse time information as additional attributes of nodes and / or edges; encoding the nodes, edges, and their connections in the first memory graph using a pre-trained graph encoder to obtain a graph representation including structural information, which serves as the local memory graph.
[0011] Optionally, the query condition parsing process may include: extracting query conditions from the current user query input, wherein the current query conditions include explicitly appearing entity conditions, location conditions, and time conditions. The candidate memory retrieval process may include: retrieving candidate memories associated with the current user query input from the long-term memory pool using a hybrid retrieval method including keyword retrieval and vector retrieval.
[0012] Optionally, the conditional constraint sorting process may include: performing conditional constraint sorting on the candidate memories based on the query conditions to obtain sorted candidate memories, wherein the conditional constraint sorting includes the degree of matching between the candidate memories and the current query conditions in terms of entity, location, and time. The reordering selection process may include: performing reordering based on the degree of answer matching between the current query conditions and the sorted candidate memories to obtain a first reordering result; determining a predetermined number of atomic memory units that rank first in the first reordering result as a predetermined number of atomic memory units associated with the current user query input.
[0013] In another general aspect, a query-aware graph-enhanced memory device for long-term dialogue agents is provided, comprising: a data acquisition module configured to receive historical user input and current user query input through multi-turn dialogue; a memory pool construction module configured to construct a long-term memory pool comprising multiple searchable and traceable atomic memory units based on the historical user dialogue input; a memory retrieval module configured to determine the working memory corresponding to the current user query input from the long-term memory pool by performing hybrid retrieval, event-constrained priority ranking, and memory reordering on the current user query input; a memory graph construction module configured to dynamically construct a local memory graph based solely on the working memory using a pre-trained graph encoder; a memory graph conversion module configured to convert the local memory graph into a graph memory representation recognizable by a predefined large language model using a pre-trained projector; and a response output module configured to input the graph memory representation, textual evidence in the working memory, and the current user query input into a predefined large language model to obtain the final answer corresponding to the current user query input.
[0014] Optionally, the plurality of atomic memory units may include memory content, source evidence, related entities, related locations, fact time, discourse time, and structured fact records, and each atomic memory unit may be constructed to store the corresponding source evidence in association with an independent fact, event, state, preference, plan, or task information.
[0015] Optionally, the operation of the memory pool construction module in constructing a long-term memory pool comprising multiple searchable and traceable atomic memory units based on the historical user dialogue input may include: segmenting the historical user dialogue input based on a sliding window, identifying facts, preferences, events, plans, requests, and state changes in the historical user dialogue input as multiple independently searchable and traceable atomic memory units, thereby constructing a long-term memory pool comprising the multiple atomic memory units.
[0016] Optionally, the memory retrieval module's operation of determining the working memory corresponding to the current user query input from the long-term memory pool by performing hybrid retrieval, event constraint priority sorting, and memory reordering on the current user query input may include: selecting a predetermined number of atomic memory units associated with the current user query input from the long-term memory pool by performing query condition parsing processing, candidate memory recall processing, condition constraint sorting processing, and reordering selection processing on the current user query input; and obtaining the current answer corresponding to the current user query input based on the predetermined number of atomic memory units, which serves as the working memory of the current answer corresponding to the current user query input.
[0017] Optionally, the memory graph construction module, through a pre-trained graph encoder, dynamically constructs a local memory graph based solely on the working memory. This operation may include: mapping people, organizations, items, locations, tasks, events, and / or states contained in the working memory to nodes in a first memory graph; mapping factual relationships, action relationships, subordinate relationships, temporal relationships, state update relationships, and / or evidence support relationships to edges between nodes; and using source evidence, factual time information, and discourse time information as additional attributes of nodes and / or edges; and encoding the nodes, edges, and their connections in the first memory graph using a pre-trained graph encoder to obtain a graph representation including structural information, which serves as the local memory graph.
[0018] Optionally, the query condition parsing process performed by the memory retrieval module may include: extracting query conditions from the current user query input, wherein the current query conditions include explicitly appearing entity conditions, location conditions, and time conditions. The candidate memory recall process performed by the memory retrieval module may include: recalling candidate memories associated with the current user query input from the long-term memory pool using a hybrid retrieval method including keyword retrieval and vector retrieval.
[0019] Optionally, the conditional constraint sorting process performed by the memory retrieval module may include: performing conditional constraint sorting on the candidate memories based on the query conditions to obtain sorted candidate memories, wherein the conditional constraint sorting includes the degree of matching between the candidate memories and the current query conditions in terms of entity, location, and time. The reordering selection process performed by the memory retrieval module may include: performing reordering based on the degree of answer matching between the current query conditions and the sorted candidate memories to obtain a first reordering result; determining a predetermined number of atomic memory units ranked first in the first reordering result as a predetermined number of atomic memory units associated with the current user query input.
[0020] In another general aspect, a computing device is provided, the computing device comprising: at least one processor; at least one memory storing computer-executable instructions, wherein, when executed by the at least one processor, the computer-executable instructions cause the at least one processor to perform the query-aware graph-enhanced memory method for long-term conversational agents as described above.
[0021] In another general aspect, a non-transitory computer-readable storage medium is provided, which stores a program or instructions that, when executed by a processor, cause the processor to perform the query-aware graph-enhanced memory method for long-term conversational agents as described above.
[0022] In another general aspect, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement the query-aware graph-enhanced memory method for long-term conversational agents as described above.
[0023] According to an embodiment of the present disclosure, a query-aware graph-enhanced memory method and apparatus for long-term dialogue agents can efficiently improve the accuracy of responses in scenarios such as fact recall, multi-evidence combination, temporal reasoning, state tracking, and information update processing by constructing a long-term memory pool, selecting query-aware working memory, constructing a local memory graph based on working memory, and generating a graph-text fusion process. Attached Figure Description
[0024] The above and other objects and features of the embodiments of this disclosure will become clearer from the following description taken in conjunction with the accompanying drawings illustrating the embodiments.
[0025] Figure 1 This is a flowchart illustrating a query-aware graph-enhanced memory method for long-term dialogue agents according to embodiments of the present disclosure.
[0026] Figure 2 This is a schematic diagram illustrating the overall framework of a query-aware graph-enhanced memory scheme for long-term dialogue agents according to embodiments of the present disclosure.
[0027] Figure 3 This is a graph showing the ablation performance of QGMem and the effect of parameter K sensitivity test according to an embodiment of the present disclosure.
[0028] Figure 4 This is a block diagram illustrating a query-aware graph enhancement memory device for a long-term dialogue agent according to an embodiment of the present disclosure.
[0029] Figure 5 This is a block diagram illustrating a computing device according to an embodiment of the present disclosure. Detailed Implementation
[0030] The following detailed embodiments are provided to aid the reader in gaining a comprehensive understanding of the methods, apparatus, and / or systems described herein. However, various changes, modifications, and equivalents of the methods, apparatus, and / or systems described herein will become apparent upon understanding this disclosure. For example, the order of operations described herein is merely illustrative and is not limited to those orders set forth herein, but may be changed as will become clear upon understanding this disclosure, except for operations that must occur in a specific order. Furthermore, for clarity and conciseness, descriptions of features known in the art may be omitted.
[0031] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings, examples of which are illustrated in the drawings, wherein the same reference numerals always refer to the same parts. The embodiments will now be described with reference to the accompanying drawings in order to explain this disclosure.
[0032] As mentioned above, based on the different ways of organizing and using memory, existing long-term conversational memory methods can be mainly divided into two categories: flat memory methods and graph-based memory methods. Typical methods of the former include flat memory methods such as MemoryBank, MemGPT, LongMem, FACT, and Mem0, while typical methods of the latter include graph-based memory methods such as SGMem and A-MEM.
[0033] The existing memory methods mentioned above have the following shortcomings: flat memory methods lack the ability to model explicit relationships and have difficulty handling long-term information updates; graph-based memory methods have high maintenance costs and the utilization of structured information is still insufficient.
[0034] Specifically, for example, flattened memory methods typically save historical dialogues as dialogue fragments, summary text, user facts, or independent memory entries. While these methods facilitate storage, retrieval, and updating, they often lack explicit representations of relationships between different memory entries, making it difficult to directly express entity associations, temporal order, state changes, and factual update relationships between historical information. In long-term dialogue scenarios, user preferences, task states, historical events, and subsequent updates are often scattered across multiple conversations. When a user's question requires synthesizing multiple pieces of historical evidence or determining whether a specific fact has been updated in subsequent conversations, it usually relies on a large language model to automatically recover implicit relationships from ordinary text. This can easily lead to problems such as missing evidence, confusion between old and new facts, incorrect entity referencing, and incomplete answers.
[0035] Furthermore, graph-based memory methods, for example, can represent relationships between historical information through nodes and edges, which helps enhance multi-hop reasoning, temporal reasoning, and state tracking capabilities. However, such methods typically require continuous extraction of entities, events, times, states, and relationships from long-term dialogues, as well as entity alignment, relationship updates, and graph structure maintenance. As the number of sessions and the scale of historical information increase, the number of nodes and edges in the graph structure also continues to grow. The construction, storage, updating, and traversal of the global graph introduce additional computational costs, increasing system complexity and engineering deployment costs. At the same time, the global graph usually contains a large number of nodes and edges that are irrelevant to the current problem. During node retrieval, path search, or subgraph extraction, weakly related relationships or irrelevant historical events can be introduced into the reasoning context, interfering with the large language model's judgment of key evidence. In addition, some existing methods typically convert the nodes, edges, triples, paths, or subgraph results in the graph into text before inputting them into the large language model. The connection relationships, path relationships, and local structural features in the graph structure still need to be re-parsed by the large language model at the text level, resulting in insufficient utilization of structured information during the generation stage.
[0036] Furthermore, existing retrieval mechanisms underutilize the constraints of the current query, easily recalling irrelevant or outdated memories. For example, existing long-term memory methods typically employ keyword retrieval, vector retrieval, or hybrid retrieval to recall historical information. Keyword retrieval can match proper nouns, dates, and explicit terms; vector retrieval can recall semantically similar content; and hybrid retrieval combines both to improve recall. However, in long-term dialogue scenarios, identical or semantically similar terms do not necessarily mean that the memory can support the answer to the current question. Multiple historical fragments may involve the same user, the same task, or the same location, but their occurrence time, state conditions, and factual validity are not the same. If the retrieval engine primarily ranks based on text similarity, it may input topic-related but mismatched historical information into the large language model. Especially in long-term interactions with multiple additions, modifications, or negations, old and new facts may be recalled simultaneously, causing the model to easily generate answers based on irrelevant or outdated memories.
[0037] To address the aforementioned and other problems in existing technologies, this disclosure proposes a query-aware graph-enhanced memory method (QGMem) and apparatus for long-term dialogue agents. First, long-term historical dialogues are constructed as atomic memory units containing memory content, source evidence, relevant entities, relevant locations, factual time, utterance time, and structured factual records, forming a searchable and traceable long-term memory pool. Then, for the current user query, working memory capable of supporting the current answer is selected from the long-term memory pool through hybrid retrieval, event-constrained priority ranking, and memory reordering. Finally, a local memory graph is dynamically constructed based solely on the working memory, and a graph encoder and projector convert the local memory graph into a graph memory representation usable by a large language model. This representation, along with textual evidence, is then input into the large language model to generate the answer. This disclosure's solution, through long-term memory pool construction, query-aware working memory selection, local memory graph construction based on working memory, and its graph-text fusion generation process, can efficiently utilize long-term historical information within a limited context window, effectively solving the aforementioned problems in long-term dialogue agents. Furthermore, the solution disclosed herein can improve the accuracy of responses from long-term dialogue agents in scenarios such as fact recall, multi-evidence combination, temporal reasoning, state tracking, and information update processing.
[0038] The following reference Figures 1 to 5 A detailed description of a query-aware graph enhancement memory method and apparatus for long-term dialogue agents according to embodiments of the present disclosure.
[0039] Reference Figures 1 to 3 A query-aware graph-enhanced memory method for long-term dialogue agents according to embodiments of the present disclosure is described in detail. Figure 1 This is a flowchart illustrating a query-aware graph-enhanced memory method 100 for a long-term dialogue agent according to an embodiment of the present disclosure. Figure 2 This is a schematic diagram illustrating the overall framework of a query-aware graph-enhanced memory scheme for long-term dialogue agents according to embodiments of the present disclosure. Here, the long-term dialogue memory enhancement framework of the present disclosure may include three parts: long-term memory pool construction, query-aware working memory selection, and graph enhancement generation based on local memory graphs.
[0040] Reference Figure 1 According to an embodiment of this disclosure, in step S101, historical user input and current user query input are received through a multi-turn dialogue.
[0041] According to an embodiment of this disclosure, in step S102, a long-term memory pool comprising multiple searchable and traceable atomic memory units is constructed based on historical user dialogue input.
[0042] For example, multiple atomic memory units may include memory content, source evidence, related entities, related locations, factual time, discourse time, and structured factual records, and each atomic memory unit may be constructed to store information about an independent fact, event, state, preference, plan, or task in association with the corresponding source evidence.
[0043] According to this disclosure, by constructing the long-term memory pool that includes multiple atomic memory units, it is possible to filter evidence that is more relevant to the question from long-term historical information based on the current user query, thereby reducing the interference of irrelevant historical information on the answering process.
[0044] Furthermore, by constructing a long-term memory pool to transform historical dialogues into fine-grained atomic memory units, by querying perceptual working memory to select and filter historical evidence related to the currently queried question, and by enhancing the generation process with a detailed local memory graph to explicitly utilize the relationship information between memories, it can more effectively support the combination of multiple evidences and the judgment of temporal relationships in long-term dialogue scenarios.
[0045] As an example, step S102 above may further include: segmenting historical user dialogue input based on a sliding window, identifying facts, preferences, events, plans, requests, and state changes in historical user dialogue input as multiple atomic memory units that can be independently retrieved and traced, thereby constructing a long-term memory pool including multiple atomic memory units.
[0046] According to this disclosure, the method can provide a stable explicit differentiation mechanism for conditions such as entity, location, time, and state changes, thereby solving the problem that existing models are prone to generating answers based on irrelevant or outdated memories.
[0047] As a concrete example, see [link / reference] Figure 2 This will illustrate the construction and related detailed applications of the long-term memory pool described above. (Refer to...) Figure 2 The leftmost blue background box represents the long-term memory pool construction, which can be divided into two phases: the dialogue segmentation phase and the atomic memory unit construction phase.
[0048] Here, the long-term memory pool can be used to store memory units extracted from historical dialogues, and each memory unit is built around an independent fact, event, state, preference, plan or task information, while retaining the corresponding source evidence.
[0049] Specifically, historical conversations can be entered via a sliding window, breaking down facts, preferences, events, plans, requests, and status changes into multiple independently searchable memory units. Each memory unit is built around a single fact or closely related event, avoiding the mixing of multiple unrelated facts in the same memory entry, thereby effectively reducing ambiguity in subsequent retrieval and reasoning processes.
[0050] By constructing the aforementioned long-term memory pool, it is possible to stably retrieve and utilize long-term historical information in subsequent processing. Furthermore, this long-term memory pool retains both readable content in natural language form and fields such as entities, locations, times, and structured facts that can be used for retrieval and reasoning, thus providing foundational data for subsequent query-aware memory selection and local graph construction.
[0051] Refer to the return Figure 1 According to an embodiment of this disclosure, in step S103, by performing a hybrid retrieval, event constraint priority sorting, and memory reordering on the current user query input, the working memory corresponding to the current answer to the current user query input is determined from the long-term memory pool.
[0052] As an example, step S103 above may further include the following steps S31 and S32: In step S31, a predetermined number of atomic memory units associated with the current user query input are selected from the long-term memory pool by performing query condition parsing processing, candidate memory recall processing, condition constraint sorting processing, and reordering selection processing on the current user query input.
[0053] For example, query condition parsing processing may include: extracting query conditions from the current user query input, which includes explicitly appearing entity conditions, location conditions, and time conditions.
[0054] For example, candidate memory retrieval processing may include: using a hybrid retrieval method that includes keyword retrieval and vector retrieval to retrieve candidate memories associated with the current user query input from the long-term memory pool.
[0055] For example, conditional constraint sorting processing may include: performing conditional constraint sorting on candidate memories based on query conditions to obtain sorted candidate memories. Conditional constraint sorting includes the degree of matching between candidate memories and current query conditions in terms of entity, location, and time.
[0056] For example, the reordering selection process may include: performing a reordering based on the degree of answer matching between the current query conditions and the sorted candidate memories to obtain a first reordering result; and determining a predetermined number of atomic memory units that rank first in the first reordering result as a predetermined number of atomic memory units associated with the current user query input.
[0057] According to this disclosure, the above four processing methods can not only improve the ability to recall facts in long conversations, but also improve the ability to utilize cross-conversation historical information, remember user preferences, perform temporal reasoning, and process knowledge updates.
[0058] In step S32, based on a predetermined number of atomic memory units, the current answer corresponding to the current user query input is obtained and used as the working memory of the current answer corresponding to the current user query input.
[0059] According to this disclosure, by comprehensively considering conditions such as entities, locations, and times in the current query when making memory selections, it is possible to effectively reduce the interference of irrelevant and outdated memories on answer generation.
[0060] Next, refer to again Figure 2 This will illustrate the relevant processing for query-aware working memory selection. (Refer to...) Figure 2 The query-aware working memory selection box with a green background in the middle can be divided into three stages: a mixed retrieval stage, a fact-constrained filtering stage, and a memory reordering stage.
[0061] Specifically, after a user submits a query, a limited number of memory units related to the current query can be selected from the long-term memory pool to form working memory. For example, this process includes four steps: query condition parsing, candidate memory retrieval, condition constraint sorting, and reordering selection.
[0062] First, regarding query condition parsing, this solution can parse the current user's query, extracting explicitly appearing entity, location, and time conditions. Entity conditions can include people, organizations, items, tasks, and / or other named objects; location conditions can include specific locations or spatial ranges; and time conditions can include specific dates, time periods, and relative time expressions such as "yesterday," "last week," or "most recent." For example, for relative time expressions, this solution can convert them into comparable time ranges based on the time the query occurred.
[0063] Secondly, regarding candidate memory recall, this solution employs a hybrid retrieval method to recall candidate memories from the long-term memory pool. Here, the hybrid retrieval includes keyword retrieval and vector retrieval, ensuring that the system can improve candidate memory recall while maintaining accurate matching capabilities.
[0064] Secondly, regarding conditional ranking, this solution can rank candidate memories based on query conditions. For example, it can determine the degree of matching between candidate memories and the current query in terms of entity, location, and time. Specifically, for entities and locations, this solution can combine exact matching, normalized matching, and semantic similarity matching to accommodate aliases, abbreviations, and approximate expressions; for time conditions, this solution can compare the time constraints in the query with the factual time in the memory unit to determine whether there is overlap or sequential relationship between the two.
[0065] Finally, regarding the reordering selection, this scheme uses a reorderer to reorder the candidate memories processed above. Here, the reorderer can re-score the candidate memories based on the degree of answer support between the current query and the candidate memories, obtaining the reordering result. Subsequently, this scheme can select the top several memory units from the reordering result to form the working memory set corresponding to the current query. Here, this working memory set is used for subsequent local memory graph construction and answer generation.
[0066] Through the aforementioned query-aware working memory selection mechanism, memory content that is more relevant to the current problem, better matches the conditions, and has stronger answer support can be filtered from a large amount of long-term historical information, effectively reducing the interference of irrelevant and outdated memories on the answers generated by the large language model.
[0067] Refer again Figure 1 According to an embodiment of this disclosure, in step S104, a local memory graph is dynamically constructed based solely on working memory using a pre-trained graph encoder.
[0068] Here, a graph encoder refers to a processing module used to convert nodes, edges, and their connections in a graph into vector representations.
[0069] As an example, step S104 above may further include steps S41 and S42: In step S41, the people, organizations, items, places, tasks, events and / or states contained in the working memory are mapped to nodes in the first memory graph, factual relationships, action relationships, subordinate relationships, temporal order relationships, state update relationships and / or evidence support relationships are mapped to edges between nodes, and source evidence, factual time information and discourse time information are added as additional attributes of nodes and / or edges.
[0070] In step S42, the nodes, edges and their connections in the first memory graph are encoded by a pre-trained graph encoder to obtain a graph representation including structural information, which serves as a local memory graph.
[0071] The memory graph structure disclosed herein can more intuitively express the relationships between different historical information, which is beneficial for supporting complex tasks such as multi-hop reasoning, temporal reasoning, state tracking, and factual conflict resolution. When answering user queries, relevant nodes, relationships, paths, or subgraphs can be retrieved from the local memory graph proposed in this disclosure and provided to the large language model as a basis for reasoning.
[0072] According to this disclosure, the local memory graph proposed in this disclosure can provide structured information such as entity relationships, event relationships, temporal order and state updates for large language models, thereby enhancing the ability of large language models to utilize the relationships between multiple pieces of historical evidence.
[0073] According to an embodiment of this disclosure, in step S105, the local memory graph is converted into a graph memory representation that can be recognized by a predefined large language model using a pre-trained projector.
[0074] Here, a projector refers to a processing module used to transform one vector representation into another vector space, so that the vectors output by different modules can be received and processed by subsequent modules.
[0075] Next, refer to again Figure 2 This section explains the relevant processing involved in generating local memory maps based on working memory. (Refer to...) Figure 2 The rightmost orange-background graph enhancement generation box can be divided into two stages: the memory subgraph construction stage and the graph-text fusion and generation stage.
[0076] As an example, after obtaining the working memory corresponding to the current query, this solution can construct a local memory graph based on the structured fact records in the working memory, and use the local memory graph to assist the large language model in generating answers.
[0077] Specifically, firstly, the people, organizations, items, places, tasks, events and / or states involved in working memory are mapped as nodes in a graph, and factual relationships, action relationships, subordinate relationships, temporal order relationships, state update relationships and / or evidence support relationships are mapped as edges between nodes, and information such as source evidence, factual time and discourse time are used as additional attributes of nodes or edges.
[0078] Subsequently, the nodes, edges and their connections in the local memory graph are encoded by a pre-trained graph encoder to obtain a graph representation containing structural information. This graph representation is then transformed into a vector space that can be received by a large language model by a pre-trained projector, forming a graph memory representation.
[0079] Refer back again Figure 1 According to an embodiment of this disclosure, in step S106, the graph memory representation, the textual evidence in working memory, and the current user query input are input into a predefined large language model to obtain the final answer corresponding to the current user query input.
[0080] exist Figure 2 In the example shown, during the answer generation stage, this scheme can input textual evidence from working memory, the current user query, and graph memory representation into a predefined large language model. This enables the model to utilize both textual content and structured relational information simultaneously, thereby more accurately completing multi-evidence combination, temporal reasoning, state tracking, and fact-updating judgments.
[0081] During the training phase, this approach can freeze the main parameters of the model and train only the graph encoder and projector, enabling them to learn to convert structural information in the local memory graph into a graph memory representation that helps generate the answer. During the inference phase, this approach can sequentially complete working memory selection, local memory graph construction, graph encoding, and answer generation, and output the final answer.
[0082] According to this disclosure, by selecting, organizing, and utilizing historical information in conjunction with the current query question, the large language model can obtain more effective historical evidence within a limited context window, thereby ensuring the quality of the corresponding answer.
[0083] Furthermore, the solution disclosed herein can address the problems in existing long-term dialogue memory methods, such as the lack of explicit relation modeling capabilities in flattened memory, insufficient utilization of constraints such as entity, location, and time in the current query by the retrieval mechanism, and the high maintenance cost of global graph structures and the ease with which irrelevant structural noise can be introduced.
[0084] Next, refer to Tables 1 and 2 below, and Figure 3 The beneficial effects of the proposed solution will be explained in detail below. Table 1 is a performance comparison table between the QGMem of this disclosure and existing methods on the LoCoMo dataset. Table 2 is a performance comparison table between the QGMem of this disclosure and existing methods on the LongMemEval-S dataset. Figure 3 This is a graph showing the ablation performance of QGMem and the effect of parameter K sensitivity test according to an embodiment of the present disclosure.
[0085] Specifically, referring to Tables 1 and 2, the two tables experimentally validate the scheme of this disclosure and other existing methods on long-term dialogue memory question-and-answer tasks.
[0086] Table 1
[0087] As shown in Table 1, the LoCoMo dataset used in Table 1 includes different types of problems such as multi-hop, temporal, open-domain, and single-hop problems, which can comprehensively evaluate the ability of long-term dialogue agents to retrieve, combine, and reason about historical information. According to the experimental results, when using different large language models such as Qwen3-8B, GPT-4o-mini, and Llama3.1-8B as backbone models, the proposed solution achieves superior performance, especially in multi-hop and temporal problems.
[0088] The experimental results above show that the proposed solution transforms historical dialogues into fine-grained atomic memory units by constructing a long-term memory pool, selects and filters historical evidence related to the current issue by querying perceptual working memory, and explicitly utilizes the relationship information between memories through local memory graph enhancement of the generation process. This approach can more effectively support the combination of multiple evidences and the judgment of temporal relationships in long-term dialogue scenarios.
[0089] Table 2
[0090] As shown in Table 2, the LongMemEval-S dataset used in Table 2 covers long-term memory capabilities such as single-session user information, user preferences, assistant information, multi-session reasoning, temporal reasoning, and knowledge updating. Based on the experimental results, the proposed solution achieves good performance across multiple dimensions of long-term memory capabilities.
[0091] The experimental results above show that the proposed solution can not only improve the ability to recall facts in long conversations, but also improve the ability to utilize cross-conversation historical information, remember user preferences, reason about time, and process knowledge updates.
[0092] Therefore, the solution disclosed herein can effectively improve the accuracy of responses and memory utilization of long-term dialogue agents in complex historical interaction scenarios.
[0093] Next, refer to Figure 3 Furthermore, the effectiveness of each component of the disclosed scheme was verified through ablation experiments and working memory quantity analysis.
[0094] Specifically, such as Figure 3 The ablation experiment results shown are as follows: (1) When the query-aware working memory selection mechanism is removed, the system performance drops significantly. This indicates that it is difficult to stably select historical memories that can support the current answer by relying solely on ordinary retrieval. However, the memory selection method of this disclosure, which combines the entity, location, and time conditions in the current query, can effectively reduce the interference of irrelevant and expired memories on the generation of the answer. (2) When the atomic memory unit is replaced with a coarser-grained memory fragment, the system performance also drops. This indicates that fine-grained memory construction can reduce retrieval ambiguity caused by multiple facts and help locate time-sensitive facts and state update information. (3) When the local graph enhancement information is removed, the system performance drops in multi-hop problems, time problems, and information update-related problems. This indicates that the local memory graph can provide structured information such as entity relationships, event relationships, time sequence, and state updates for the large language model, thereby enhancing its ability to utilize the relationships between multiple historical evidences.
[0095] In addition, such as Figure 3The analysis of working memory counts further demonstrates that when the number of memories entering the generation stage is too small, the system is prone to missing crucial evidence; when the number of memories is too large, irrelevant or weakly related memories increase contextual noise, affecting the quality of answer generation. Under the experimental settings, an appropriate Top-K (representing the optimal K) number of working memories can achieve a good balance between evidence coverage and contextual noise.
[0096] The above results indicate that the three components of the disclosed scheme—long-term memory pool construction, query-aware working memory selection, and local graph enhancement generation—all make substantial contributions to the final performance. Moreover, the performance improvement is not achieved by simply increasing the input context, but by improving the effectiveness of long-term dialogue question answering through more refined memory organization, selection, and structured utilization.
[0097] Next, refer to Figure 4 This invention describes a query-aware graph enhancement memory apparatus for long-term dialogue agents according to embodiments of the present disclosure.
[0098] Figure 4 This is a block diagram illustrating a query-aware graph enhancement memory device 400 for a long-term dialogue agent according to an embodiment of the present disclosure.
[0099] Reference Figure 4 According to embodiments of the present disclosure, a query-aware graph enhancement memory device 400 for long-term dialogue agents may include a data acquisition module 410, a memory pool construction module 420, a memory retrieval module 430, a memory graph construction module 440, a memory graph conversion module 450, and a response output module 460.
[0100] Specifically, according to embodiments of this disclosure, the data acquisition module 410 can perform the following: receiving historical user input and current user query input through multi-turn dialogue.
[0101] According to embodiments of this disclosure, the memory pool construction module 420 can perform the following: based on historical user dialogue input, construct a long-term memory pool comprising a plurality of searchable and traceable atomic memory units.
[0102] For example, multiple atomic memory units may include memory content, source evidence, related entities, related locations, factual time, discourse time, and structured factual records, and each atomic memory unit may be constructed to store information about an independent fact, event, state, preference, plan, or task in association with the corresponding source evidence.
[0103] As an example, the above-mentioned operations performed by the memory pool construction module 420 may further include: segmenting historical user dialogue input based on a sliding window, identifying facts, preferences, events, plans, requests, and state changes in historical user dialogue input as multiple atomic memory units that can be independently retrieved and traced, thereby constructing a long-term memory pool including multiple atomic memory units.
[0104] According to embodiments of this disclosure, the memory retrieval module 430 can perform the following: by performing a hybrid retrieval, event constraint priority sorting, and memory reordering on the current user query input, determine the working memory corresponding to the current answer in the long-term memory pool.
[0105] As an example, the above-mentioned operations performed by the memory retrieval module 430 may further include the following operations 431) and 432). In operation 431, a predetermined number of atomic memory units associated with the current user query input are selected from the long-term memory pool by performing query condition parsing processing, candidate memory recall processing, condition constraint sorting processing, and reordering selection processing on the current user query input.
[0106] For example, the query condition parsing process performed by the memory retrieval module 430 may include: extracting query conditions from the current user query input, whereby the current query conditions include explicitly appearing entity conditions, location conditions, and time conditions. The candidate memory recall process performed by the memory retrieval module 430 may include: recalling candidate memories associated with the current user query input from the long-term memory pool using a hybrid retrieval method that includes keyword retrieval and vector retrieval.
[0107] Furthermore, the conditional constraint sorting process performed by the memory retrieval module 430 may include: performing conditional constraint sorting on candidate memories based on query conditions to obtain sorted candidate memories, wherein the conditional constraint sorting includes the degree of matching between candidate memories and current query conditions in terms of entity, location, and time. The reordering selection process performed by the memory retrieval module 430 may include: performing reordering based on the degree of answer matching between current query conditions and sorted candidate memories to obtain a first reordering result; determining a predetermined number of atomic memory units at the top of the first reordering result as a predetermined number of atomic memory units associated with the current user query input.
[0108] In operation 432, based on a predetermined number of atomic memory units, the current answer corresponding to the current user query input is obtained and used as the working memory of the current answer corresponding to the current user query input.
[0109] According to embodiments of this disclosure, the memory graph construction module 440 can perform the following: dynamically construct a local memory graph based solely on working memory using a pre-trained graph encoder.
[0110] As an example, the above operations performed by the memory graph construction module 440 may further include the following operations 441) and 442). In operation 441), people, organizations, items, places, tasks, events and / or states contained in working memory are mapped to nodes in the first memory map, factual relationships, action relationships, subordinate relationships, temporal order relationships, state update relationships and / or evidence support relationships are mapped to edges between nodes, and source evidence, factual time information and discourse time information are added as additional attributes of nodes and / or edges.
[0111] In operation 442), the nodes, edges and their connections in the first memory graph are encoded by a pre-trained graph encoder to obtain a graph representation including structural information, which serves as a local memory graph.
[0112] According to embodiments of this disclosure, the memory graph conversion module 450 can perform the following: converting a local memory graph into a graph memory representation that can be recognized by a predefined large language model using a pre-trained projector.
[0113] According to an embodiment of this disclosure, the response output module 460 can perform the following: input the graph memory representation, textual evidence in working memory, and the current user query input into a predefined large language model to obtain a final answer corresponding to the current user query input.
[0114] It should be noted that the operations performed on the above structural frames can be compared with those in the reference section. Figure 1 The related content is similar, so I will not repeat it here.
[0115] Figure 5 This is a block diagram illustrating a computing device 500 according to an embodiment of the present disclosure.
[0116] Reference Figure 5 The computing device 500 according to embodiments of the present disclosure may include at least one processor 510 and at least one memory 520. The processor 510 may include (but is not limited to) a central processing unit (CPU), a digital signal processor (DSP), a microcomputer, a field-programmable gate array (FPGA), a system-on-a-chip (SoC), a microprocessor, an application-specific integrated circuit (ASIC), etc. The memory 520 may store computer-executable instructions to be executed by the processor 510. The memory 520 includes high-speed random access memory and / or a non-volatile computer-readable storage medium. When the processor 510 executes the computer-executable instructions stored in the memory 520, the query-aware graph enhancement memory method for long-term conversational agents described above can be implemented.
[0117] The query-aware graph enhancement memory method for long-term dialogue agents according to embodiments of this disclosure can be written as a computer program / instructions to form a computer program product and stored on a computer-readable storage medium. When the computer program / instructions are executed by a processor, the query-aware graph enhancement memory method for long-term dialogue agents as described above can be implemented. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device / server, the electronic device / server is enabled to perform the query-aware graph enhancement memory method for long-term dialogue agents as described above.
[0118] Examples of computer-readable storage media include: read-only memory (ROM), random access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-RLT. H, BD-RE, Blu-ray or optical disc storage, hard disk drive (HDD), solid-state drive (SSD), card storage (such as multimedia cards, secure digital (SD) cards, or ultra-fast digital (XD) cards), magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid-state drive, and any other device configured to store computer programs and any associated data, data files, and data structures in a non-transitory manner and to provide computer programs and any associated data, data files, and data structures to a processor or computer so that the processor or computer can execute the computer programs, but not limited thereto.
[0119] In one example, the computer program, along with any associated data, data files, and data structures, is distributed across a networked computer system, allowing the computer program, along with any associated data, data files, and data structures, to be stored, accessed, and executed in a distributed manner via one or more processors or computers.
[0120] According to an embodiment of this disclosure, a query-aware graph-enhanced memory method and apparatus for long-term dialogue agents is proposed. This method and apparatus combine fine-grained long-term memory construction, query-aware working memory selection, and local graph enhancement generation to improve the ability of fact recall, multi-evidence combination, temporal reasoning, and information update processing in long-term dialogue question answering.
[0121] On the other hand, the scheme disclosed herein is applicable to, but not limited to, long-term dialogue agents, which store a collection of information such as historical interaction information, user preferences, facts, events, relationships, and state changes during multi-turn, multi-session interactions.
[0122] While some embodiments of this disclosure have been disclosed and described, those skilled in the art will understand that modifications and variations may be made to these embodiments without departing from the concept and spirit of this disclosure, which is defined by the claims and their equivalents.
Claims
1. A query-aware graph-enhanced memory method for long-term dialogue agents, characterized in that, The query-aware-map-enhanced memory method includes: It uses multi-turn dialogue to receive input from historical users and query input from the current user; Based on the historical user dialogue input, a long-term memory pool is constructed, comprising multiple searchable and traceable atomic memory units. By performing hybrid retrieval, event-constrained priority sorting, and memory reordering on the current user query input, the working memory corresponding to the current answer to the current user query input is determined from the long-term memory pool; Local memory graphs are dynamically constructed based solely on the working memory using a pre-trained graph encoder. The local memory graph is converted into a graph memory representation that can be recognized by a predefined large language model using a pre-trained projector. The graph memory representation, the textual evidence in the working memory, and the current user query input are input into a predefined large language model to obtain the final answer corresponding to the current user query input.
2. The query-aware graph-enhanced memory method according to claim 1, characterized in that, The multiple atomic memory units include memory content, source evidence, related entities, related locations, factual time, discourse time, and structured factual records. Each atomic memory unit is constructed to store information about an independent fact, event, state, preference, plan, or task in association with the corresponding source evidence.
3. The query-aware graph-enhanced memory method according to claim 1, characterized in that, The step of constructing a long-term memory pool comprising multiple searchable and traceable atomic memory units based on the historical user dialogue input includes: By segmenting the historical user dialogue input based on a sliding window, the facts, preferences, events, plans, requests, and state changes in the historical user dialogue input are identified as multiple atomic memory units that can be independently retrieved and traced, thereby constructing a long-term memory pool including the multiple atomic memory units.
4. The query-aware graph-enhanced memory method according to claim 1, characterized in that, The step of determining the working memory corresponding to the current user query input from the long-term memory pool by performing hybrid retrieval, event-constrained priority sorting, and memory reordering on the current user query input includes: By performing query condition parsing, candidate memory recall, condition constraint sorting, and reordering selection on the current user query input, a predetermined number of atomic memory units associated with the current user query input are selected from the long-term memory pool. Based on the predetermined number of atomic memory units, the current answer corresponding to the current user query input is obtained and used as the working memory of the current answer corresponding to the current user query input.
5. The query-aware graph-enhanced memory method according to claim 1, characterized in that, The step of dynamically constructing a local memory graph based solely on the working memory using a pre-trained graph encoder includes: The people, organizations, items, places, tasks, events and / or states contained in the working memory are mapped to nodes in the first memory graph. Factual relationships, action relationships, subordinate relationships, temporal order relationships, state update relationships and / or evidence support relationships are mapped to edges between nodes. Source evidence, factual time information and discourse time information are used as additional attributes of nodes and / or edges. The nodes, edges, and their connections in the first memory graph are encoded by a pre-trained graph encoder to obtain a graph representation including structural information, which serves as a local memory graph.
6. The query-aware graph-enhanced memory method according to claim 4, characterized in that, The query condition parsing process includes: The query conditions are extracted from the current user query input. These current query conditions include explicitly stated entity conditions, location conditions, and time conditions. The candidate memory retrieval process includes: using a hybrid retrieval method that includes keyword retrieval and vector retrieval to retrieve candidate memories associated with the current user query input from the long-term memory pool.
7. The query-aware graph-enhanced memory method according to claim 6, characterized in that, The conditional constraint sorting process includes: Based on the query conditions, the candidate memories are sorted according to conditional constraints to obtain sorted candidate memories. The conditional constraints ranking includes the degree of matching between the candidate memories and the current query conditions in terms of entity, location, and time. The reordering selection process includes: Based on the degree of answer matching between the current query conditions and the sorted candidate memories, a re-sorting is performed to obtain the first re-sorting result; A predetermined number of atomic memory units are determined at the top of the first sorting result, as the predetermined number of atomic memory units associated with the current user query input.
8. A query-aware graph enhancement memory device for long-term dialogue agents, characterized in that, The query-aware graph enhancement memory device includes: The data acquisition module is configured to receive historical user input and current user query input through multi-turn dialogue; The memory pool construction module is configured to: construct a long-term memory pool comprising multiple searchable and traceable atomic memory units based on the historical user dialogue input; The memory retrieval module is configured to: determine the working memory of the current answer corresponding to the current user query input from the long-term memory pool by performing a hybrid retrieval, event-constrained priority sorting, and memory reordering on the current user query input; The memory graph construction module is configured to dynamically construct local memory graphs based solely on the working memory using a pre-trained graph encoder. The memory graph conversion module is configured to convert the local memory graph into a graph memory representation that can be recognized by a predefined large language model through a pre-trained projector. The response output module is configured to input the graph memory representation, the textual evidence in the working memory, and the current user query input into a predefined large language model to obtain the final answer corresponding to the current user query input.
9. A computing device, characterized in that, include: At least one processor; At least one memory that stores computer-executable instructions. The computer-executable instructions, when executed by the at least one processor, cause the at least one processor to perform the query-aware graph-enhanced memory method for long-term dialogue agents as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores a program or instructions that, when executed by a processor, cause the processor to perform the query-aware graph-enhanced memory method for long-term conversational agents as described in any one of claims 1 to 7.
