Skip to content
ML to LLMs
Learning path

Module 16

Retrieval-augmented generation

Ground LLM answers in your documents: ingest, chunk, embed, retrieve, rerank, generate, and evaluate.

  1. 1. The RAG pipelineBuild retrieval-augmented generation end to end (ingest, chunk, embed, index, retrieve, rerank, construct context, generate with citations) and diagnose its failures.45 min
  2. 2. Vector searchPick a similarity metric and an approximate nearest-neighbor index (IVF, HNSW, product quantization), trade recall against latency and memory, and combine BM25 with dense retrieval using reciprocal rank fusion.40 min

RAG gives a model the right context at query time instead of hoping the answer is stored in its weights. Most RAG failures are retrieval failures, so this module treats retrieval as a search system with its own metrics.

StepWhat happensFailure mode
Ingestparse and clean sourcesmissing or corrupted text
Chunksplit documents into retrievable unitstoo small loses context; too large dilutes relevance
Embed and indexstore vectors plus metadatawrong model, stale index
Retrievefind relevant chunkspoor query or low recall
Rerankscore candidates more preciselyextra latency
Generateanswer using the supplied contexthallucination or weak grounding
Evaluatemeasure retrieval and answer qualityonly judging fluency
#LessonYou will be able to
1The RAG pipelinebuild each stage, compute retrieval metrics, and decide between RAG and fine-tuning
2Vector searchchoose a similarity metric and an ANN index (IVF, HNSW, PQ), trade recall against latency and memory, and fuse BM25 with dense results

Interactive labs: RAG pipeline · Approximate nearest neighbors

Next moduleModule 17: LLM evaluation