Build a RAG pipeline

Chunking, storage, retrieval and generation, and the failure each stage introduces.

What you will be able to do

Answer questions over your own documents, and know which stage is lying when it goes wrong.

Prerequisites
Embeddings and similarity search, or a working vector store.
Length
8 lessons · 35 min

Syllabus

  1. 1What is RAG?Two pipelines rather than one: indexing when documents arrive, querying per request. Each of the four stages introduces its own failure, and retrieval always returns something even when your corpus cannot answer.3 min
  2. 2RAG Use CasesFour problem shapes retrieval fits and four it does not, why counting questions fail quietly, and how a million-token window moved the threshold.7 min
  3. 3Chunking strategies that survive productionStructural, recursive and semantic splitting compared, with the sizes to start from for short lookups and for prose. Chunk size sets a ceiling on what retrieval can return, and several common mistakes lower it further.8 min
  4. 4Embedding DocumentsPrepending context to a chunk before embedding it cut Anthropic's top-20 retrieval failure rate from 5.7% to 3.7%. What to store beside the vector, and why ingest has to be safe to run twice.3 min
  5. 5Storing in a Vector DBA namespace is a hard partition, not a tag. Changing the embedding model invalidates every vector, so plan the rebuild before you need it.4 min
  6. 6Retrieval ProcessAnthropic's evaluation retrieves 150 candidates and reranks to 20. Why the two stages are good at different things, how to choose each number, and the measurement that separates retrieval from generation.3 min
  7. 7GenerationThe last stage is where retrieval gets believed. Separating passages from instructions, citations that carry a validity guarantee rather than a plausible ID, and building refusal for the question your corpus cannot answer.3 min
  8. 8RAG with Dynamic FiltersA forgotten metadata filter returns everyone's documents; a forgotten namespace returns an error. When the filter is a tenancy boundary, that asymmetry is the whole argument for a partition.4 min

Practice alongside it