RAG Lab

Chunk a handbook, search it by meaning, fuse BM25 with dense retrieval, rerank, measure recall and NDCG, and keep the index fresh.

About the RAG Lab

Retrieval-augmented generation, or RAG, is how an AI assistant answers from your documents instead of from memory: it finds the right passages first, then writes an answer from them. The RAG Lab lets you run every stage of that pipeline on a small handbook and see where answers get lost.

Most RAG failures happen before the language model is ever called. A chunk was cut in the wrong place, the search missed a passage that used different words, or an outdated copy of a document was still in the index. Each experiment here makes one of those failures visible, and shows the fix.

It is aimed at developers building search or chat over their own data, and at students who want to understand what "vector search" and "reranking" mean in practice. The metrics experiment computes recall, MRR and NDCG as you tap results, which is the quickest way to learn what those scores reward.

Experiments in this lab

  1. Chunking strategies: Fixed, recursive, by heading and semantic: does the answer survive the cut?
  2. Embedding search: Find chunks by meaning, and see them in vector space.
  3. Cosine, dot, Euclidean: Drag vectors and watch the three measures agree or disagree.
  4. Vector index (IVF): Search a few clusters instead of everything, and what it costs in recall.
  5. Hybrid search and RRF: BM25 plus dense retrieval, fused by rank or by weight.
  6. Reranking: A cross-encoder reorders the candidates before they reach the model.
  7. Retrieval metrics: Recall, precision, MRR, MAP and NDCG, computed as you tap.
  8. Index freshness: Re-ingest a changed document and find the duplicates and orphans.