Corrective RAG
A linear, one-concept-per-lesson path through Corrective RAG (CRAG), grading retrieved chunks for relevance and correcting a bad retrieval before it ever reaches generation, built from scratch with no framework, from your first relevance grade to a complete FastAPI corrective RAG service backed by ChromaDB. 26 lessons · 3 tiers.
Prerequisites: Completion of Naive RAG, or already comfortable with embeddings, cosine similarity, top-k retrieval, and why naive retrieval can confidently return the wrong chunk - Lesson 2 here is a compressed recap of that failure, not a full re-teach.
Lessons use Google's Gemini free tier (gemini-embedding-001 for embeddings, gemini-3.5-flash-lite for chat and grading), the same models as this site's other RAG courses. No Docker and no database through most of the course; the Advanced tier graduates the vector store to a local ChromaDB instance, still no server or account required.
Built on ChromaDB, the open-source vector database this course graduates to in the Advanced tier.

Beginner
Grading a retrieved chunk, filtering out the bad ones, and rewriting the query when nothing survives.
- 01What Is Corrective RAGGitHub
- 02Where Naive Retrieval Is Confidently WrongGitHub
- 03Grading a Retrieved ChunkGitHub
- 04Grading All Top-k ChunksGitHub
- 05Filtering Out Incorrect ChunksGitHub
- 06Query RewritingGitHub
- 07Re-retrieval with the Rewritten QueryGitHub
- 08End-to-End Corrective QAGitHub
- 09Checkpoint: CLI Q&A That Self-CorrectsGitHub
Intermediate
Strip-level grading, three-way confidence buckets, and making the correction precise and bounded.
- 10Strip-Level GradingGitHub
- 11Recomposing Context from Relevant StripsGitHub
- 12Confidence Buckets and ActionsGitHub
- 13Persisting Grading ResultsGitHub
- 14Query Rewriting StrategiesGitHub
- 15Prompting for Disclosed CorrectionsGitHub
- 16Failure Modes of Grading and RewritingGitHub
- 17Minimal Evaluation: Before vs. After CorrectionGitHub
- 18Checkpoint: Notes Search with a Corrected IndicatorGitHub
Advanced
Making correction affordable and graduating to ChromaDB, plus a capstone.
- 19Where Per-Chunk Grading Gets ExpensiveGitHub
- 20A Cheap Pre-Filter Before GradingGitHub
- 21Bounding Correction LoopsGitHub
- 22External Web Search as the Incorrect BranchGitHub
- 23Refactoring into ingest(), grade(), correct(), ask()GitHub
- 24Wrapping It as a ServiceGitHub
- 25Capstone: A Complete Corrective RAG ServiceGitHub
- 26Where Corrective RAG Hits a WallGitHub