TL;DR
Researchers have developed Dynamic Context Prompting/Programming (DCP/P), a framework that allows Large Language Models (LLMs) to generate complex, branching visual novel stories with high coherence. By treating story generation as a graph traversal problem and dynamically managing the LLM's context window, the system produces significantly more consistent and instruction-compliant narratives than standard prompting methods.
What Problem Does This Paper Address?
Visual novels are defined by their branching narratives, often represented as Directed Acyclic Graphs (DAGs) where player choices lead to different story paths. Generating these with LLMs presents two major hurdles:
- Context Limitations: LLMs have a finite "memory" (context window). As a story branches and grows, fitting the entire narrative history into the prompt becomes impossible.
- Coherence and Instruction Following: Simply providing a summary of the story so far often leads to disjointed transitions, "hallucinated" characters that weren't previously introduced, and a failure to generate the requested number of player choices.
Previous attempts often relied on manual extraction or basic prompting that lacked the flexibility to handle long-form, multi-branching content.
Methods
The authors introduce DCP/P, which draws inspiration from dynamic programming and breadth-first search (BFS) algorithms.
Key components include:
- Graph-Based Generation: The story is broken into "chunks." The algorithm maintains a frontier of chunks to be generated, traversing the story tree branch by branch.
- Dynamic Context History: Instead of a static prompt, each new story chunk is generated using the specific conversation history of its parent branch. This ensures the LLM "remembers" the exact path taken to reach that point.
- Context Overflow Policy: To stay within token limits, the system uses a rolling history mechanism. When the context reaches 80% capacity, it selectively truncates older messages while prioritizing recent user inputs and essential "Story Data" (like character bios and world settings) to maintain coherence.
- Automated Pipeline: The framework integrates Claude 3 Opus for text, DALL-E 3 for assets, and Neo4j for storing the resulting story graph.
Datasets
The study did not use a pre-existing dataset for training. Instead, it generated a benchmark of 20 unique stories (10 using the DCP/P approach and 10 using a baseline approach) based on three themes: "adventure," "high-fantasy," and "science fiction."
Evaluation was conducted using an LLM-as-a-judge setup, where a separate LLM evaluated the stories based on five linguistic criteria: coherence, inspiration, narrative fluency, readability, and word complexity.
Key Insights and Ideas
- Context > Summary: The most significant finding is that providing the actual conversation history of a branch is vastly superior to providing a summarized version. Summaries often lose the "flavor" and specific details needed for smooth transitions.
- Instruction Compliance: Without proper context, LLMs become "lazy." The baseline approach frequently failed to generate the requested number of choices (e.g., generating one choice when three were requested). DCP/P significantly improved adherence to these structural constraints.
- Inherent Model Biases: Despite using a different model family (Claude 3 vs. the GPT series used in prior work), the authors found consistent biases. The LLM frequently gravitated toward specific words like "Aria," "Celestial," and "Power," suggesting these tropes are deeply embedded in the underlying training data across the industry.
Key Results
The DCP/P approach outperformed the baseline across nearly all metrics:
- Coherence: The best DCP/P game scored 7.20/10, compared to 6.83/10 for the best baseline game.
- Graph Complexity: DCP/P games averaged 721.4 story chunks, while baseline games averaged only 577.7. This is because DCP/P followed instructions to create more branches more reliably.
- Qualitative Superiority: Qualitative analysis showed that DCP/P stories had smoother transitions between locations and fewer "hallucinations" (like characters appearing out of nowhere).
Limitations and Future Work
- Visual Artifacts: While DALL-E 3 generated impressive assets, background removal sometimes failed, and malformed shapes appeared in complex scenes.
- Hallucinations: Even with DCP/P, the model occasionally referenced non-existent characters or mismatched speakers with dialogue lines.
- Creativity Ceiling: The stories often followed standard genre tropes (e.g., a protagonist seeking lost memories). The authors suggest that "expert prompting" or "role prompting" could help push the LLM toward more novel narratives.
- Future Directions: The team plans to explore Retrieval-Augmented Generation (RAG) for even deeper personalization and incorporate audio generative models to create a fully multimodal experience.
Summary updated