01 — Overview

RAG, Traced

A working implementation of Retrieval-Augmented Generation, built to make the mechanics visible rather than taken on faith.

Large language models answer from what they memorized during training, which means they don't know about anything created afterward — and they'll often guess with confidence rather than admit they don't know. RAG (Retrieval-Augmented Generation) fixes this by having the model search a set of documents first, then answer using only what it finds. This page runs that process live, in two parts: first how the documents get prepared for search, then how a question gets answered from them. Underlined terms like the one above have a short explanation on hover or tap.

Diagram of the two-phase RAG pipeline. Indexing: documents split into chunks, chunks turned into vectors, vectors stored in a vector database. Query: a question turned into a query vector, matched against the vector database to retrieve context snippets, which are passed with the question to a model to produce a grounded answer.
The same two phases traced live below — indexing, then query.

Why it matters

  • Grounded, not guessed. Answers are traceable to specific source text, not the model's memorized best guess.
  • Updates without retraining. Changing what the system knows means editing a document, not retraining a model.
  • Honest about gaps. When the source material doesn't cover a question, a well-built system says so instead of fabricating an answer.

The knowledge base

Documents6
Chunks indexedchecking…
Vector indexrag-demo-index, 768 dimensions, cosine similarity
Embedding modelbge-base-en-v1.5
Generation modelgpt-oss-20b

02 — Indexing

How the documents get indexed

Pick a document to trace it through the same steps every document went through before any question could be answered.

The starting point is the raw document text — nothing has been processed yet.

—

The document is split into overlapping chunks — small enough to be specific, large enough to stand alone. Highlighted text is carried over from the previous chunk so an idea near a cut point isn't split in half.

—

Pick any chunk above to turn it into a real embedding — the same model and the same step used for every one of the 23 chunks actually stored.

—

The embedding is stored in a vector index alongside the chunk's text, ready to be searched the moment a question comes in.

— embed a chunk in stage 03 to see it confirmed here —

03 — Query

Ask it something

Every value below comes from one live request — click a stage to expand it. Timings are real.

The pipeline starts with plain text — no preprocessing yet.

— waiting for a question —

An embedding model turns the question into 768 numbers that place it near every stored chunk with a similar meaning — the same step traced above, run on your question this time.

—

Cosine similarity ranks every stored chunk against the question's vector; the top 4 move forward.

—

These are the real chunks the search found — not a summary of them.

—

The retrieved chunks are numbered and inserted into a prompt that instructs the model to answer only from them — this is what makes the answer grounded.

—

The generation model answers from the prompt above. Citation markers link back to the chunk cards in stage 4.

—