Advanced11 min
Self-Corrective RAG: Grade, Rewrite, Re-Retrieve
Corrective RAG adds document grading and question rewriting to the retrieval loop — if retrieved documents don't answer the question, the system rewrites the query and tries again.
Quick Reference
- →Self-Corrective RAG = retrieve → grade documents → generate OR rewrite query → re-retrieve
- →Document grading uses structured output (GradeDocuments) to score relevance before generation
- →If documents fail grading, the query is rewritten and retrieval runs again with the improved query
- →Prevents hallucination from irrelevant context — the LLM only sees high-quality documents
- →Implement as a LangGraph cycle: retrieve → grade → conditional edge → generate or rewrite
- →Typically improves answer quality by 20-35% over naive RAG on ambiguous queries
Why Standard RAG Fails
Retrieve → grade → generate if relevant, rewrite and re-retrieve if not (max 2 retries)
Standard 2-step RAG (retrieve → generate) has a critical weakness: it trusts whatever the retriever returns. If the query is ambiguous, poorly worded, or the relevant documents use different terminology, the retriever returns irrelevant chunks. The LLM then either hallucinates an answer from bad context or produces a generic non-answer. Self-Corrective RAG adds a feedback loop that catches this before generation.
| Step | Standard RAG | Self-Corrective RAG |
|---|---|---|
| 1. Retrieve | Retrieve top-K docs | Retrieve top-K docs |
| 2. Validate | Skip — trust retriever | Grade each document for relevance |
| 3a. If good | Generate answer | Generate answer |
| 3b. If bad | Generate anyway (hallucinate) | Rewrite query → re-retrieve → grade again |
| Result | 60-70% answer quality | 85-95% answer quality on ambiguous queries |