Self-Correcting RAG: CRAG & Self-RAG: overview
- Source
- From the RAG & Agents Engineering course
- By
- Sourav Banerjee
- Last updated
- 9 Nov 2026
A RAG pipeline that never checks its own work answers from whatever retrieval returns, relevant or not. This module adds the checks. Corrective RAG (CRAG) grades the retrieved chunks before generation and looks elsewhere when too few pass; Self-RAG also decides whether to retrieve at all and checks the answer after generation for support and usefulness. Every check is another model call, so the module ends by counting what each pipeline spends and where the spending buys nothing. The T9.2 notebooks build on four ideas: grading retrieval before generation, refining the context, the four reflection decisions, and checking that an answer is grounded.
The running example is the twelve-chunk Larkspur Cloud handbook from T5.1 and its three golden questions, plus two questions the handbook cannot answer: Does Larkspur offer GPU servers? and How much does the starter plan cost per month? The handbook is private, so a web search cannot answer for it. That makes it a fair stress test for a pipeline whose fallback is the web.
In short
- CRAG puts a retrieval evaluator between retrieval and generation. In notebook 01a it grades each chunk yes or no and searches the web when half or fewer pass; in 01b it scores each chunk from 0 to 1 and picks Correct (above 0.7), Incorrect (below 0.3) or Ambiguous.
- Knowledge refinement cuts the context down to the parts that answer the question before generation. 01b does it with an LLM call that turns a document into bullet points.
- Self-RAG makes four judgements, the reflection tokens of the paper: retrieve or not, is this chunk relevant, is the answer supported, is it useful. Notebook 02a asks an LLM for each one and caps the retry loops at
max_iterations = 2. - The groundedness check is the hallucination guard, and in 02a it has two holes: it passes without a call when there are no documents, and its regenerate loop ignores the iteration cap.
- Correction is paid in LLM calls. In the lab at
k = 5, the baseline makes 1 call per question, CRAG 5.6 on average and Self-RAG 15.0, up to 20 on a question the handbook cannot answer.
Mental model
- A customer asks “Can I export my data after I cancel my plan?”
- The retriever returns the top k chunks, here five.
- CRAG and Self-RAG grade each chunk, one LLM call per chunk.
- When too few chunks pass, the context is fixed. CRAG rewrites the question and searches the web; Self-RAG rewrites it and retrieves again.
- The model answers from the context that survived.
- Self-RAG grades the answer twice more: is it grounded in the chunks, and is it useful? A no goes back round.
- The answer goes out. On this question at k = 5 the baseline made 1 LLM call, CRAG 7 and Self-RAG 9.
There are two places to catch a bad answer. CRAG checks the context before generation; Self-RAG also checks the answer after it. Each check is an LLM call, and each failed check sends the question round again, so the price of correction is set by how often the checks fail.
Interactive lab
What correction costs: open the file in a browser. Pick Can I export my data after I cancel my plan? and move k from 3 to 4: CRAG still keeps both evidence chunks, yet it now searches the web, because 2 of 4 is not more than half. Then pick How much does the starter plan cost per month? at k = 5 and read the Self-RAG row: three retrieval passes, 20 LLM calls, and a final generation with no context that the groundedness check never examines.
How it connects
- Before: T5.1 supplies the handbook, the golden questions and the baseline these pipelines are compared against. T6.2 teaches query rewriting, and T9.1 the relevance grader and bounded retry loop that CRAG and Self-RAG both reuse. T8.1 covers reflection as a general agent pattern.
- Next: T9.3 routes the question before retrieval and adds a hallucination grader of its own. T9.5 turns these checks into feedback loops, and T15.1 weighs CRAG and Self-RAG against the other agentic RAG designs.
Key Takeaways
- Grade the context before you generate from it, and log the grade: the route a request took is the first thing to read when an answer is wrong.
- Pick the fallback by where the answer can live. A web search cannot answer for a private handbook; rewrite and retry against your own index first, and refuse when the corpus has nothing.
- A groundedness check guards only the cases it runs on. Make "no documents" a refusal, never an automatic pass.
- Count LLM calls per question on your golden set before you ship a correction loop, and bound every loop with a counter that a node, not a router, updates.