Skip to main content

Corrective RAG (CRAG)

Corrective RAG adds self-evaluation and correction mechanisms to traditional RAG, using LangGraph to implement a sophisticated workflow that validates retrievals and uses fallback strategies when needed.

Overview

CRAG evaluates the quality of retrieved documents and takes corrective actions:
  • Relevant documents: Use directly for generation
  • Ambiguous documents: Apply query transformation and re-retrieve
  • Irrelevant documents: Fall back to web search
CRAG significantly improves answer accuracy by validating retrieval quality before generation.

Architecture

Implementation

See the Advanced RAG Techniques page for complete CRAG implementation with LangGraph.

Document Grading

Evaluate retrieval relevance with LLM-based grading

Query Transformation

Rewrite queries for better retrieval on ambiguous results

Web Search Fallback

Use Tavily AI for web search when local docs insufficient

LangGraph Workflow

Orchestrate the complete CRAG workflow with state management

Advanced RAG Techniques

Complete CRAG implementation with code examples and LangGraph workflow

Build docs developers (and LLMs) love