A large model hallucination mitigation method based on multi-agent cooperation and dynamic state tracking

By employing multi-agent collaboration and dynamic state tracking mechanisms, the problems of logical consistency and structural planning in long-form creative writing using large language models are solved, achieving efficient context management and creative generation. The generated stories are logically rigorous and structurally complex.

CN122334458APending Publication Date: 2026-07-03HANGZHOU JUNTONG FUTURE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU JUNTONG FUTURE TECHNOLOGY CO LTD
Filing Date
2026-01-30
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing large language models suffer from problems such as difficulty in maintaining logical consistency, insufficient structural planning, and poor context management in long-form creative writing. This leads to generated content that is prone to illusion and structural uniformity, making it difficult to create complex and coherent long stories.

Method used

By introducing a multi-agent collaboration and dynamic state tracking mechanism, narrative planning and text generation are decoupled. A symbolic state verification mechanism and a non-linear narrative outline are used to verify and correct the generated content in real time to ensure logical consistency. The context is managed through a hybrid retrieval and rewriting mechanism.

Benefits of technology

It significantly reduces logical errors in long texts, improves story coherence and structural complexity, achieves efficient context management and controllable creative generation, and ensures the logical rigor and literary quality of the generated content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122334458A_ABST
    Figure CN122334458A_ABST
Patent Text Reader

Abstract

This invention discloses a method for mitigating hallucinations in large-scale narratives based on multi-agent collaboration and dynamic state tracking. The method includes: generating an event graph composed of multiple atomic events using an outline agent; mapping these atomic events from an event occurrence time series to a text narrative time series using an orchestration agent; constructing a non-linear narrative outline; retrieving historical fragments related to the semantics and sentiment of the current chapter from the generated historical text; generating the text content of the current chapter using a writing agent; performing real-time logical consistency checks on the content during generation; triggering a correction mechanism when entity state changes in the generated content violate preset state transition rules; and parsing the entity state changes after the current chapter is finalized, updating the global state table and historical text database. This invention effectively mitigates hallucinations in long narratives, significantly improving the logical rigor and long-term coherence of the plot development while maintaining the literary quality of the text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0002] This invention belongs to the field of artificial intelligence and natural language processing technology, specifically relating to a large-scale hallucination mitigation method based on multi-agent collaboration and dynamic state tracking. Background Technology

[0004] This invention primarily addresses the systemic technical bottlenecks of existing Large Language Models (LLMs) in long-form creative writing. Current methods are mostly based on single-agent, autoregressive generative paradigms, which expose the following core shortcomings when handling narrative tasks requiring long-term logical consistency, complex structural planning, and management of extremely long texts:

[0005] Existing LLMs are essentially probabilistic sequence predictors that treat all historical text as a flattened context, lacking an independent, structured, dynamic state tracking module. When generating long stories, key narrative elements such as character attributes, item states, and spatial relationships are quickly buried in the text once mentioned. The model lacks a built-in mechanism to continuously maintain and query an evolving fact base, making it prone to forgetting or violating early assumptions in subsequent generation, creating long-term illusions that disrupt logical consistency. Existing methods to reinforce memory through cue word repetition or manual summarization are inefficient and unreliable.

[0006] Mainstream LLM follows a linear autoregressive generation model, which naturally tends to produce chronological narratives. The model architecture and training objectives do not endow it with the ability of a top-level narrative architect. It is difficult for it to independently conceive and execute complex non-linear narrative structures such as flashbacks, interludes, multiple perspectives, and parallel plot lines. Even when forcibly guided by instructions, its generation results are often local and mechanical. It cannot organically coordinate various literary techniques in a long-form narrative, resulting in a simple story structure, a slow pace, and a lack of artistic tension and layering.

[0007] Despite the model's continuously increasing context window, simply inputting all historical text can lead to a significant loss of information in the middle—the model focuses excessively on the beginning and end of the input sequence, neglecting crucial information in the middle. Simultaneously, a massive amount of irrelevant details dilutes the core clues and conflicts essential to the current generation. This exposes the current architecture as a passive, homogeneous information carrier, lacking the ability to proactively and accurately retrieve and focus on key information, causing generated content to easily deviate from the main theme or fail to effectively echo the preceding text.

[0008] In summary, existing technologies employ isolated patching strategies, failing to fundamentally address the disconnect between state maintenance, structural planning, and context management. Therefore, a system-level innovative framework is urgently needed to deeply integrate dynamic state tracking, macro-narrative planning, and precise content generation, thereby overcoming the fundamental limitations of current LLM in high-quality long-form creative writing. This invention is precisely proposed to address this need. Summary of the Invention

[0010] To address the aforementioned technical problems, this invention proposes a large-scale hallucination mitigation method based on multi-agent cooperation and dynamic state tracking. This method decouples narrative planning and text generation and introduces a symbolic state verification mechanism, specifically including the following steps:

[0011] S1: Generate an event graph through an outline agent. The event graph consists of multiple atomic events. The orchestration agent maps the atomic events from the event occurrence time sequence to the text narrative time sequence and constructs a non-linear narrative outline.

[0012] S2: Retrieve historical fragments from the generated historical text that are semantically and emotionally relevant to the current chapter;

[0013] S3: Based on a non-linear narrative outline and historical fragments, use a writing agent to generate the text content of the current chapter;

[0014] During the generation process, the generated content is checked for logical consistency in real time based on the global state table. When the entity state change in the generated content is detected to violate the preset state transition rules, a correction mechanism is triggered.

[0015] S4: After the current chapter is finalized, analyze the changes in entity states and update the global state table and historical text library.

[0016] In step S1, generating an event graph through the outline agent includes:

[0017] Obtain multiple atomic events that constitute the narrative content and the timestamp of each atomic event.

[0018] Based on the causal or temporal relationships between multiple atomic events, an event graph is constructed with atomic events as nodes.

[0019] Mapping atomic events from event occurrence time series to text narrative time series through orchestration agents includes:

[0020] Based on the graph traversal algorithm, at least one critical event path is determined in the event graph;

[0021] Adjust the position of at least one event node in the critical event path within the text narrative sequence;

[0022] The adjustment methods include moving event nodes with later timestamps to positions in the text narrative sequence that are earlier than their original positions, or moving event nodes with earlier timestamps to positions in the text narrative sequence that are later than their original positions.

[0023] In step S2, historical fragments related to the semantics and emotions of the current chapter are retrieved from the generated historical text;

[0024] Retrieving historical fragments that are semantically and emotionally relevant to the current chapter includes:

[0025] Construct a retrieval kernel function To measure the relevance of historical fragments, the optimal retrieval distribution is defined as:

[0026]

[0027] Among them, the retrieval kernel The specific form is as follows:

[0028]

[0029] The currently generated story segment is Historical fragments are ; Indicates the semantic cosine similarity between the current segment and historical segments; Indicates the sentiment score of the segment; Emotional consistency penalty items; The emotional punishment coefficient, For temperature parameters;

[0030] Based on the search relevance score, one or more segments with the highest relevance are selected as historical segments.

[0031] In step S3, based on the non-linear narrative outline and historical fragments, the writing agent generates the text content of the current chapter. During the generation process, the generated content is checked for logical consistency in real time according to the global state table. When the entity state change in the generated content is detected to violate the preset state transition rules, the correction mechanism is triggered.

[0032] Real-time logical consistency verification of the generated content based on the global status table includes:

[0033] Identify at least one key entity in the current narrative context, and build and dynamically update a state mapping table for each key entity. The state mapping table records the unique identifier of each key entity and its corresponding current symbolic state. The symbolic state belongs to a predefined state space.

[0034] When the symbolic state of a critical entity is a preset terminal state, state transition constraints are applied to prevent the symbolic state from transitioning out of the terminal state.

[0035] When the large language model generates subsequent narrative text content, the subsequent narrative text content is parsed in real time to determine whether it contains intent instructions that trigger state transitions of key entities.

[0036] When an intent instruction is detected attempting to transfer the symbolic state of a key entity in a terminal state out of the terminal state, it is determined to be a logical illusion, and the output of subsequent narrative text content is intercepted.

[0037] The reviewing agent generates specific modification suggestions based on logical illusions, and the writing agent generates a revised draft based on the modification suggestions.

[0038] Furthermore, the state transition constraints are based on Markov chains, when the critical entity... At any moment If it is in a terminal state, then in subsequent time steps... The state transition probability must satisfy the absorption state condition:

[0039]

[0040] Then at time subsequent The probability of remaining in that terminal state is 1. As a key entity At time step The state;

[0041] When a large language model attempts to generate content descriptions, key entities that again reach a terminal state are encountered. At that time, it was an attempt to carry out an illegal migration;

[0042] Calculate the narrative entropy increase caused by this illegal migration. :

[0043]

[0044] When the narrative entropy is detected to increase beyond a preset threshold, it is determined to be a logical illusion, and the output of subsequent narrative text content is blocked.

[0045] Furthermore, the revised draft re-invokes the logical consistency check, and outputs subsequent narrative text content when the revised content does not introduce new logical conflicts.

[0046] In step S4, after the current chapter is finalized, the changes in entity states are analyzed, and the global state table and historical text database are updated.

[0047] Global state table updates include parsing state changes in subsequent narrative text and adding them to the global state table;

[0048] The historical text library update includes slicing and quantifying subsequent narrative text content and adding it to the historical text library.

[0049] Compared with the prior art, the present invention has the following significant advantages:

[0050] This invention alleviates the logical illusion of lengthy narratives by introducing symbolic dynamic state tracking, combining probability-based text generation with rule-based logic verification. Experiments show that this method significantly reduces logical errors regarding object states and character settings in long texts (such as resurrection of the dead and teleportation of objects), ensuring the long-term coherence of the story.

[0051] This invention enhances the literary quality and structural complexity of the narrative. By distinguishing between the time of events and the time of textual narration and employing non-linear programming, it breaks through the limitation that large language models can only generate linear narratives, and can create complex stories with exquisite structures and well-resolved foreshadowing.

[0052] It achieves efficient context management. By utilizing the input-output rewriting mechanism and hybrid retrieval, when processing long stories of tens of thousands of words, the system only needs to input the most relevant historical text and state into the model, which effectively solves the problem of attention decay in large models with long windows and reduces inference costs.

[0053] Controllable creative generation, through a logic-expression separation training and generation strategy, ensures both the rigor of the underlying plot logic and the diversity and stylization of language expression, thus solving the TTR paradox of traditional models that sacrifice literary style for logical accuracy (the negative correlation between lexical diversity and quality). Attached Figure Description

[0055] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art 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.

[0056] Figure 1 This is a flowchart illustrating a large-scale hallucination mitigation method based on multi-agent collaboration and dynamic state tracking provided by the present invention. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the scope of protection of this invention.

[0059] This embodiment proposes a large-scale hallucination mitigation method based on multi-agent collaboration and dynamic state tracking.

[0060] The core algorithm and processing flow of this invention includes the following four key steps:

[0061] S1: Generate an event graph through an outline agent. The event graph consists of multiple atomic events. The orchestration agent maps the atomic events from the event occurrence time sequence to the text narrative time sequence and constructs a non-linear narrative outline.

[0062] S2: Retrieve historical fragments from the generated historical text that are semantically and emotionally relevant to the current chapter;

[0063] S3: Based on a non-linear narrative outline and historical fragments, use a writing agent to generate the text content of the current chapter;

[0064] During the generation process, the generated content is checked for logical consistency in real time based on the global state table. When the entity state change in the generated content is detected to violate the preset state transition rules, a correction mechanism is triggered.

[0065] S4: After the current chapter is finalized, analyze the changes in entity states and update the global state table and historical text library.

[0066] like Figure 1 As shown, in step S1, an event graph is generated by an outline agent. The event graph consists of multiple atomic events. An orchestration agent maps the atomic events from the event occurrence time series to the text narrative time series and constructs a non-linear narrative outline.

[0067] The prerequisite for receiving user input. A framework agent generates a data structure containing... Event graph of atomic events ;

[0068] To enhance narrative complexity, a mapping function is defined by orchestrating nonlinear transformations performed by intelligent agents. ,in This is the actual time sequence of the events. The sequence of chapters presented in the text.

[0069] For any two events in the event graph , If in the actual timeline , i.e., event It happened first, but in the order of narration , i.e., event If described first, the system will automatically mark the event. As a reverse narrative, the planning results are stored as a sequence of chapter outlines.

[0070] like Figure 1 As shown, in step S2, historical fragments related to the semantics and emotions of the current chapter are retrieved from the generated historical text;

[0071] In writing the first When processing chapter content, to address the issue of forgetting long texts, instead of inputting the entire history, key historical fragments are extracted, and a retrieval kernel function is constructed. To measure the relevance of historical fragments, based on the derivation of the SCORE framework, the optimal retrieval distribution is determined. Defined as:

[0072]

[0073] in, For the currently generated story segment, This is a historical fragment.

[0074] Search kernel The specific form is as follows:

[0075]

[0076] In this formula: Indicates the semantic cosine similarity between the current segment and historical segments; Indicates the sentiment score of the segment; This is a penalty item for emotional consistency. The emotional punishment coefficient, This refers to the temperature parameter.

[0077] Based on the retrieval relevance score, one or more segments with the highest relevance are selected as historical segments. This step ensures that the retrieved historical segments are not only semantically relevant, but also maintain continuity with the current plot in terms of emotional tone, thereby maximizing narrative coherence.

[0078] like Figure 1 As shown, in step S3, the text content of the current chapter is generated by the writing agent based on the non-linear narrative outline and historical fragments. During the generation process, the generated content is checked for logical consistency in real time according to the global state table. When the entity state change in the generated content is detected to violate the preset state transition rules, the correction mechanism is triggered.

[0079] Identify at least one key entity in the current narrative context, and build and dynamically update a state mapping table for each key entity. The state mapping table records the unique identifier of each key entity and its corresponding current symbolic state. The symbolic state belongs to a predefined state space, which is defined as follows:

[0080] ;

[0081] When the symbolic state of a critical entity is a preset terminal state, a state transition constraint is applied to prevent the symbolic state from transitioning out of the terminal state. The state transition constraint is based on a Markov chain. At any moment If its status is "destroyed", then it will be destroyed at a later time. The state transition probability must satisfy the absorption state condition:

[0082]

[0083] Then at time subsequent The probability of remaining in that terminal state is 1. As a key entity At time step The state;

[0084] When a large language model attempts to generate a content description such as "The protagonist reuses a destroyed item," ", that is, attempting to perform an illegal migration, calculating the resulting narrative entropy increase." :

[0085]

[0086] When the narrative entropy is detected to increase beyond a preset threshold, it is determined to be a logical illusion, and the output is intercepted, returning an error code to the writing agent: "Logical Conflict: Entity..." "Destroyed and cannot be made active";

[0087] The reviewing agent scores the intercepted output D0 based on three dimensions: plot, creativity, and coherence.

[0088] If the scoring function Review the specific modification suggestions generated by the intelligent agent. The intelligent agent generates a revised draft based on the modification suggestions. , represented as:

[0089]

[0090] Preferably, the maximum number of iterations in this process is set to Preferably, This is to prevent infinite loops.

[0091] When the writing agent generates a revised draft based on the modification suggestions, it also calls a logical consistency check. If the revised content does not introduce new logical conflicts, it outputs the subsequent narrative text content.

[0092] like Figure 1 As shown, in step S4, after the current chapter is finalized, the changes in the entity state are parsed, and the global state table and historical text database are updated.

[0093] Once the chapter is finalized, analyze the entity state changes in the new text:

[0094] Global State Table Update: Update the global state table , for example Character_A_Location: "Home" -> "Office".

[0095] Historical text library update: New chapters are sliced ​​and quantized, and then stored in the historical text library.

[0096] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a necessary general-purpose hardware platform, or by a combination of hardware and software. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can be implemented in the form of a computer program product on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Other embodiments may also be used. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A large model hallucination mitigation method based on multi-agent cooperation and dynamic state tracking, characterized in that, Includes the following steps: S1: Generate an event graph through an outline agent. The event graph consists of multiple atomic events. The orchestration agent maps the atomic events from the event occurrence time sequence to the text narrative time sequence and constructs a non-linear narrative outline. S2: Retrieve historical fragments from the generated historical text that are semantically and emotionally relevant to the current chapter; S3: Based on the non-linear narrative outline and the historical fragments, use the writing agent to generate the text content of the current chapter; During the generation process, the generated content is checked for logical consistency in real time according to the global state table. When the entity state change in the generated content is detected to violate the preset state transition rules, a correction mechanism is triggered. S4: After the current chapter is finalized, parse the changes in the entity states and update the global state table and historical text library.

2. The large model hallucination mitigation method based on multi-agent collaboration and dynamic state tracking according to claim 1, characterized in that, In step S1, generating the event graph through the outline agent includes: Obtain multiple atomic events that constitute the narrative content and the timestamp of each atomic event. Based on the causal or temporal relationships among the multiple atomic events, an event graph is constructed with atomic events as nodes.

3. The method for alleviating large-scale hallucinations based on multi-agent cooperation and dynamic state tracking according to claim 1, characterized in that, In step S1, mapping the atomic events from the event occurrence time series to the text narrative time series by orchestrating the intelligent agent includes: Based on the graph traversal algorithm, at least one critical event path is determined in the event graph; Adjust the position of at least one event node in the key event path within the text narrative sequence; The adjustment methods include moving event nodes with later timestamps to positions in the text narrative sequence that are earlier than their original positions, or moving event nodes with earlier timestamps to positions in the text narrative sequence that are later than their original positions.

4. The method for alleviating large-scale hallucinations based on multi-agent cooperation and dynamic state tracking according to claim 1, characterized in that, In step S2, the retrieval of historical fragments related to the semantics and sentiment of the current chapter includes: Construct a retrieval kernel function To measure the relevance of historical fragments, the optimal retrieval distribution is defined as: Among them, the retrieval kernel The specific form is as follows: The currently generated story segment is Historical fragments are ; Indicates the semantic cosine similarity between the current segment and historical segments; Indicates the sentiment score of the segment; Emotional consistency penalty items; The emotional punishment coefficient, For temperature parameters; Based on the search relevance score, one or more segments with the highest relevance are selected as the historical segments.

5. The method for alleviating large-scale hallucinations based on multi-agent cooperation and dynamic state tracking according to claim 1, characterized in that, In step S3, the real-time logical consistency verification of the generated content based on the global state table includes: Identify at least one key entity in the current narrative context, and establish and dynamically update a state mapping table for each key entity. The state mapping table records the unique identifier of each key entity and its corresponding current symbolic state, which belongs to a predefined state space. When the symbolic state of the key entity is a preset terminal state, a state transition constraint is applied to prevent the symbolic state from transitioning out of the terminal state. When the large language model generates subsequent narrative text content, the subsequent narrative text content is parsed in real time to determine whether it contains intentional instructions that trigger the state transition of the key entity. When the intent instruction is detected to attempt to migrate the symbolic state of a key entity in the final state out of the final state, it is determined to be a logical illusion, and the output of the subsequent narrative text content is intercepted; The reviewing agent generates specific modification suggestions based on the logical illusion, and the writing agent generates a revised draft based on the modification suggestions.

6. The method for alleviating large-scale hallucinations based on multi-agent cooperation and dynamic state tracking according to claim 5, characterized in that, The state transition constraints are based on Markov chains, when the critical entity... At any moment If it is in the terminal state, then at subsequent times... The state transition probability must satisfy the absorption state condition: Then at time subsequent The probability of remaining in that terminal state is 1. As a key entity At time step The state; When a large language model attempts to generate content descriptions, key entities that again reach a terminal state are encountered. At that time, it was an attempt to carry out an illegal migration; Calculate the narrative entropy increase caused by this illegal migration. : When the narrative entropy is detected to increase beyond a preset threshold, it is determined to be a logical illusion, and the output of the subsequent narrative text content is blocked.

7. A method for alleviating large-scale hallucinations based on multi-agent cooperation and dynamic state tracking according to claim 5, characterized in that, The revised draft re-invokes the logical consistency check, and outputs the subsequent narrative text content when the revised content does not introduce new logical conflicts.

8. The method for alleviating large-scale hallucinations based on multi-agent cooperation and dynamic state tracking according to claim 1, characterized in that, In step S4, The global state table update includes parsing the state changes in the subsequent narrative text content and adding them to the global state table; The historical text library update includes slicing and quantifying the subsequent narrative text content and adding it to the historical text library.