Course contentsShow
← Machine Learning and Deep Learning
Lesson 2054 of 3,53843. Retrieval-Augmented Generation: Advanced TechniquesFree lesson

Corrective RAG Patterns

Detecting poor retrieval results and taking corrective actions like query rewriting or web search fallback.

Corrective RAG Patterns

What you'll learn: How to detect when retrieval fails and automatically fix it through query rewriting or fallback strategies.

The Problem with Blind Retrieval

Even sophisticated RAG systems sometimes retrieve irrelevant, incomplete, or contradictory documents. Rather than blindly feeding poor results to your LLM, Corrective RAG adds a quality-checking layer that evaluates retrieval results and takes corrective action when they're insufficient.

How Corrective RAG Works

Think of it like a smart assistant who double-checks their research. If the first search doesn't yield good answers, they rephrase the question or consult a different source.

The pattern typically involves three steps:

1. Retrieval Quality Assessment

After retrieving documents, evaluate their relevance using:

  • An LLM-based relevance classifier ("Are these documents helpful for answering the query?")
  • Confidence scores from your vector database
  • Semantic similarity thresholds

2. Decision Making

Based on the assessment:

  • Good retrieval → Proceed normally to generation
  • Marginal retrieval → Refine the query and retrieve again
  • Poor retrieval → Trigger fallback mechanisms

3. Corrective Actions

When retrieval quality is insufficient:

  • Query rewriting: Reformulate using techniques like HyDE or step-back prompting
  • Web search fallback: Query external search engines for fresh information
  • Multi-source routing: Try alternative knowledge bases
  • Iterative refinement: Use initial results to generate better queries

This pattern is especially valuable when dealing with ambiguous questions, rapidly changing information, or edge cases your knowledge base doesn't cover well.

Key Takeaway: Corrective RAG patterns transform passive retrieval into an adaptive process that self-diagnoses failures and automatically takes remedial action, significantly improving answer quality and system robustness.