A Multi-Level Main Graph Memorization Method for Large Models

By employing a multi-level mainline graph memory method, the semantic information of the task is organized using a directed graph structure. This solves the memory decay and mainline deviation problems of large language models in complex multi-turn dialogue tasks, achieves logical coherence and information consistency in the dialogue, and improves the performance and reliability of the model.

CN120911571BActive Publication Date: 2026-01-06QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511439495.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-10
Publication Date
2026-01-06
Estimated Expiration
2045-10-10

AI Technical Summary

Technical Problem

Large language models suffer from memory decay, main line deviation, and lack of contextual consistency in complex multi-turn dialogue tasks, especially in long-duration or multi-step tasks where it is difficult to maintain the continuity of the task main line and historical information.

Method used

A multi-level mainline graph memory method is adopted, which organizes task semantic information through a directed graph structure, constructs a multi-level mainline strategy, automatically creates nodes and updates the graph, constructs dependency edges and acceleration strategies, generates structured prompts and context injection mechanisms, and performs automatic maintenance and lifecycle management of the graph structure.

Benefits of technology

It improves the performance and reliability of large language models in complex multi-turn dialogue tasks, maintains the consistency of the main task line, and enhances the logical coherence and accuracy of the dialogue.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120911571B_ABST
    Figure CN120911571B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of artificial intelligence, and in particular provides a multi-level mainline graph memory method for a large model. The method comprises the following steps: designing a memory graph to organize task semantic information in a dialogue in a directed graph structure; constructing a multi-level mainline strategy; automatically creating a node and updating a graph; constructing a dependent edge and an acceleration strategy; generating a structured prompt and a context injection mechanism; and automatically maintaining a graph structure and managing a life cycle. The method solves the key problems of memory decay, mainline deviation and context consistency loss of a large language model in a complex multi-turn dialogue task, and improves the performance and reliability of the large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a multi-level principal graph memorization method for large models. Background Technology

[0002] In recent years, with the rapid development of large language models (LLMs) such as GPT, ChatGPT, and Claude, significant progress has been made in natural language understanding and generation, multi-turn dialogue systems, intelligent question answering, and code generation. Multi-turn dialogue systems based on large language models can engage in complex interactions with users, demonstrating broad application prospects in education, customer service, programming assistants, and research assistants, greatly enhancing the intelligence level and practical value of artificial intelligence systems in supporting complex tasks. However, when faced with complex tasks requiring long-term interaction or multi-step completion, such as system development, project planning, and multi-stage problem solving, existing large language models still face serious memory decay and task focus deviation problems. These problems are prevalent in current open-domain question answering, programming guidance, and research collaboration dialogue systems, and have become one of the key bottlenecks hindering the in-depth application of large models. Specifically, these problems can be summarized in the following three points:

[0003] First, there's the issue of forgetting early task information. During long dialogues, the model easily overlooks or forgets important variables, constraints, or explicit task objectives defined by the user in the initial input. For example, in round 5, the user might emphasize that the backend must use the FastAPI framework or specify that model fine-tuning should use the LoRA method, but in round 15, the model might use conflicting implementations like Flask or full-parameter fine-tuning. This forgetting stems not only from context length limitations but, more fundamentally, from the model's lack of a long-term structured memory mechanism.

[0004] Secondly, there's the issue of task deviation. During dialogue, the model often gets distracted by non-core details, causing the conversation to gradually deviate from the original task's main focus. For example, when completing the third stage of a five-stage task, the model might suddenly start processing content related to the fifth stage, or turn to discussing issues outside the task, such as optimization suggestions or unsolicited extensions, resulting in process interruptions or logical confusion. The root cause of this problem is that the model fails to establish a structured representation of task stage awareness or the current execution position within the context, leading to a lack of core constraints during decision generation.

[0005] Finally, there is a lack of structured long-term memory mechanisms. Current mainstream dialogue systems generally use linear text concatenation to maintain contextual information, simulating memory states by piecing together historical turns into prompt words for the input model. While this approach works reasonably well in short-turn dialogues, it shows significant limitations when handling complex information requiring execution paths, task stages, and conditional dependencies. For example, a user might temporarily insert branching operations during a task, such as modifying settings, viewing logs, or adjusting hyperparameters, but linear text cannot clearly express the relationship between these branches and the task, ultimately leading to memory confusion and failed logical transitions.

[0006] To alleviate these problems, some studies have attempted to introduce memory enhancement mechanisms such as summary memory, retrieval-enhanced generation (RAG), memory trees, reflection mechanisms, and knowledge graphs. For example, LongChat (2023) introduced a dialogue summarization module and a task attention marking mechanism to help the model reduce mainline deviation by explicitly recording user goals and intermediate summaries; MemGPT (2023) constructed a working memory-long-term memory system that simulates the human memory process, with memory reading and writing controlled by a proxy model, but its memory structure is still a linear text fragment; GraphRAG (2023) attempted to introduce knowledge graphs into retrieval-enhanced generation, finding the most relevant subgraph to the user query through graph traversal and retrieval, and feeding it into the language model as context. Although the graph structure allows it to explicitly represent entity relationships and perform accurate matching, it does not combine task stages or state control, making it unable to model the stage states, dependencies, and context evolution processes in the dialogue task process; LTM-LLM (2024) proposed a reflective long-term memory management framework that supports periodic review of historical content to dynamically generate summary memories, but lacks task state modeling. In addition to the methods mentioned above, some projects have introduced knowledge graphs into large model memory with good results. For example, Zep, AriGraph, and A-MEM unify dynamic events and stable knowledge in the graph structure through semantic / episodic layering, dual temporal modeling, or self-evolving memory graphs, thereby achieving accurate retrieval and causal reasoning across sessions and time. GoT transforms the reasoning process itself into graph search and fusion, enabling the model to flexibly switch, backtrack, and merge between multiple paths and multiple pieces of evidence, improving the solution rate of complex tasks. KELP, Injecting KG, and GLAME, through path selection, graph label injection, and knowledge editing mechanisms oriented towards consistency propagation, make LLM more accurate and efficient in utilizing external knowledge, and can maintain the consistency and generalization ability of internal reasoning after fact updates. While these methods improve dialogue continuity and historical consistency to some extent, they share the following common shortcomings: First, they lack the ability to model multi-level stages and sub-goals of the main task, making it impossible to represent the hierarchical structure and stage evolution of the task. Second, the memory structure is usually organized in chronological order, making it difficult to express the conditional dependencies and stage transitions between task nodes. Third, the identification of the current task stage relies on contextual reasoning, lacks explicit modeling and control mechanisms, and the generated response is difficult to accurately correspond to the current execution goal. Summary of the Invention

[0007] In view of this, the present invention provides a multi-level mainline graph memory method for large models, which solves the key problems of memory decay, mainline deviation and lack of context consistency in large language models in complex multi-turn dialogue tasks, thereby improving the performance and reliability of large language models.

[0008] In a first aspect, the present invention provides a multi-level mainline graph memorization method for large models, the method comprising:

[0009] Step 1: Design a memory graph to organize the task semantic information in the dialogue using a directed graph structure;

[0010] Step 2: Based on Step 1, construct a multi-level main strategy;

[0011] Step 3: Based on Step 2, perform automatic node creation and graph update;

[0012] Step 4: Using the methods from Step 3, construct dependency edges and acceleration strategies;

[0013] Step 5: Based on Step 4, generate structured hints and a context injection mechanism;

[0014] Step 6: Based on Step 5, perform automatic maintenance and lifecycle management of the graph structure.

[0015] Optionally, step 1 includes:

[0016] Organizing task semantic information in a dialogue using a directed graph structure is defined as follows:

[0017] ;

[0018] in, It is a set of nodes, including task nodes, stage nodes, step nodes, variable nodes, constraint nodes, and operation nodes; A set of directed edges with type. It is a collection of edge types, including mainline edges, containing edges, and variable-dependent edges;

[0019] Task nodes represent Level 1 nodes (L1), used to represent the overall goal proposed by the user; Stage nodes represent Level 2 nodes (L2), used to represent sub-goals within the task that have a temporal or logical order; Step nodes represent Level 3 nodes (L3), used to represent the actual steps performed in a stage; Variable nodes, Constraint nodes, and Operation nodes all represent Level 4 nodes (L4). Variable nodes represent important variables, paths, or parameter settings that are frequently referenced; Constraint nodes express the restrictive conditions for model generation behavior; Operation nodes represent behavioral instructions with actual execution significance; each history node... The semantic representation is obtained through vector encoding, defined as:

[0020] ;

[0021] in, It is a sentence vector encoder used for semantic similarity calculation and dependency reasoning.

[0022] Optionally, step 2 includes:

[0023] The complex intent is decomposed layer by layer into a nested hierarchy of task nodes L1, stage nodes L2, step nodes L3, and variable nodes, constraint nodes, and operation nodes L4, as shown below:

[0024] ;

[0025] By incorporating edges and main lines, a multi-level master-slave structure is formed. Task nodes serve as top-level nodes, representing the global goal; stage nodes serve as mid-level nodes, representing stage goals; step nodes serve as bottom-level nodes, representing specific steps; and any node can serve as a new task node to further divide subtasks, forming a complete graph structure.

[0026] Optionally, step 3 includes:

[0027] When natural language is input, the following operations are automatically performed: First, it is determined whether the input introduces a new task objective or operation step; the input content is automatically parsed, node content is constructed and inserted into the graph structure; the main line connection direction is determined according to the multi-level main line strategy; and the main line path, stage number and graph structure metadata are automatically updated.

[0028] Optionally, step 4 includes:

[0029] In multi-turn dialogues, the new questions or task steps proposed at the moment depend on information from nodes in previous turns. To maintain the logical coherence and task consistency of the dialogue, dependency edges are constructed to enable explicit semantic references from the current node to historical nodes. A dependency edge is a non-linear, non-hierarchical reference relationship edge, and its expression is as follows:

[0030] ;

[0031] It represents the current node. Refer to historical nodes when generating content or executing logic. Information in the middle; This indicates that the edge type is a dependent edge;

[0032] A three-level acceleration strategy is adopted to gradually narrow down the candidate set:

[0033] The first level is time window and hierarchical path filtering. The principle is based on the fact that recent history is more relevant in real-world dialogue scenarios, introducing time window and path consistency constraints. Let the round number of the current dialogue or task be r, and only the following candidate nodes are retained, expressed as follows:

[0034] ;

[0035] in, This represents the set of candidate nodes obtained after time window and path filtering. This represents the nodes that have been processed in the previous k dialogues; express The generation round in which it occurs; w represents the size of the time window, i.e., the dialogue round. Indicates the current node; This represents the path from the first k iterations; Indicates the current path; This indicates that task paths intersect to ensure semantic context relevance; the time window w is set to 5~10 rounds, and a floating window is used for long dialogues.

[0036] The second-level semantic vector retrieval works by analyzing each historical node. Encoding using a sentence vector model, its representation is as follows:

[0037] ;

[0038] Then calculate the current node. With historical nodes The semantic similarity is expressed as follows:

[0039] ;

[0040] in, Represents each current node Encoding is performed using a sentence vector model; if Then Nodes that can be relied upon =0.75~0.9; Using FAISS to build a vector index supports real-time search, with a complexity of approximately ;

[0041] The third level of reference frequency and activity filtering works by maintaining a set of frequently referenced or highly active nodes in the system's reference frequency pool. Its form of expression is:

[0042] ;

[0043] in, This indicates that other nodes reference the node. The number of times; Indicates the citation threshold;

[0044] Based on the above three-level acceleration strategy, a final set of candidate nodes is established, and dependency edges are constructed using this final set of candidate nodes, defined as follows:

[0045] ;

[0046] in, This represents the set of candidate nodes obtained after time window and path filtering. Represents the citation frequency pool; This represents the candidate set selected based on semantic similarity.

[0047] The system in the candidate set Perform high similarity ranking, i.e., from the candidate set In the middle, according to the current node The semantic and task relevance are ranked to ensure that the most relevant information is used to establish dependencies first; references are classified into variable references, constraint references, and structural references according to their type; based on the semantic content and contextual relationship of each dependency candidate node, its reference type in the current context is determined so as to perform semantic annotation on the dependency edges; dependency edge establishment and annotation: in the structured graph, dependency edges are explicitly established ( , (and label its dependency type and credibility, for use in retrieval, context focusing, and generation control.)

[0048] Optionally, step 5 includes:

[0049] The structured prompt generation and context injection mechanism constructs prompt words based on a multi-level dialogue control strategy; when generating a response, it is based on the current node. The path context is calculated as follows:

[0050] ;

[0051] in, Indicates the current node All parent nodes; Indicates the current node All dependent nodes; Indicates the current node The union of all parent nodes and all dependent nodes.

[0052] Optionally, step 6 includes:

[0053] When a correction instruction is given in a subsequent dialogue, the semantic intent will be automatically parsed, the target step node that needs to be modified will be identified, the original node will be deleted and a new node will be added, the main line edge and dependency edge related to the new node will be updated synchronously, and the system will maintain the creation time, state change and source path of all nodes in the graph, supporting the tracking, rollback and dependency reconstruction of the task structure.

[0054] In a second aspect, embodiments of the present invention provide a computer-readable storage medium comprising a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute the multi-level mainline graph memory method for large models in the first aspect or any possible implementation thereof.

[0055] Thirdly, embodiments of the present invention provide an electronic device, including: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the multi-level mainline graph memory method for large models in the first aspect or any possible implementation of the first aspect.

[0056] The technical solution provided by this invention includes a method that designs a memory graph to organize the task semantic information in the dialogue using a directed graph structure; constructs a multi-level main line strategy; performs automatic node creation and graph updates; constructs dependency edges and acceleration strategies; generates structured prompts and a context injection mechanism; and performs automatic graph structure maintenance and lifecycle management. This method solves the key problems of memory decay, main line shift, and lack of context consistency in large language models in complex multi-turn dialogue tasks, thereby improving the performance and reliability of large language models. Attached Figure Description

[0057] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0058] Figure 1 A flowchart of a multi-level mainline graph memory method for large models provided in an embodiment of the present invention;

[0059] Figure 2 A schematic diagram illustrating a tourism planning task example provided in an embodiment of the present invention;

[0060] Figure 3 A schematic diagram of a multi-level mainline strategy provided in an embodiment of the present invention;

[0061] Figure 4 This is a schematic diagram of the construction dependency edges provided in an embodiment of the present invention;

[0062] Figure 5 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0063] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0064] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0065] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” used in the embodiments of this invention are also intended to include the plural forms unless the context clearly indicates otherwise.

[0066] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0067] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0068] Figure 1 The flowchart of the multi-level principal graph memory method for large models provided in the embodiments of the present invention is as follows: Figure 1 As shown, the method includes:

[0069] The core technology of this invention lies in explicitly modeling task objectives, stage processes, variable constraints, user preferences, and their multi-level semantic dependencies in multi-turn dialogues using graph structures. This constructs a structured memory mechanism that supports long-term memory, main task retention, stage tracking, and context reuse, thereby solving key problems in existing large language models such as memory decay, main task deviation, and lack of context consistency in complex dialogue tasks. For example, a user requests the model to plan a recommended five-day trip to Beijing, specifying locations along subway lines, a budget of around 5000 yuan, and suitability for seniors. The model will then invoke a multi-level main task memory graph to construct the multi-level main task memory graph based on the user's requirements.

[0070] In embodiments of the present invention, such as Figure 2 As shown, planning a travel itinerary is a first-level node (L1) or task node in a multi-level main line; considering special needs, arranging daily itineraries, and arranging accommodation and transportation are stage tasks, which are second-level nodes (L2) or stage nodes in the multi-level main line; the arrangements for the first day, the second day, searching for subway hotels, and comparing prices are specific steps, which are third-level nodes (L3) or step nodes in the multi-level main line; subway lines, senior-friendly facilities, the Forbidden City, acrobatic performances, calling the map API, and a total budget of 5000 yuan are implementation details or constraints of the steps, which are fourth-level nodes (L4) or variable nodes or constraint nodes in the multi-level main line; for example... Figure 3 As shown, a multi-level graph structure of a typical task is illustrated. The task node (green) contains multiple stage nodes (orange-yellow), and each stage contains step nodes (sky blue) and related variable, constraint, and operation nodes (pink). Figure 3 Different types of nodes are connected by main line advancement edges (directed edges), inclusion edges (thin dashed lines), and dependency edges (thick dashed lines), forming the structural backbone and semantic relationships of the task. Except for the fourth-level node L4, other levels all have a main line structure, which is formed by directed edges. It represents the direction of the model's progress and the dependency constraints for completing the current project.

[0071] In subsequent dialogues, the multi-level mainline will focus on task nodes based on task status to extract subgraphs, construct model context, and provide structured contextual information to the model, discarding redundant information and retaining key information to the greatest extent. The model will complete this task according to the multi-level mainline graph structure. When the user raises new requirements, the graph memory system will automatically perform operations such as adding, deleting, modifying, and querying nodes to achieve a structured memory mechanism for maintaining and updating the mainline task, tracking stages, and reusing context.

[0072] Step 1: Design a memory graph to organize the task semantic information in the dialogue using a directed graph structure.

[0073] In this embodiment of the invention, step 1 includes:

[0074] Organizing task semantic information in a dialogue using a directed graph structure is defined as follows:

[0075] ;

[0076] in, It is a set of nodes, including task nodes, stage nodes, step nodes, variable nodes, constraint nodes, and operation nodes; A set of directed edges with type. It is a collection of edge types, including mainline edges, containing edges, and variable-dependent edges;

[0077] Task nodes represent Level 1 nodes (L1), used to represent the overall goal proposed by the user; Stage nodes represent Level 2 nodes (L2), used to represent sub-goals within the task that have a temporal or logical order; Step nodes represent Level 3 nodes (L3), used to represent the actual steps performed in a stage; Variable nodes, Constraint nodes, and Operation nodes all represent Level 4 nodes (L4). Variable nodes represent important variables, paths, or parameter settings that are frequently referenced; Constraint nodes express the restrictive conditions for model generation behavior, such as the requirement to use FastAPI; Operation nodes represent behavioral instructions with actual execution significance, such as defining a POST interface; each history node... The semantic representation is obtained through vector encoding, defined as:

[0078] ;

[0079] in, It is a sentence vector encoder used for semantic similarity calculation and dependency reasoning.

[0080] Step 2: Based on Step 1, construct a multi-level main strategy.

[0081] In this embodiment of the invention, step 2 includes:

[0082] The complex intent is decomposed layer by layer into a nested hierarchy of task nodes L1, stage nodes L2, step nodes L3, and variable nodes, constraint nodes, and operation nodes L4, as shown below:

[0083] ;

[0084] By incorporating edges and main lines, a multi-level master-slave structure is formed. Task nodes serve as top-level nodes, representing global goals, such as building a fine-tuning system; stage nodes serve as mid-level nodes, representing stage goals, such as data preparation and model configuration; step nodes serve as bottom-level nodes, representing specific steps, such as using LoRA and loading FastAPI; and any node can serve as a new task node to further divide into subtasks, forming a complete graph structure.

[0085] Step 3: Based on Step 2, perform automatic node creation and graph update.

[0086] In this embodiment of the invention, step 3 includes:

[0087] Upon input of natural language, the following operations are automatically performed: First, it is determined whether the input introduces new task objectives or operation steps; the input content is automatically parsed, node content is constructed and inserted into the graph structure; the direction of main line connection is determined according to the multi-level main line strategy; the main line path, stage number and graph structure metadata are automatically updated, relying on edge construction without user intervention in maintenance.

[0088] Step 4: Using the methods from Step 3, construct dependency edges and acceleration strategies.

[0089] In this embodiment of the invention, step 4 includes:

[0090] In multi-turn dialogues, the new problem or task steps proposed at the moment rely on information from nodes in previous turns, such as variable definitions, preconditions, constraints, and model selections. To maintain the logical coherence and task consistency of the dialogue, dependency edges are constructed to enable explicit semantic references between the current node and historical nodes. A dependency edge is a non-linear, non-hierarchical reference relationship edge, expressed as follows:

[0091] ;

[0092] It represents the current node. Refer to historical nodes when generating content or executing logic. Information in the middle; This indicates that the edge type is a dependent edge;

[0093] The introduction of dependency edges enables the reuse of information such as variables, constraints, methods, and paradigms; ensures the consistency and traceability of model-generated output; supports cross-stage calls between non-parent-child nodes in the graph structure; and implements explicit memory tracking for continuous access by subsequent dialogue models.

[0094] Since the number of nodes in the graph structure increases as the dialogue progresses, directly traversing the entire graph to establish dependency edges is inefficient. Therefore, a three-level acceleration strategy is adopted to gradually narrow down the candidate set:

[0095] The first level is the Window & Path Filter, which is based on the principle that recent history is more relevant in real-world dialogue scenarios, and introduces time window and path consistency constraints. Let the round number of the current dialogue or task be r, and only the following candidate nodes are retained, expressed as follows:

[0096] ;

[0097] in, This represents the set of candidate nodes obtained after time window and path filtering. This represents the nodes that have been processed in the previous k dialogues; express The generation round in which it occurs; w represents the size of the time window, i.e., the dialogue round. Indicates the current node; This represents the path from the first k iterations; Indicates the current path; This indicates that task paths intersect to ensure semantic context relevance; the time window w is set to 5~10 rounds, and a floating window is used for long dialogues.

[0098] The second-level semantic vector retrieval (Semantic Embedding Retrieval) works by analyzing each historical node. Encoding using a sentence vector model, its representation is as follows:

[0099] ;

[0100] Then calculate the current node. With historical nodes The semantic similarity is expressed as follows:

[0101] ;

[0102] in, Represents each current node Encoding is performed using a sentence vector model; if Then Nodes that can be relied upon =0.75~0.9; Using FAISS to build a vector index supports real-time search, with a complexity of approximately ;

[0103] The third level of reference frequency and activity filtering (Reference Pool) works by maintaining a set of frequently referenced or highly active nodes. This set filters low-quality, low-reference nodes, performing dependency matching only on knowledge-intensive nodes. Its form of expression is:

[0104] ;

[0105] in, This indicates that other nodes reference the node. The number of times; This indicates the citation threshold, which defaults to 2-3 times.

[0106] Based on the above three-level acceleration strategy, a final set of candidate nodes is established, and dependency edges are constructed using this final set of candidate nodes, defined as follows:

[0107] ;

[0108] in, This represents the set of candidate nodes obtained after time window and path filtering. Represents the citation frequency pool; This represents the candidate set selected based on semantic similarity.

[0109] The system in the candidate set Perform high similarity ranking, i.e., from the candidate set In the middle, according to the current node The semantic and task relevance are ranked to ensure that the most relevant information is used to establish dependencies first; references are classified into variable references, constraint references, and structural references according to their type; based on the semantic content and contextual relationship of each dependency candidate node, its reference type in the current context is determined so as to perform semantic annotation on the dependency edges; dependency edge establishment and annotation: in the structured graph, dependency edges are explicitly established ( , (and label its dependency type and credibility, for use in retrieval, context focusing, and generation control.)

[0110] In embodiments of the present invention, such as Figure 4 As shown, in a multi-level mainline graph memory system, the automatic construction process of dependency edges when a new node is created is illustrated. This process is triggered internally by the system, and users do not need to explicitly label dependencies. When a user submits a new task request or supplementary instruction, the system identifies the new node that needs to be added. The system performs semantic analysis on the new node, extracting key entities such as variable names, keywords, model configurations, and path references that may be involved. Based on the extracted information, a candidate dependency node pool is constructed in the historical graph using a three-level acceleration strategy. For each node in the candidate node pool, the system evaluates its semantic relevance to the new node through methods such as embedding vector similarity calculation, keyword matching, or language model-assisted judgment, generating a score. The system selects the final set of dependency target nodes based on the relevance score and a preset threshold (e.g., Score > 0.75), and automatically constructs dependency edges based on the target node set.

[0111] Step 5: Based on step 4, generate structured hints and a context injection mechanism.

[0112] Current mainstream models do not possess memory capabilities like humans; they do not actively store previous conversation content, nor do they naturally recall past information in subsequent interactions. Their core logic for achieving continuous dialogue is precisely through constructing and carrying context. In each round of dialogue, the model integrates historical conversation content—including the user's questions, the model's responses, and the current new input—as a complete input sequence for processing.

[0113] In this embodiment of the invention, step 5 includes:

[0114] The structured prompt generation and context injection mechanism utilizes a multi-level dialogue control strategy to construct the most valuable prompt words; when generating a response, it is based on the current node. The path context is calculated as follows:

[0115] ;

[0116] in, Indicates the current node All parent nodes; Indicates the current node All dependent nodes; Indicates the current node The union of all parent nodes and all dependent nodes.

[0117] The system automatically from Key summaries are extracted and injected into the prompt model to ensure that the response is consistent with the main thread, coherent in behavior, and consistent in preference, thereby minimizing catastrophic forgetting and deviation from the main task thread.

[0118] This strategy focuses only on building prompts for the current stage's main storyline and the dependent nodes of the current node. The prompts are then concatenated with the user input and injected into the context of the large language model, thereby improving the model's responsiveness and accuracy.

[0119] Step 6: Based on Step 5, perform automatic maintenance and lifecycle management of the graph structure.

[0120] In this embodiment of the invention, step 6 includes:

[0121] like Figure 2As shown, when a correction instruction is given in a subsequent dialogue, such as "I don't want to go to the Forbidden City, I want to go to the Summer Palace instead," the semantic intent will be automatically parsed, the target step node that needs to be modified will be identified, the original node will be deleted and a new node will be added, and the main line edge and dependency edge related to the new node will be updated synchronously to ensure the consistency of the main task path and dependency relationship. At the same time, the system maintains the creation time, state change and source path of all nodes in the graph, supports the tracking, rollback and dependency reconstruction of the task structure, and ensures the consistency and controllability of the task in complex multi-round interactions.

[0122] This invention organizes dialogue history and task status through a graph structure, constructs a dialogue graph, and realizes long-term memory management, mainline consistency tracking, and structured response generation control, fundamentally improving the performance and reliability of large language models in complex multi-turn task dialogues.

[0123] The technical solution provided by this invention includes a method that designs a memory graph to organize the task semantic information in the dialogue using a directed graph structure; constructs a multi-level main line strategy; performs automatic node creation and graph updates; constructs dependency edges and acceleration strategies; generates structured prompts and a context injection mechanism; and performs automatic graph structure maintenance and lifecycle management. This method solves the key problems of memory decay, main line shift, and lack of context consistency in large language models in complex multi-turn dialogue tasks, thereby improving the performance and reliability of large language models.

[0124] The various steps in the embodiments of the present invention can be performed by an electronic device. This electronic device includes, but is not limited to, tablet computers, portable PCs, and desktop computers.

[0125] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is running, it controls the electronic device containing the computer-readable storage medium to execute the above-described embodiment of the multi-level mainline graph memory method for large models.

[0126] Figure 5 A schematic diagram of an electronic device provided in an embodiment of the present invention, such as... Figure 5 As shown, the electronic device 21 includes a processor 211, a memory 212, and a computer program 213 stored in the memory 212 and executable on the processor 211. When the computer program 213 is executed by the processor 211, it implements the multi-level mainline graph memory method for large models in the embodiment. To avoid repetition, it will not be described in detail here.

[0127] Electronic device 21 includes, but is not limited to, processor 211 and memory 212. Those skilled in the art will understand that... Figure 5This is merely an example of electronic device 21 and does not constitute a limitation on electronic device 21. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.

[0128] The processor 211 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0129] The memory 212 can be an internal storage unit of the electronic device 21, such as a hard disk or RAM of the electronic device 21. The memory 212 can also be an external storage device of the electronic device 21, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or FlashCard equipped on the electronic device 21. Furthermore, the memory 212 can include both internal and external storage units of the electronic device 21. The memory 212 is used to store computer programs and other programs and data required by network devices. The memory 212 can also be used to temporarily store data that has been output or will be output.

[0130] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0131] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A multi-level mainline graph memory method for large models, characterized in that, The method comprises: Step 1, design a memory graph to organize task semantic information in a dialogue in a directed graph structure; Step 2, according to step 1, build a multi-level mainline strategy; Step 3, based on step 2, automatically create nodes and update the graph; Step 4, using step 3, build dependent edges and acceleration strategies; Step 5, based on step 4, generate structured prompts and context injection mechanisms; Step 6, according to step 5, automatically maintain the graph structure and manage the life cycle; The step 1 comprises: Organizing task semantic information in a dialogue in a directed graph structure is defined as: ; wherein, is a set of nodes, including task nodes, stage nodes, step nodes, variable nodes, constraint nodes and operation nodes; is a set of directed edges of type, is a set of edge types, including mainline edges, containment edges, variable dependency edges; The task node represents a first level node L1, and is used to represent the overall goal proposed by the user; the stage node represents a second level node L2, and is used to represent the sub-goals in the task with time or logical sequence; the step node represents a third level node L3, and is used to represent the actual steps in the stage; the variable node, the constraint node and the operation node all represent a fourth level node L4, the variable node is used to represent the important variable, path or parameter setting repeatedly cited, the constraint node is used to express the restrictive condition of the model generation behavior, and the operation node is used to represent the behavior instruction with actual execution significance; the semantic representation of each history node is obtained by vector coding, and is defined as: ; wherein, is a sentence vector encoder for semantic similarity computation and dependency reasoning; The step 2 comprises: The complex intent is decomposed into task nodes L1, stage nodes L2, step nodes L3, and variable nodes, constraint nodes, and operation nodes L4 in a nested hierarchical representation as follows: ; Promote through containing edges and mainline edges to form a multi-level master-slave structure, with task nodes as top-level nodes representing global goals; stage nodes as middle-level nodes representing stage goals; step nodes as bottom-level nodes representing specific steps; and any node can continue to divide sub-tasks as a new task node, forming a complete graph structure; The step 3 comprises: After inputting natural language, the following operations are automatically performed: first, determine whether the input introduces a new task target or operation step; automatically parse the input content, construct node content, and insert it into the graph structure; determine the mainline connection direction according to the multi-level mainline strategy; automatically update the mainline path, stage number, and graph structure metadata; The step 4 comprises: In multi-round dialogues, the newly proposed questions or task steps depend on the information of the nodes in the historical rounds; in order to maintain the logical coherence and task consistency of the dialogue, a dependent edge is constructed to realize the explicit semantic reference of the current node to the historical node; the dependent edge is a nonlinear, non-hierarchical reference relationship edge, and its expression form is: ; which indicates the current node At the time of content generation or logic execution, reference is made to the information in the history node The type of the edge is a dependency edge.​ A three-level acceleration strategy is adopted to gradually narrow down the candidate set: The first level is time window and hierarchical path filtering, which is based on the principle that recent history is more relevant in real dialogue scenarios, and introduces time window and path consistency restrictions; let the round number of the current dialogue or task be r, only the following candidate nodes are retained, and its expression form is: ; wherein, represents the candidate node set obtained after the time window and path filtering; represents the node operated by the previous k dialogues; represents the generation round in which the node is located; w represents the time window size, i.e., the dialogue round; represents the current node; represents the previous k paths; represents the current path; represents the intersection of the task paths to ensure semantic context relevance; the time window w is set to 5-10 rounds, and is set to a floating window for long dialogues; The second level semantic vector retrieval is based on the principle of encoding each historical node The sentence vector model is used for encoding, and its expression form is: ; Then calculate the semantic similarity of the current node with the historical nodes , which is expressed as: ; wherein, represents each current node is encoded using sentence vector model; if , then is considered as a node that can be relied on, = 0.75~0.9; using FAISS to establish vector index supports real-time search, and the complexity is approximately ; The third level of reference frequency and activity filtering works on the principle that the system maintains a set of frequently referenced or highly active nodes collection, the reference frequency pool The expression form is: ; wherein, represents the number of times the other node references the node . represents a reference threshold value; Based on the above three-level acceleration strategy, the final candidate node set is established, and the dependent edge is constructed through the final candidate node set, defined as: ; wherein, represents a candidate node set obtained after time window and path filtering; represents a pool of citation frequencies; represents a candidate set screened by semantic similarity; The system performs high similarity ranking in the candidate set , i.e. from the candidate set , according to the semantic relevance and task relevance of the current node , to ensure that the most relevant information is established first; according to the reference type classification, variable reference, constraint reference, structure reference, according to the semantic content and context relationship of each dependent candidate node, judge its reference type in the current context, so as to carry out semantic annotation on the dependency edge; dependency edge establishment and annotation, in the structured graph, the dependency edge is established explicitly (dependency edge , ), and its dependency type and credibility are annotated, which is used for retrieval, context focusing and generation control.

2. The method of claim 1, wherein, The step 5 comprises: The structured prompt generation and context injection mechanism constructs a prompt word according to a multi-level strategy of dialogue control; when generating a response, the current node is determined based on the current node The path context is calculated in the following manner: ; wherein, represents all parent nodes of the current node ; represents all dependent nodes of the current node ; represents the union of all parent nodes and all dependent nodes of the current node .

3. The method of claim 2, wherein, The step 6 comprises: When a correction instruction is proposed in the subsequent dialogue, the semantic intent is automatically parsed, the target step node to be modified is identified, the original node is deleted and a new node is added, the mainline edge and the dependent edge related to the new node are updated, and the system maintains the creation time, state change, and source path of all nodes in the graph, supporting task structure tracking, rollback, and dependent reconstruction.

4. A computer-readable storage medium, characterized in that, The computer-readable storage medium comprises a stored program, wherein when the program runs, it controls the device where the computer-readable storage medium is located to perform the multi-level mainline graph memory method for large models according to any one of claims 1-3.

5. An electronic device, comprising: Comprise: One or more processors; Memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs including instructions, which when executed by the device, cause the device to perform the large model oriented multi-level mainline graph memory method of any one of claims 1 to 3.

Citation Information

Patent Citations

  • Memory retrieval method for enhancing multi-modal long-context dialogue ability of large language model

    CN119293139A

  • Large language model reasoning method based on time sequence difference learning and rule enhancement

    CN120409667A