Large-model-oriented multi-level main line diagram memory method

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

CN120911571AActive Publication Date: 2025-11-07QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +1

Patent Information

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

AI Technical Summary

Technical Problem

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

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 task's main line and contextual coherence, and reduces memory decay and main line deviation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120911571A_ABST
    Figure CN120911571A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and particularly provides a multi-level main line diagram memory method for a large model. The method comprises the following steps: designing a memory graph, and organizing task semantic information in a dialogue by a directed graph structure; constructing a multi-level main line strategy; automatically creating nodes and updating the graph; constructing a dependency edge and an acceleration strategy; generating a structured prompt and context injection mechanism; according to the method, the key problems of memory decline, main line offset and context consistency deficiency of the large language model in complex multi-round dialogue tasks are solved, and the performance and reliability of the large language model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and particularly relates to a multi-level mainline graph memory method for large models. BACKGROUND

[0002] In recent years, with the rapid development of large language models (LLM) such as GPT, ChatGPT, Claude, etc., they have made significant progress in natural language understanding and generation, multi-turn dialogue systems, intelligent question answering, code generation, etc. Multi-turn dialogue systems based on large language models can interact with users in complex ways and have broad application prospects in education, customer service, programming assistants, research assistants, etc., greatly improving the intelligence level and practical value of artificial intelligence systems in complex task support. However, when faced with complex tasks that require 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 mainline 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, the following three points can be summarized: Firstly, forgetting early task information. In a long-turn dialogue process, the model tends to ignore or forget important variables defined by the user in the early input, set constraints or explicit task goals. For example, the user emphasizes in the 5th round of dialogue that the backend must use the FastAPI framework, or specifies that the model fine-tuning needs to use the LoRA method, but in the 15th round of the model's generated solution, it uses Flask or full-parameter fine-tuning, which conflicts with the implementation. This forgetting not only results from the limitation of context length, but also fundamentally due to the lack of long-term structured memory mechanism in the model.

[0003] Secondly, mainline task deviation. The model is often attracted by non-core details during the dialogue process, causing the dialogue to gradually deviate from the original task mainline. For example, in the third stage of a five-stage task, the model may suddenly start processing the fifth stage-related content, or turn to discuss issues outside the task such as optimization suggestions, non-requested expansion solutions, etc., causing process interruption or logical confusion. The root cause of this problem is that the model fails to establish a structured representation of task stage awareness or current execution position in the context, resulting in a lack of mainline constraints when generating decisions.

[0004] Finally, there is a lack of structured long-term memory mechanism. Current mainstream dialogue systems generally use linear text concatenation to maintain context information, simulating memory states by concatenating historical turns as prompt inputs into the model. While this approach may work well in short-turn dialogues, it has obvious limitations when dealing with complex structures such as execution paths, task stages, and conditional dependencies. For example, a user may temporarily insert certain branch operations such as modifying settings, viewing logs, or adjusting hyperparameters during a task. However, linear text cannot clearly express the relationship between these branches and the task, ultimately leading to memory confusion and logic jump failures.

[0005] To alleviate these problems, some researches have attempted to introduce summary memory mechanisms, retrieval-augmented generation (RAG), memory trees, reflection mechanisms, knowledge graphs, and other enhanced memory methods. For example, LongChat (2023) introduced a dialogue summary module and a task focus marking mechanism, explicitly recording user goals and intermediate summaries to help the model reduce main line deviation; MemGPT (2023) constructed a working memory-long-term memory system simulating the human memory process, with an agent model controlling memory reading and writing, but its memory structure is still linear text segments; GraphRAG (2023) attempted to introduce a knowledge graph in retrieval-augmented generation, finding the most relevant subgraph to user queries through graph traversal and retrieval, and feeding it into the language model as context. Although using a graph structure allows explicit representation of entity relationships and precise matching, it does not incorporate task phases or state control, making it unable to model stage status, dependency relationships, and context evolution processes in dialogue task processes; LTM-LLM (2024) proposed a reflection-based 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 above methods, some projects have introduced knowledge graphs into large model memories and achieved good results. For example, Zep, AriGraph, and A-MEM unified dynamic events and stable knowledge in a graph structure through semantic / episode hierarchical modeling, dual-time modeling, or self-evolving memory graphs, enabling precise retrieval and causal reasoning across sessions and time; GoT transformed the reasoning process itself into graph search and fusion, allowing the model to flexibly switch, backtrack, and merge between multiple paths and multiple evidence, improving the solution rate of complex tasks; KELP, Injecting KG, and GLAME used path selection, graph label injection, and consistency propagation-oriented knowledge editing mechanisms to make LLMs more accurate and efficient when utilizing external knowledge, while maintaining internal reasoning consistency and generalization ability after fact updates. These methods have improved dialogue continuity and historical consistency to some extent, but have the following common deficiencies: first, they lack multi-level modeling capabilities for task main line stages and sub-goals, making it difficult to represent the hierarchical structure and stage evolution of tasks; second, memory structures are usually organized in chronological order, making it difficult to express conditional dependencies and stage jumps between task nodes; third, the identification of the current task stage relies on context reasoning, lacking explicit modeling and control mechanisms, making it difficult to accurately correspond to the current execution goal when generating responses. SUMMARY

[0006] Therefore, the present application provides a multi-level main line graph memory method for large models to solve the key problems of memory decay, main line deviation, and context consistency loss in complex multi-turn dialogue tasks for large language models, and to improve the performance and reliability of large language models.

[0007] In a first aspect, the present application provides a multi-level mainline graph memory method for large models, comprising: 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, construct a multi-level mainline strategy; Step 3, based on step 2, perform node automatic creation and graph update; Step 4, using step 3, construct dependent edges and acceleration strategies; Step 5, based on step 4, generate structured prompts and context injection mechanisms; Step 6, according to step 5, perform automatic maintenance of graph structure and life cycle management.

[0008] Optionally, the step 1 comprises: Organizing task semantic information in a dialogue in a directed graph structure is defined as: ; wherein, is a node set, including task nodes, stage nodes, step nodes, variable nodes, constraint nodes and operation nodes; is a directed edge set with type, is an edge type set, including mainline edges, containing edges, variable dependent edges; The task node represents a first-level node L1, which is used to represent the overall goal proposed by the user; the stage node represents a second-level node L2, which is used to represent the sub-goal with time or logical sequence in the task; the step node represents a third-level node L3, which is used to represent the actual step of 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 an important variable, path or parameter setting that is repeatedly referred to, 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 historical node is obtained by vector encoding, defined as: ; wherein, is a sentence vector encoder, used for semantic similarity calculation and dependency reasoning.

[0009] Optionally, the step 2 comprises: The complex intent is decomposed into a nested hierarchical representation of task nodes L1, stage nodes L2, step nodes L3, and variable nodes, constraint nodes and operation nodes L4 as follows: ; The task node is as a top node, representing a global target; the stage node is as a middle node, representing a stage target; and the step node is as a bottom node, representing a specific step. Any node can be used as a new task node to continue to divide sub-tasks, forming a complete graph structure.

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

[0011] Optionally, the step 4 comprises: In the multi-round dialogue, the newly proposed question or task step depends on the information of the nodes in the historical rounds. In order to maintain the logical coherence and task consistency of the dialogue, a dependency edge is constructed to realize the explicit semantic reference of the current node to the historical node. The dependency edge is a non-linear and non-hierarchical reference relationship edge, and its expression form is: ; which represents the current node refers to the information in the historical node when generating content or executing logic; , and the type of the edge is a dependency edge. A three-level acceleration strategy is adopted to gradually reduce the candidate set: The first level is the time window and hierarchical path filtering. The principle is based on the principle that the recent history is more relevant in the real dialogue scene, and the time window and path consistency restriction are introduced. Let the round number of the current dialogue or task be r, only the following candidate nodes are retained, and the expression form is: ; wherein represents the candidate node set obtained after the time window and path filtering; represents the node operated in the previous k dialogues; represents the generation round in which is located; w represents the time window size, i.e. the dialogue round; represents the current node; represents the path of the previous k times; 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 the floating window is set for long dialogues; The second level is semantic vector retrieval. The principle is that for each historical node The sentence vector model is used for encoding, and its expression form is: ; Then, the semantic similarity of the current node and the historical node is calculated, and its expression form is: ; Wherein, Each current node is encoded using a sentence vector model; if , the node is regarded as a node that can be relied on, =0.75~0.9; the vector index is established using FAISS to support real-time search, and the complexity is approximately ; The third-level frequency of citation and activity filtering is based on the principle that the system maintains a set of frequently cited or highly active nodes, and the frequency of citation pool Its expression form is: ; Wherein, The number of times that other nodes reference node ; Reference threshold; Based on the above-mentioned three-level acceleration strategy, the final candidate node set is established, and the dependent edge is constructed through the final candidate node set, which is defined as: ; Wherein, Indicates the candidate node set obtained after time window and path filtering; Indicates the frequency of citation pool; Indicates the candidate set screened out by semantic similarity; The system performs high similarity sorting in the candidate set , that is, 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. The reference type is classified into variable reference, constraint reference and structure reference according to the semantic content and context relationship of each dependent candidate node in the current context, so as to perform semantic annotation on the dependent edge; the dependent edge is established and annotated, and in the structured graph, the dependent edge is explicitly established , ), and its dependent type and credibility are labeled, which are used for retrieval, context focusing and generation control.

[0012] Optionally, 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 The path context is calculated as follows: ; 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 .

[0013] Optionally, the step 6 comprises: When a correction instruction is proposed in the subsequent dialogue, the semantic intention is automatically parsed, the target step node to be modified is identified, the original node is deleted and a new node is added, the main line edge and the dependent edge related to the new node are updated synchronously, and the system maintains the creation time, state change and source path of all nodes in the graph, supporting tracking, rollback and dependent reconstruction of the task structure.

[0014] In a second aspect, an embodiment of the present application provides a computer readable storage medium, the computer readable storage medium comprising a stored program, wherein the program controls the device where the computer readable storage medium is located to execute the multi-level main line graph memory method for large models in the first aspect or any possible implementation manner of the first aspect when the program is running.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising: 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 comprise instructions that, when executed by the device, cause the device to execute the multi-level main line graph memory method for large models in the first aspect or any possible implementation manner of the first aspect.

[0016] The technical solution provided by the present application comprises designing a memory graph to organize task semantic information in a dialogue in a directed graph structure; constructing a multi-level main line strategy; automatically creating nodes and updating the graph; constructing dependent edges and acceleration strategies; generating a structured prompt and a context injection mechanism; and automatically maintaining the graph structure and managing the life cycle, which solves the key problems of memory decay, main line deviation and context consistency loss of large language models in complex multi-round dialogue tasks, and improves the performance and reliability of large language models. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and all other drawings obtained by those of ordinary skill in the art without creative effort based on these drawings also belong to the protection scope of the present application.

[0018] Figure 1 A flowchart of the multi-level mainline graph memory method for large models provided by the embodiments of the present application is shown in FIG. 1. Figure 2 A schematic diagram of a tourism planning task example provided by the embodiments of the present application is shown in FIG. 2. Figure 3 A schematic diagram of a multi-level mainline strategy provided by the embodiments of the present application is shown in FIG. 3. Figure 4 A schematic diagram of constructing a dependent edge provided by the embodiments of the present application is shown in FIG. 4. Figure 5 A schematic diagram of an electronic device provided by the embodiments of the present application is shown in FIG. 5. DETAILED DESCRIPTION

[0019] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the protection scope of the present application.

[0020] It should be clear that the described embodiments are only some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the protection scope of the present application.

[0021] The terms used in the embodiments of the present application are only for the purpose of describing the specific embodiments, and are not intended to limit the present application. The singular forms "a", "an" and "the" used in the embodiments of the present application are also intended to include the plural forms, unless the context clearly indicates otherwise.

[0022] It should be understood that the term "and / or" used herein is only to describe the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. In addition, the character " / " in this paper generally represents that the front and rear associated objects are a "or" relationship.

[0023] Depending on context, the word "if" as used herein can be interpreted to mean "when" or "while" or "in response to determining" or "in response to detecting." Similarly, depending on context, the phrase "if it is determined" or "if [a stated condition or event] is detected" can be interpreted to mean "when it is determined" or "in response to determining" or "when [a stated condition or event] is detected" or "in response to detecting [a stated condition or event]."

[0024] Figure 1 A flowchart of a multi-level mainline graph memory method for large models provided for embodiments of the present application is shown in Figure 1 The method includes: The core technology of the present application is to explicitly model the task target, stage process, variable constraint, user preference and their multi-level semantic dependency relationship in multi-round dialogue through graph structure, and to construct a structured memory mechanism supporting long-term memory, mainline task maintenance, stage tracking and context reuse, thereby solving the key problems of memory decay, mainline deviation and context consistency loss existing in the current large language model in complex dialogue tasks. For example, the user requires the model to plan a five-day tour recommendation strategy in Beijing, and requires to be along the subway line, with a budget of about 5000 yuan, and friendly to the elderly. The model will call the multi-level mainline memory graph to construct a multi-level mainline memory graph of the tourism task according to the user's demand.

[0025] In embodiments of the present application, as shown in Figure 2 Planning a travel strategy is a task in a one-level node L1 in the multi-level mainline, that is, a task node; considering special requirements, arranging daily itinerary, and arranging accommodation and transportation are stage tasks, which are two-level nodes L2 in the multi-level mainline, that is, stage nodes; the first day arrangement, the second day arrangement, searching for subway hotels, and price comparison are specific steps, which are three-level nodes L3 in the multi-level mainline, that is, step nodes, and the subway line, the elderly-friendly, the Forbidden City, acrobatic performance, calling the map API, and the total budget of 5000 yuan are implementation details or constraint conditions of the steps, which are four-level nodes L4 in the multi-level mainline, that is, variable nodes or constraint nodes; as shown in Figure 3 A multi-level graph structure of a typical task is shown. 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 in the middle are connected by mainline promotion edges (directed edges), containing edges (thin dotted lines), and dependency edges (thick dotted lines) to form the structural backbone and semantic association of the task. In addition to the four-level nodes L4, other levels have a mainline structure, which is formed by directed edges, which represents the promotion direction and dependency constraints of the model to complete the current project.

[0026] In the subsequent dialogue, the multi-level main line focuses on the task node extraction subgraph according to the task state, constructs the model context, provides structured context information for the model, discards redundant information, and maximizes the retention of key information. The model will complete this task according to the multi-level main line graph structure, and when the user proposes new requirements, the graph memory system will automatically perform operations such as adding, deleting, modifying and searching on the nodes to realize the structured memory mechanism of main line task maintenance and update, stage tracking and context reuse.

[0027] Step 1, design a memory graph to organize task semantic information in the dialogue in a directed graph structure.

[0028] In the embodiment of the application, step 1 includes: Organizing task semantic information in the dialogue in a directed graph structure is defined as: ; Wherein, is a node set, including task nodes, stage nodes, step nodes, variable nodes, constraint nodes and operation nodes; is a directed edge set with type, is an edge type set, including main line edges, containing edges, variable dependency edges; The task node represents a first-level node L1, which is used to represent the overall goal proposed by the user; the stage node represents a second-level node L2, which is used to represent the sub-goal with time or logical order in the task; the step node represents a third-level node L3, which is used to represent the actual step of 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 referred to, the constraint node is used to express the restrictive condition of the model generation behavior, such as must use FastAPI, and the operation node is used to represent the behavior instruction with actual execution significance, such as defining the POST interface; the semantic representation of each historical node is obtained by vector encoding, defined as: ; Wherein, is a sentence vector encoder, which is used for semantic similarity calculation and dependency reasoning.

[0029] Step 2, according to step 1, construct a multi-level main line strategy.

[0030] In the embodiment of the application, step 2 includes: The complex intent is decomposed into the nested hierarchical representation of task nodes L1, stage nodes L2, step nodes L3 and variable nodes, constraint nodes and operation nodes L4 as follows: ; By containing the edge and the main line edge, a multi-level master-slave structure is formed, the task node is as a top node, representing the global target, such as constructing a fine-tuning system, the stage node is as a middle node, representing the stage target, such as data preparation and model configuration, and the step node is as a bottom node, representing the specific step, such as using LoRA and loading FastAPI, and any node can continue to divide sub-tasks as a new task node, forming a complete graph structure.

[0031] Step 3, based on step 2, node automatic creation and graph update are performed.

[0032] In the embodiment of the application, step 3 comprises: When the natural language is input, the following operations are automatically performed: firstly, it is judged whether the input introduces a new task target or an operation step; the input content is automatically parsed, the 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; the main line path, stage number and graph structure metadata are automatically updated, without user participation in maintenance and relying on the construction of the edge.

[0033] Step 4, using step 3, a dependency edge and an acceleration strategy are constructed.

[0034] In the embodiment of the application, step 4 comprises: In the multi-round dialogue, the newly proposed question or task step depends on the information of the nodes in the historical rounds, such as variable definition, pre-operation, constraint condition and model selection; in order to maintain the logical coherence and task consistency of the dialogue, a dependency edge is constructed to realize the explicit semantic reference of the current node to the historical node; the dependency edge is a nonlinear and non-hierarchical reference relationship edge, and its expression form is: ; which represents the current node refers to the information in the historical node ; , and the type of the edge is a dependency edge. The introduction of the dependency edge has the reuse of variable, constraint, method and paradigm information; guarantees the consistency and traceability of the model generation output; supports the cross-stage calling between non-parent and child nodes in the graph structure; realizes the explicit memory tracking for the subsequent dialogue model continuous access.

[0035] Since the number of nodes in the graph structure increases with the dialogue advancement, direct full-graph traversal to establish the dependency edge is inefficient, and a three-level acceleration strategy is adopted to gradually reduce the candidate set: The first level is a time window and hierarchical path filter (Window & Path Filter). The principle is to introduce time window and path consistency restrictions based on the principle that recent history is more relevant in real dialogue scenarios. Let the round number of the current dialogue or task be r. Only the following candidate nodes are retained, which are expressed as: ; wherein, represents the candidate node set obtained after time window and path filtering; represents the node passed through k previous dialogue operations; 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 a floating window is set for long dialogues; The second level is semantic vector retrieval (Semantic Embedding Retrieval). The principle is to encode each historical node using a sentence vector model, which is expressed as: ; Then, the semantic similarity between the current node and the historical node is calculated, which is expressed as: ; wherein, represents that each current node is encoded using a sentence vector model; if , the node is considered as a node that can be relied on, =0.75~0.9; the vector index is established using FAISS to support real-time search, and the complexity is approximately ; The third level is reference pool and activity filtering (Reference Pool). The principle is that the system maintains a set of frequently referenced or highly active nodes, which is used to filter low-quality, low-reference nodes and only rely on knowledge-intensive nodes. The reference pool is expressed as: ; wherein, represents the number of times that other nodes reference the node ; represents the reference threshold, which is set to 2-3 times by default;​ Depending on the above three acceleration strategies, the final candidate node set is established, and the construction of the dependent edge is carried out through the final candidate node set, which is defined as: ; Wherein, represents the candidate node set obtained after the time window and path filtering; represents the pool of citation frequency; represents the candidate set screened by semantic similarity; The system performs high-similarity sorting in the candidate set , that is, 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 dependent edge; dependent edge establishment and annotation, in the structured graph, the dependent edge is established (D , ) and its dependent type and credibility are marked, which are used for retrieval, context focusing and generation control.

[0036] In the embodiment of the application, as shown in Figure 4 , in the multi-level main line graph memory system, the automatic construction process of the dependent edge when the new node is created. This process is triggered by the system internally, and the user does not need to explicitly mark the dependent relationship. When the user proposes 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 and extracts the variable name, keyword, model configuration, path reference and other key entities that may be involved. According to the extracted information, through three-level acceleration strategy, the candidate dependent node pool is constructed in the historical graph. For each node in the candidate node pool, the system evaluates the semantic relevance between the node and the new node through embedded vector similarity calculation, keyword matching, or language model auxiliary judgment, generates a score, and the system selects the final dependent target node set according to the relevance score and the preset threshold (such as Score>0.75). The system automatically constructs the dependent edge according to the target node set.

[0037] Step 5, based on step 4, generate structured prompts and context injection mechanism.

[0038] Current mainstream models do not have memory ability like human beings, they do not actively store previous conversation content, and do not naturally recall past information in subsequent interactions. The core logic of continuous dialogue is achieved by building and carrying context, in each round of dialogue, the model integrates historical dialogue content including user questions, model responses and current new inputs as a complete input sequence for processing.

[0039] In the embodiment of the application, step 5 comprises: The structured prompt generation and context injection mechanism constructs the most core value prompt word according to the multi-level strategy of dialogue control; when generating a response, the current node The path context is calculated as follows: ; Wherein, represents all parent nodes of the current node ; represents all dependent nodes of the current node ; represents the union set of all parent nodes and all dependent nodes of the current node .

[0040] The system automatically extracts the key summary from as a prompt to inject the model, ensuring that the response has main line consistency, behavior coherence, preference consistency, and maximum avoidance of catastrophic forgetting and task main line deviation.

[0041] This strategy only focuses on the current stage main line and the dependent nodes of the current node to construct the prompt, and injects the prompt into the context of the large language model after splicing with the user input, thereby improving the response focus and accuracy of the model.

[0042] Step 6, according to step 5, automatically maintain and manage the life cycle of the graph structure.

[0043] In the embodiment of the application, step 6 comprises: As shown in Figure 2 , when a correction instruction is raised in subsequent dialogue, such as "I don't want to go to the Forbidden City, change to the Summer Palace", the semantic intent will be automatically analyzed and the target step node to be modified will be identified, the original node will be deleted and a new node will be added, the main line edge and the dependent edge related to the new node will be updated synchronously, the consistency of the main line task path and the dependent relationship is ensured, and the system maintains the creation time, state change and source path of all nodes in the graph, supports tracking, rollback and dependent reconstruction of the task structure, and ensures the consistency and controllability of the task in complex multi-round interaction.

[0044] The application organizes the dialogue history and task state through a graph structure, constructs a dialogue graph, realizes long-term memory management, main line consistency tracking and structured response generation control, and fundamentally improves the performance and reliability of the large language model in complex multi-turn task dialogue.

[0045] The technical scheme provided by the application includes designing a memory graph, organizing task semantic information in dialogue in a directed graph structure, constructing a multi-level main line strategy, automatically creating nodes and updating the graph, constructing dependent edges and acceleration strategies, generating a structured prompt and a context injection mechanism, and automatically maintaining the graph structure and managing the life cycle.

[0046] The various steps of the embodiments of the application can be executed by an electronic device. The electronic device includes, but is not limited to, a tablet computer, a portable PC, a desktop computer, and the like.

[0047] The embodiments of the application provide a computer-readable storage medium including a stored program, wherein the computer-readable storage medium controls an electronic device in which the computer-readable storage medium is located to execute the embodiments of the multi-level main line graph memory method for large models when the program is running.

[0048] Figure 5 An electronic device provided by the embodiments of the application is shown in a schematic diagram as shown in Figure 5 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, the computer program 213 being executed by the processor 211 to implement the multi-level main line graph memory method for large models in the embodiments, to avoid repetition, which will not be described one by one.

[0049] The electronic device 21 includes, but is not limited to, the processor 211 and the memory 212. Those skilled in the art can understand that Figure 5 The electronic device 21 is only an example and does not constitute a limitation on the electronic device 21, and can include more or fewer components than the diagram, or combine certain components, or different components, for example, the electronic device can also include an input / output device, a network access device, a bus, and the like.

[0050] The processor 211 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0051] The memory 212 can be an internal storage unit of the electronic device 21, such as a hard disk or a memory 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, a smart media card (SMC), a secure digital (SD) card, a flash card, or the like. Further, the memory 212 can include both the internal storage unit and the external storage device of the electronic device 21. The memory 212 is used to store computer programs and other programs and data required by the network device. The memory 212 can also be used to temporarily store data that has been output or will be output.

[0052] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described herein.

[0053] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

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.

2. The method of claim 1, wherein, 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.

3. The method of claim 2, wherein, 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.

4. The method of claim 3, wherein, The step 3 comprises: After inputting natural language, the following operations are automatically performed: first, determine whether the input introduces a new task goal 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.

5. The method of claim 4, wherein, 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.

6. The method of claim 5, 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 .

7. The method of claim 6, 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.

8. 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-7.

9. 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 7.

Citation Information

Patent Citations

  • Data intelligent question and answer method and system fusing domain knowledge

    CN118779438A

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

    CN119293139A

  • Multi-round dialogue optimization method, system and equipment based on large language model and medium

    CN119537533A

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

    CN120409667A

  • Question-answering method and apparatus based on large language model

    WO2025098195A1

Cited By

  • Large model agent interactive question and answer task decision-making method and system

    CN121117167A