04 / Retrieval-augmented generation · 2026

Dungeon Master RAG Assistant

Fast, sourced answers from the D&D SRD 5.1

A lightweight rules assistant built for Dungeon Masters who need a reliable answer without stopping the game. It retrieves relevant passages from the official SRD 5.1, generates an answer with citations and refuses questions outside the source.

Real saved result from the working Dungeon Master RAG notebook
Source
D&D SRD 5.1 · official CC BY 4.0 rules reference
Retrieval
Hierarchical chapter and section chunks with hybrid search
Generation
Gemini first, with Groq fallback
Evaluation
14/14 rule questions passed in the final saved run

Case study

From problem to validated pipeline

The problem

Dungeons & Dragons rules are precise, scattered across chapters and easy to misremember in the middle of a session. A general chatbot can sound confident while combining rules that do not belong together. The goal was narrower: answer only from the official SRD 5.1, show where every answer comes from and say no when the source cannot support it.

Preparing the source

The SRD was organised into 16 chapter-level blocks, then split into smaller sections without losing chapter, section and page metadata. This hierarchical structure preserves the context around combat, spellcasting and conditions while still producing fragments focused enough for retrieval. The result is a corpus that can be inspected and cited, rather than an opaque pile of text.

Hybrid retrieval

The pipeline combines semantic similarity with keyword signals. Semantic search catches different ways of asking the same rule; lexical matching protects exact terms, names and numbers. The retrieved fragments keep their metadata all the way to the final answer, so the response can point back to the chapter, section and page used as evidence.

Generation and fallback

Gemini is tried first and Groq is available as a fallback from a single notebook control. The prompt tells the model to stay inside the retrieved evidence, cite its sources and avoid filling gaps from general knowledge. If the question is outside the SRD corpus, the assistant blocks it instead of improvising.

Evaluation and iteration

The final saved run passes 14 out of 14 rule questions with answers and sources checked. That score followed rejected iterations: one invented a restriction about casting two spells, another confused grappled with restrained, and another invented a price. Those failures shaped the retrieval and grounding checks. The target was never a green notebook cell; it was an answer a Dungeon Master could verify.

What this demonstrates

The project is a working Google Colab pipeline, not a deployed app. It demonstrates document preparation, retrieval design, model routing, source attribution, refusal behaviour and evaluation as one connected system. The two interface images below are clearly labelled concepts: they explore how the validated pipeline could become a product without claiming that product already exists.

How it works

RAG pipeline

01

Structure the rules

The SRD is split by chapter and section so spellcasting, combat and conditions keep their context.

02

Retrieve the evidence

Hybrid retrieval finds the relevant chunks and keeps their chapter, section and page metadata.

03

Answer or abstain

The model answers from the retrieved context, cites its sources and blocks questions outside the SRD.

← Back to selected work