We develop AI systems for generating game dialogues and quests that do not replace narrators but scale their work. The solution fine-tunes a large language model (LLaMA 3 70B or Mistral Large) on your content and connects a RAG layer for access to the game world knowledge base. The result is dynamic dialogues and quests that preserve the character's voice, lore, and react to player actions.
A typical problem: a team of writers physically cannot write branching dialogues for 500 NPCs and 200 quests — the output is either templated or lore-inconsistent. Our system handles rough generation, and a human finalizes it. From the start, we reduce narrative content time by 60–70%.
With over 5 years in AI solutions, a team of 15 engineers (NLP, CV, MLOps), and 120+ completed projects, this experience guarantees predictable results.
System Architecture
The core is a fine-tuned LLM (LLaMA 3 70B or Mistral Large) with a RAG component for accessing the game world knowledge base.
Knowledge Base Layer
- Vector store (Chroma/Qdrant) with character descriptions, factions, locations, backstories
- Graph database (Neo4j) for relationships between NPCs, quest dependencies, progression flags
- World state system — game variables affecting generation
Generation Layer
- Fine-tuned LLM with LoRA adapter on game dialogue examples (minimum 10K examples)
- Constrained decoding to enforce format (JSON with dialogue branches, conditions, triggers)
- Character Voice Model — a separate adapter for each key character
Orchestration Layer
- LangGraph for multi-step quest generation
- Narrative consistency validator (checks contradictions with the knowledge base)
- Integration bridge for Unreal Engine (via REST API or UE Python)
Character Consistency
Each key NPC gets its own LoRA adapter trained on its lines (minimum 500 examples). During generation, the adapter is loaded alongside the base model — this guarantees the dialogue sounds exactly like that character, not an average. For generic NPCs, we use Character Profile Embedding — a vector description of personality and speech style.
Advantage of RAG
Fine-tuning fixes the model's knowledge at training time. A RAG layer allows dynamic retrieval of the current world state: which quests are completed, which NPCs died, how faction relations changed. This is critical for long game sessions — without RAG, the model 'forgets' context. More on the technology in the article Retrieval-Augmented Generation.
Types of Generated Content
NPC Dialogues
- Lines with branching (supports Twine/Ink/Yarn Spinner formats)
- Contextual reactions to player actions (NPC kills, faction choice, quest progress)
- Idle phrases, ambient conversations between NPCs
Quests
- Basic structure: objective, task chain, rewards, failure conditions
- Random side quests considering current region and player level
- Procedural dungeon tasks with dynamic descriptions
Development Pipeline
- Weeks 1–4: Collect and annotate existing narrative content. Build the game's Knowledge Graph. Set up the vector index.
- Weeks 5–9: Fine-tune the base LLM on the dialogue corpus. Develop a Chain-of-Thought prompt system for quest logic. First iterations with the narrative team.
- Weeks 10–14: Engine integration. Tune real-time generation (target latency up to 2 seconds per line). Implement caching for repeatable contexts.
- Weeks 15–16: QA testing for narrative contradictions, toxic content, character role violations.
Quality Metrics
| Metric | Target Value |
|---|---|
| Character Voice Consistency (writer evaluation) | >4.2/5 |
| Lore Contradiction Rate | <3% |
| Player Engagement (time spent in dialogue) | +15% over baseline |
| Unique quest generation | <500 ms (with cache) |
| Phrase repetition (n-gram overlap) | <8% |
Cost-Efficiency
| Approach | Infrastructure Cost | Switch Speed |
|---|---|---|
| Separate models per project | High (each instance) | Slow (model boot up) |
| Multi-LoRA serving (our choice) | 60–70% savings | Instant (adapter swap) |
Multi-LoRA serving uses a single base LLM instance, and LoRA adapters are switched by project_id. This saves 60–70% compared to separate models, making it 3 times more cost-effective. Projects typically start at $50,000 and save up to $200,000 annually on cloud compute.
Export Formats
Native support for Twine (JSON), Ink (.ink), Yarn Spinner, Unreal Engine Dialogue Graph, FountainHead. Custom formats are implemented via an adapter in 3–5 days.
Human-in-the-loop
The system suggests, people finalize. A built-in editorial interface (web app) allows narrators to accept/reject/edit generations, preserving a feedback loop for model improvement. After 2–3 iterations, the acceptance rate without edits reaches 70–80%.
What's Included
- Architecture and API documentation
- Training for the writing team on the editorial interface
- Technical support during launch (2 weeks)
- Source code for adapters and deployment scripts
How to Get Started?
We will send a questionnaire to describe your project, within 2 days estimate the scope, and propose a plan with precise timelines. Contact us for a consultation — we'll share the details.
Example of dialogue generation
(Example omitted for brevity.)







