← Back to Series / Day 17 of 20
🔧
RAG Series · Day 17

Corrective RAG (CRAG)

Traditional RAG blindly trusts retrieved documents. CRAG adds an evaluator that corrects bad retrieval automatically.

Traditional RAG Blind Spot
🔧

Blindly Trusting Retrieved Documents

Traditional RAG has a fundamental flaw — it always trusts whatever documents the retriever returns. If retrieval returns wrong or irrelevant documents, a wrong answer is guaranteed. There is no mechanism to catch or correct this failure.

⚠️ In business applications, confidently wrong answers have serious consequences. Corrective RAG eliminates this risk with a self-correction mechanism.
What CRAG Does
🏗️

Evaluate, Then Decide What to Do

CRAG adds a Retrieval Evaluator that judges whether retrieved documents are actually relevant before using them. Based on that judgment, it takes one of three different actions.

Correct — Documents are relevant — proceed with normal RAG pipeline
Ambiguous — Partially relevant — combine retrieved docs with web search results
Incorrect — Documents are irrelevant — discard them and use web search instead
Knowledge Refinement
🔨

Cleaning What Is Retrieved

Even when documents pass the relevance check, they may contain mixed content. Knowledge Refinement cleans this up in three steps.

1
DecomposeBreak the document into individual sentences
2
FilterScore each sentence for relevance to the query — keep only relevant ones
3
RecomposeJoin the relevant sentences back into clean focused context
Web Search Integration
🌐

Fallback to Live Web Search

When retrieved documents are insufficient, CRAG queries the web using services like Tavily. The query is first rewritten into a form optimized for search engines — producing better results than the raw user question.

💡 Query rewriting example: "latest AI news" → "recent AI model releases and developments in the last 30 days" — far more effective for search engines.
CRAG in LangGraph
📊

The Graph Architecture

·retrieve — Fetch documents from vector store
·evaluate — Score each document for relevance (0 to 1)
·refine — Extract only relevant sentences from documents
·web_search — Query web when documents are incorrect or ambiguous
·generate — Produce final answer from clean verified context

Corrective RAG transforms traditional RAG from a trust-everything system into a self-correcting one. The retrieval evaluator judges relevance, knowledge refinement cleans the context, and web search provides a reliable fallback. The result is a system that never blindly trusts bad retrieval — and almost never produces hallucinated answers.