Knowledge Graphs Help AI Maintain Character Consistency in Stories
Researchers propose a multi-agent pipeline using knowledge graphs to prevent narrative drift and character loss in long-form AI storytelling.
Source: Grafy Research LabLarge language models often struggle to maintain a coherent narrative over long stretches of text, frequently losing track of character traits or relationships. Researchers have developed a new multi-agent framework that utilizes knowledge graphs to serve as a long-term memory, ensuring that characters and plot elements remain consistent throughout a story.
How does the knowledge graph pipeline work?
According to the research paper "Remember Me: Enhancing Long-term Character Persistence in LLM-Generated Stories using Knowledge Graphs," the authors addressed the issue of narrative drift by moving away from simple, linear prompting. Instead, they implemented a multi-agent system built on LangGraph.
This system decomposes the creative process into specialized roles. Figure 1 shows the agentic structured generation workflow, which involves different agents responsible for planning the generation, extracting information into a knowledge graph, and writing the actual text. As the story progresses chapter by chapter, the system updates a shared, evolving knowledge graph. This graph acts as a structural backbone, storing the current state of characters, their relationships, and the narrative objectives. This allows the "writer" agent to condition its output on both the immediate preceding text and the broader, structured context provided by the graph.
Why do standard LLMs struggle with long fiction?
While modern models are highly capable at following instructions, they often suffer from logical breakdowns when tasked with long-form content. The authors note that off-the-shelf models frequently exhibit issues such as character inconsistency and the loss of implicit connections between entities.
In traditional prompting, the model relies on its context window—the amount of previous text it can "see" at one time. As a story grows, earlier details about a character's appearance, motivations, or social ties may fall outside this window, leading to the fragmented narratives common in current AI-generated fiction. By using a knowledge graph, the system provides a way to retrieve essential facts about the story world without relying solely on the raw text of previous chapters.
What are the results of using knowledge graphs?
To evaluate the effectiveness of this approach, the researchers introduced new metrics focused on entity and relationship retention. They wanted to measure how well a model preserves the "identity" of characters and the links between them over time.
Through statistical analysis, the researchers found that stories generated with the multi-agent knowledge graph (KG) pipeline showed significant improvements in retention and cohesion compared to those produced with naive prompting. Figure 2 illustrates this difference, comparing the knowledge graph of a story generated with the multi-agent pipeline against one generated with vanilla prompting. The KG-guided approach results in a more robust and interconnected representation of the story's elements, which directly translates to more stable and logical storytelling.
How is story consistency measured?
Because standard text similarity metrics like BLEU are often unsuitable for evaluating open-ended, unreferenced creative writing, the authors devised a novel retention-based metric. This methodology uses named entity recognition (NER) to track specific characters and their relationships.
By focusing on character retention and relationship persistence, the researchers can quantitatively assess whether a character's established role or a specific plot connection remains intact across multiple chapters. This moves the evaluation of AI creativity from surface-level word patterns to deeper structural and logical stability.
How can this research be applied in practice?
For developers and researchers working on agentic workflows, this study highlights the value of structured memory. Rather than simply feeding larger chunks of text into a prompt, building a dedicated "world state" via a graph can solve many of the coherence problems currently facing generative AI.
While Grafy does not currently feature a dedicated long-form fiction writing studio, researchers looking to dive deeper into the mechanics of this paper can use Reader to analyze the full PDF, asking specific questions about the mathematical implementations or the LangGraph architecture. For those interested in exploring how different models handle complex, multi-step reasoning, Chat allows for side-by-side comparisons of various models to observe how they maintain context in long conversations.
Frequently asked questions
Does the knowledge graph improve character consistency?
Yes, the research demonstrates that using a knowledge graph as long-term context storage significantly improves character retention. By explicitly storing character traits and relationships in a graph, the multi-agent pipeline prevents the model from losing track of essential details that might otherwise fall out of the immediate text context.
What is the role of agents in this pipeline?
In this framework, specialized agents work together to manage the story. One agent handles the generation planning, another is responsible for extracting information to update the knowledge graph, and a third acts as the writer. This division of labor allows the system to maintain a structured narrative while generating text.
How does this method differ from standard prompting?
Standard prompting relies on the model's ability to remember previous text within its context window, which often leads to narrative drift in long stories. This method instead uses an evolving knowledge graph to provide a structured, permanent record of the story's entities and relationships, which the writer agent uses to guide its output.
Source: Alvin Tan et al., "Remember Me: Enhancing Long-term Character Persistence in LLM-Generated Stories using Knowledge Graphs"


