Prompt Engineering Guide
πŸ˜ƒ Basics
πŸ’Ό Applications
πŸ§™β€β™‚οΈ Intermediate
🧠 Advanced
Special Topics
🌱 New Techniques
πŸ€– Agents
βš–οΈ Reliability
πŸ–ΌοΈ Image Prompting
πŸ”“ Prompt Hacking
πŸ” Language Model Inversion
πŸ”¨ Tooling
πŸ’ͺ Prompt Tuning
πŸ—‚οΈ RAG
πŸ”§ Models
🎲 Miscellaneous
πŸ“™ Vocabulary Resource
πŸ“š Bibliography
πŸ“¦ Prompted Products
πŸ›Έ Additional Resources
πŸ”₯ Hot Topics
✨ Credits
πŸ—‚οΈ RAG🟦 Corrective RAG

Corrective RAG

🟦 This article is rated medium
Reading Time: 3 minutes
Last updated on March 2, 2025

Valeriia Kuka

Corrective Retrieval-Augmented Generation (CRAG) is a novel approach designed to improve the robustness and accuracy of Retrieval-Augmented Generation (RAG) systems. CRAG enhances RAG by introducing a retrieval evaluator that assesses the quality of retrieved documents and applies corrective strategies when retrieval fails or returns inaccurate results.

Instead of blindly relying on retrieval, CRAG:

  1. Evaluates retrieved documents to determine their reliability.
  2. Triggers corrective actions to refine or replace incorrect retrievals.
  3. Leverages web search to supplement missing or inaccurate knowledge.
  4. Filters and refines retrieved content to improve knowledge integration.

How CRAG Differs from Standard RAG

FeatureStandard RAGCRAG
Uses retrieved texts as-isβœ… Yes❌ No
Evaluates retrieval quality❌ Noβœ… Yes
Handles incorrect retrievals❌ Noβœ… Yes
Uses web search for correction❌ Noβœ… Yes
Filters noisy retrievals❌ Noβœ… Yes
Plug-and-play for any RAG model❌ Limitedβœ… Yes

Why is CRAG Needed?

While RAG helps mitigate hallucinations in large language models (LLMs) by incorporating external knowledge, it is highly dependent on the quality of retrieved documents. When retrieval fails (i.e., retrieves incorrect or irrelevant documents), RAG can actually make LLM outputs worse by reinforcing errors.

CRAG solves this problem by:

  • Evaluating retrieved documents for correctness.
  • Applying different retrieval strategies based on confidence scores.
  • Filtering and refining retrieved knowledge for better utilization.

How CRAG Works

CRAG introduces a retrieval evaluator that categorizes retrieved documents into three confidence levels and applies corresponding actions:

Confidence LevelAction
High confidence βœ…Use and refine retrieval (Correct)
Low confidence ❌Discard and replace with web search (Incorrect)
Medium confidence πŸ€”Blend retrieved and web search knowledge (Ambiguous)
  1. Retrieval Evaluation: A lightweight retrieval evaluator (based on T5) scores the quality of retrieved documents.

If the evaluator detects poor retrieval, CRAG modifies the retrieval process before generation.

  1. Corrective Actions: CRAG applies three corrective actions:

    • (a) Correct: If retrieval is reliable: Refines retrieved documents using a decompose-then-recompose technique. Removes irrelevant information while retaining key knowledge.

    • (b) Incorrect: If retrieval is unreliable: Discards faulty retrievals. Triggers a web search to retrieve more reliable information.

    • (c) Ambiguous: If retrieval confidence is unclear: Combines refined retrieval with web search results. Ensures more diverse and robust knowledge integration.

  2. Knowledge Refinement: Breaks retrieved documents into smaller "knowledge strips". Filters out irrelevant information while keeping the most critical insights. Ensures higher-quality input for LLMs.

  3. Web Search for Knowledge Expansion: Generates search queries using a query rewriter. Extracts knowledge from authoritative sources (e.g., Wikipedia). Filters web search results to avoid misinformation.

Note

You can find the code for CRAG on GitHub.

Main Benefits of CRAG

FeatureBenefits
Improves accuracy & robustnessβ€’ Corrects misleading retrievals.
β€’ Reduces hallucinations in LLMs.
β€’ Improves fact-checking capabilities.
Enhances retrieval & knowledge utilizationβ€’ Filters noisy or irrelevant retrieved content.
β€’ Refines useful knowledge before generation.
Expands knowledge beyond static corporaβ€’ Dynamically searches the web when needed.
β€’ Ensures fresh and updated information.
Works with any RAG modelβ€’ Plug-and-play integration with LLaMA, GPT-4, Alpaca, Self-RAG, etc.
β€’ No need to fine-tune the generator.
Lightweight & efficientβ€’ Uses a small T5-based retrieval evaluator (0.77B parameters).
β€’ Minimal computational overhead (only 2-5% more FLOPs).

Conclusion

CRAG significantly improves RAG-based LLMs by introducing a retrieval evaluator and corrective retrieval strategies. It ensures that LLMs generate factually accurate, concise, and reliable contentβ€”even when retrieval goes wrong.

Valeriia Kuka

Valeriia Kuka, Head of Content at Learn Prompting, is passionate about making AI and ML accessible. Valeriia previously grew a 60K+ follower AI-focused social media account, earning reposts from Stanford NLP, Amazon Research, Hugging Face, and AI researchers. She has also worked with AI/ML newsletters and global communities with 100K+ members and authored clear and concise explainers and historical articles.

Footnotes

  1. Yan, S.-Q., Gu, J.-C., Zhu, Y., & Ling, Z.-H. (2024). Corrective Retrieval Augmented Generation. https://arxiv.org/abs/2401.15884 ↩