Lab
RAG Pipeline Simulator
Trace a query through retrieval, reranking and generation.
Retrieval-Augmented Generation grounds a model in your own documents. Watch a query flow through every stage, chunking, embedding, retrieval, and prompt construction, and inspect exactly what the model would be asked.
1Documents
- Embeddings
- Retrieval
- Generation
2Chunks (9)
- embeddings#0 · words 0–14
An embedding maps text to a vector so that similar meaning lands nearby in - embeddings#1 · words 10–24
meaning lands nearby in space. Cosine similarity compares two vectors by the angle between - embeddings#2 · words 20–27
by the angle between them, ignoring length. - retrieval#0 · words 0–14
Retrieval finds the chunks whose vectors are closest to the query vector. Exact search - retrieval#1 · words 10–24
query vector. Exact search scans every vector, while approximate search scans fewer and trades - retrieval#2 · words 20–29
scans fewer and trades a little recall for speed. - generation#0 · words 0–14
The language model receives the retrieved chunks as context and writes an answer that - generation#1 · words 10–24
writes an answer that cites its sources. This grounding keeps the model anchored to - generation#2 · words 20–29
the model anchored to your documents instead of guessing.
3Retrieved top-3
- 1.generation#00.590
- 2.retrieval#00.579
- 3.retrieval#20.532
4Context prompt
Use only the sources below to answer the question. Cite sources as [n]. [1] Generation, The language model receives the retrieved chunks as context and writes an answer that [2] Retrieval, Retrieval finds the chunks whose vectors are closest to the query vector. Exact search [3] Retrieval, scans fewer and trades a little recall for speed.
3 sources cited.
5Generation
A language model would receive the prompt above and write a cited answer. This lab stops at the prompt and does not fabricate an answer, real generation needs a real model. The retrieval and grounding you see here are the part RAG actually controls.
RAG has two halves. Everything up to the prompt, chunking, embedding, retrieval, context assembly, is deterministic plumbing you can inspect and tune. Only the final generation step needs a model. Most RAG quality problems live in the plumbing: chunks too large to be specific, too small to be coherent, or a retriever that fetches the wrong passages.
Honest note: retrieval here uses the toy character-trigram embeddings, so it matches on shared words rather than meaning, and no answer is generated. The pipeline’s shape, and the way chunk size, overlap, and k change what the model sees, is exactly that of a production RAG system.
Challenge
Shrink the chunk size to its minimum, then grow it to the maximum. How does the retrieved context change, and at which extreme would a model struggle to answer precisely? Then change the query wording and watch which chunks surface.