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.