Retrieval-Augmented Generation: The Complete Course
How to make a language model answer from your documents, correctly, with citations, and say so when it cannot.
Retrieval-augmented generation (RAG) looks simple: find some text, paste it into a prompt, ask the model. Most of the work is in everything around that: getting documents in without losing their tables, finding the right piece among thousands, keeping old and private documents out, making the answer cite its source, and proving all of it with numbers. This course teaches each stage through one system you build piece by piece: Hollin Answers, an assistant over the documents of Hollin Home Appliances, a made-up appliance maker, for its support agents, repair partners and customers. Hollin is fictional; every lesson also opens with a real, cited case.
Who this course is for
| You are... | Start at |
|---|---|
| New to Python or to calling a language model | The AI Engineering course Module 0, Module 1 and Module 7 first, then Module 1 here |
| An engineer who has built a basic RAG demo | Module 1 as a quick check, then Module 2 |
| Already running RAG in production | Modules 6, 8, 9, 11 and 12, then the capstone |
| Mostly interested in quality | Module 1, Lesson 2, then Module 11 |
| Mostly interested in security and permissions | Module 2, Lesson 1; Module 5, Lesson 3; Module 9, Lesson 4; Module 12, Lesson 4 |
Every module's README lists what you need to know before starting it, so you can check whether it is safe to skip the one before.
Prerequisites
| You should be comfortable with | Level | Where to learn it in depth |
|---|---|---|
| Python: functions, dictionaries, list comprehensions, classes | Intermediate | AI Engineering Module 1 |
| Calling a language model, prompts, tokens, temperature | Basic | AI Engineering Modules 0 and 7 |
| Structured output with Pydantic | Basic | AI Engineering Module 7 |
| Vectors and a dot product | Basic, explained again in Module 4 | AI Engineering Module 4 |
| SQL and a web API | Basic, for Modules 10 and 14 | AI Engineering Modules 10 and 11 |
| Docker | Basic, for Module 14 only | AI Engineering Module 13 |
The AI Engineering course has a one-module introduction to RAG (its Module 8). This course is the full treatment: if you have done that module, you can start here at Module 2.
What you need
- A Google account, to run code in Google Colab and to keep your
hollin-answersrepository in Google Drive between sessions. Nothing to install. - One free API key, from Groq or Google Gemini, to use in Colab. Or no key at all, if you run a model on your own computer with Ollama and work in a code editor.
- Embedding models and rerankers run locally from Hugging Face and need no key.
- For the capstone and a few production lessons (PostgreSQL with pgvector, Docker Compose, CI), your own computer. Those lessons say so.
Setup takes about ten minutes: course-guide/02-setup-colab-and-llm-providers.md.
The modules
| # | Module | What you add to Hollin Answers | Needs first |
|---|---|---|---|
| 1 | RAG Foundations | The first grounded answer with a citation; which sources need retrieval and which need a database | Python and one model call |
| 2 | Document Ingestion and Parsing | Loaders for HTML, PDF, CSV, email and Markdown; clean text; duplicates caught; a typed record with access rights | Module 1 |
| 3 | Chunking | Chunks that keep headings and tables together, with stable IDs and metadata | Module 2 |
| 4 | Embeddings | A cached, versioned embedder and the first retrieval scores on the labelled questions | Module 1 |
| 5 | Vector Stores and Indexing | Chroma and FAISS behind one retriever interface, permission filters inside the search, updates and deletes | Module 4 |
| 6 | Search: Dense, Sparse, and Hybrid | BM25, hybrid search with fusion, thresholds, current-over-archived ranking | Modules 4 and 5 |
| 7 | Query Understanding and Transformation | Rewritten follow-up questions; routing to documents or to the case database | Modules 1, 4, 5 and 6 |
| 8 | Reranking and Post-Retrieval Processing | A cross-encoder reranker and a context assembler that fits the budget | Modules 4, 5 and 6 |
| 9 | Generation, Grounding, and Citations | Grounded answers, verified citations, "I don't know", injected text contained | Modules 1, 5 and 8 |
| 10 | RAG Architectures and Patterns | Corrective and agentic RAG in LangGraph, text-to-SQL, compared with the plain pipeline | Modules 5 to 9 |
| 11 | Evaluation | An evaluation harness, a judge you have checked, and a regression gate | Modules 4, 5, 6 and 9 |
| 12 | Production Engineering | Caching, freshness, access control at every step, tracing, fallbacks | Modules 5 to 9 |
| 13 | Advanced and Emerging Topics | Query-log mining, unanswerable-question detection, a corpus audit | Modules 6, 8, 9, 11 and 12 |
| 14 | Capstone: A Production RAG Service | A multi-tenant FastAPI service on PostgreSQL with pgvector, and a gauntlet of probes in CI | The labs of Modules 5, 6, 7, 8, 9, 11 and 12 |
How each lesson works
Every lesson is a walk through one Hollin example, one picture at a time:
- The situation: a problem at Hollin, brought by a named person.
- A real case, first: something that really happened, from a published source, cited.
- The idea: fifteen to thirty figures, one idea each, one running example.
- Run it: code with a walkthrough of every line.
- Break it: a failure you cause on purpose.
- In production: what teams do with this at scale.
- Check yourself: questions, one exercise, key terms and sources.
Each module ends with a lab (a guided build of its piece of Hollin Answers) and an incident file (a real, published failure replayed on Hollin's data and fixed). More detail: course-guide/01-how-this-course-works.md.
The tools you will use
Python throughout, plain Python first for every mechanism. LangChain for models, retrievers and text splitters, and LangGraph for loops and state, so the same code works with Groq, Gemini or Ollama. sentence-transformers for local embeddings and rerankers, rank_bm25 for keyword search, Chroma and FAISS in notebooks, PostgreSQL with pgvector and FastAPI for the service, Docker Compose to run it. Everything is open source apart from the hosted model services.
Course guide
| File | Read it when |
|---|---|
| 01-how-this-course-works.md | Before your first lesson |
| 02-setup-colab-and-llm-providers.md | Before you run any code |
| 03-hollin-answers.md | To meet Hollin, the people, the sources and the dates |
| 06-shared-data.md | To see the corpus, questions and users every module reuses |
| 04-style-guide.md | Only if you are writing or editing lessons |
| 05-image-style-guide.md | Only if you are drawing the course figures |