Corrective RAG: grade the evidence before you answer

Corrective RAG scores the retrieved documents and acts on the score: keep, discard, or search elsewhere. Use it when a wrong or empty retrieval would otherwise produce a confident wrong answer.

Corrective RAG in 60 seconds

  • What: a retrieval step followed by an evaluator that scores how relevant the retrieved documents are to the question.
  • Three outcomes: correct (keep and clean the documents), incorrect (discard them and fall back to another source such as web search), ambiguous (use both).
  • Why it helps: the model stops building answers on top of evidence that does not match the question.
  • Cost: one extra evaluation per request, sometimes a second retrieval, so latency and spend rise.
  • Must have: a retry cap and a defined fallback, otherwise the loop can run forever or fail silently.

Where this type fits

Corrective RAG belongs to the quality-loop family: the pipeline still retrieves and then generates, but it inspects its own intermediate result and can change course before the answer is written. The other members of that family are advanced, self, and HyDE retrieval. See the overview of RAG types for the full map.

The problem it solves

Every retrieval step returns something. A vector search always produces its top results, even when the store holds nothing relevant. Ask a support bot about a product that was launched last week, and the index may only contain pages about older products. The search returns the nearest ones by meaning, they look plausible, and the model dutifully writes an answer from them. The user receives fluent text that is wrong, and nothing in the pipeline noticed.

Think of a student writing an essay from a pile of library books that a helper fetched. A careful student skims the pile first. If the books are about the wrong topic, they say so and ask for different ones. A careless student writes the essay from whatever arrived. Basic RAG behaves like the careless student because it has no step that asks whether the pile is any good.

Even when the right document is retrieved, most of it may be noise. A long passage might contain one useful sentence among paragraphs about other things. Models can be distracted by that noise. Corrective RAG addresses both failures: it grades the evidence, removes the irrelevant parts of good evidence, and looks elsewhere when the evidence is poor.

How it works

  • Retrieve: run the normal search against the main index and take the top results.
  • Evaluate: a lightweight evaluator scores each retrieved document against the question. The published method uses a small trained evaluator; teams often use a model prompt that returns a score or a label.
  • Decide: combine the scores into one of three actions. Correct means at least one document is clearly relevant. Incorrect means none is. Ambiguous means the evidence is mixed or the evaluator is unsure.
  • Act on correct: refine the documents with a decompose-then-recompose step. Split each one into small strips, score the strips, drop the weak ones, and join the rest.
  • Act on incorrect: discard the retrieved documents and run a fallback, such as web search, then refine those results the same way.
  • Act on ambiguous: keep the refined internal documents and add the fallback results, so the generator sees both.
  • Generate: the model answers from the cleaned evidence only, with a cap on how many correction rounds are allowed.
The grade decides which repair runs before the answer is written.

The key idea in the diagram is that the evaluator sits between retrieval and generation and has the power to change what generation sees. This is what the paper behind the method, Corrective Retrieval Augmented Generation (Yan et al., 2024, often shortened to CRAG), contributes. It describes a lightweight retrieval evaluator that estimates the quality of retrieved documents and triggers one of three actions, with web search as the fallback for the incorrect case and a decompose-then-recompose step to filter what is kept.

Two details matter in practice. First, the evaluator must be cheaper than the generator, or the design loses its point. Second, the thresholds that separate correct, ambiguous, and incorrect are tuned on your own data. A threshold that works for a legal archive will not suit a recipe collection, because the typical score of a good match differs.

A worked example

Acme sells a project tool. A user asks: Does the Team plan include single sign-on? The index holds product pages, but the pricing page was updated yesterday and the new text is not indexed yet.

  • Retrieve: the top three results are an old pricing page (mentions Team and Business plans, no SSO), a security overview (mentions SSO for enterprise customers), and a blog post about the Team plan launch.
  • Evaluate: scores out of 1.0 are 0.35, 0.58, and 0.22. The high-water mark is 0.58, which sits between the lower threshold of 0.30 and the upper threshold of 0.75.
  • Decide: ambiguous. Nothing is clearly right, but nothing is clearly useless.
  • Refine internal documents: the security overview is split into sentences. Only two sentences about SSO score above 0.5, so the rest is dropped.
  • Fallback: the query is rewritten as Acme Team plan features single sign-on and sent to the fallback search. A fresh page from the company site returns, stating that SSO is included on Team from this month.
  • Generate: the model sees two SSO sentences from the older page and the fresh page text. It answers that SSO is included and cites the fresh page, noting the older overview said enterprise only.
Evaluator output for the example (illustrative) (json)
{
  "question": "Does the Team plan include single sign-on?",
  "scores": [
    { "doc": "pricing-old", "score": 0.35 },
    { "doc": "security-overview", "score": 0.58 },
    { "doc": "team-launch-blog", "score": 0.22 }
  ],
  "action": "ambiguous",
  "fallback_query": "Acme Team plan features single sign-on"
}

Building it

The sketch below keeps the whole control flow in one function so the three branches are easy to see. All helpers are placeholders: swap in your own search, grader, and model.

Corrective RAG control flow (illustrative) (python)
# All helpers below are placeholders; wire in your own search, grader and model.
LOW, HIGH = 0.30, 0.75     # tune on your own labelled questions
MAX_ROUNDS = 2             # hard cap so the loop always ends
STRIP_KEEP = 0.50

def retrieve(query, k=5):
    return vector_store.search(embed(query), k=k)          # placeholder

def grade(question, text):
    # Placeholder: a small model or prompt returning a 0..1 relevance score.
    return grader.score(question=question, document=text)

def refine(question, docs):
    # Decompose into strips, keep only the useful ones, recompose.
    kept = []
    for d in docs:
        for strip in split_sentences(d.text):               # placeholder
            if grade(question, strip) >= STRIP_KEEP:
                kept.append(strip)
    return kept

def fallback_search(question):
    # Placeholder: web or secondary-source search with a short timeout.
    q = llm.generate('Rewrite as a search query: ' + question)
    return external_search(q, timeout_s=5)                  # placeholder

def answer(question):
    docs = retrieve(question)
    evidence, used_fallback = [], False
    for round_no in range(MAX_ROUNDS):
        scores = [grade(question, d.text) for d in docs]
        best = max(scores, default=0.0)
        if best >= HIGH:
            evidence = refine(question, docs)
            break
        if best < LOW:
            # Discard weak internal evidence entirely: it would only mislead.
            docs = fallback_search(question)
            used_fallback = True
            continue
        # Ambiguous: keep the cleaned internal evidence, then add outside evidence.
        evidence = refine(question, docs)
        docs = fallback_search(question)
        evidence += refine(question, docs)
        used_fallback = True
        break
    if not evidence:
        return 'I could not find reliable information to answer this.'
    prompt = ('Answer only from the evidence. Cite it. Say if it is insufficient.\n'
              + '\n'.join(evidence) + '\nQuestion: ' + question)
    return {'text': llm.generate(prompt), 'used_fallback': used_fallback}

Note the explicit refusal at the end. If every round fails to produce evidence, the system says so rather than letting the model improvise. That single line prevents most of the harm corrective RAG is designed to avoid.

Grader prompt that returns a number (illustrative) (python)
GRADER_PROMPT = '''You grade search results.
Question: {question}
Document: {document}
Reply with one number from 0 to 1.
0 means unrelated, 1 means it directly answers the question.'''

def score(question, document):
    raw = llm.generate(GRADER_PROMPT.format(question=question, document=document))  # placeholder
    try:
        return min(1.0, max(0.0, float(raw.strip())))
    except ValueError:
        return 0.5   # unreadable output counts as ambiguous, not as a pass

Design decisions

  • Evaluator choice: start with a small, fast model prompt that outputs a score. Move to a trained classifier only when you have labelled data and the volume justifies it. The evaluator must cost far less than the generator.
  • Fallback source: pick one outside source with a known trust level. Web search brings freshness and also untrusted text, so treat its output as untrusted input and apply guardrails.
  • Thresholds: keep the low and high thresholds in configuration, not code. Re-tune them whenever the index, the grader, or the embedding model changes.
  • Latency budget: run strip scoring in parallel and give the fallback a short timeout. Return the ambiguous-path answer with internal evidence alone if the fallback is slow.
  • Access control: apply user permissions at retrieval and again to fallback results. Refinement must never mix documents the user cannot see into the answer.
  • Failure handling: cap rounds at two. On grader errors, treat the result as ambiguous. On empty evidence, refuse politely.
  • Versioning: log the grader version and thresholds with every answer so a change in behaviour can be traced to a change in the checker.

Measuring it

  • Grader accuracy: on a labelled set of question and document pairs, compute precision and recall of the relevant label. A weak grader makes the whole design worse than plain RAG.
  • Action mix: the share of requests ending in correct, ambiguous, and incorrect. A sudden shift often signals index drift or a broken grader.
  • Answer faithfulness: the share of answer claims supported by the supplied evidence, judged by people or a calibrated judge model, compared before and after adding correction.
  • Fallback value: among requests that used the fallback, the share whose final answer was judged correct, against the share of those that would have been correct without it.
  • Added latency and cost: median and 95th percentile time, and tokens per request, with and without the evaluator.
Grader precision and recall (illustrative) (python)
def grader_report(examples, threshold=0.5):
    # examples: list of (question, document, is_relevant) labelled by people.
    tp = fp = fn = 0
    for q, d, label in examples:
        predicted = grade(q, d) >= threshold
        tp += predicted and label
        fp += predicted and not label
        fn += (not predicted) and label
    precision = tp / (tp + fp) if tp + fp else 0.0
    recall = tp / (tp + fn) if tp + fn else 0.0
    return {'precision': precision, 'recall': recall}

When to use it, and when not to

SituationUse this type?Why
The index is incomplete or goes out of date quicklyYesThe fallback fills gaps, and the evaluator notices when the index has nothing useful.
Wrong answers are costly, such as policy or compliance questionsYesGrading evidence before answering reduces confident errors.
Questions are narrow, the index is curated, and retrieval is reliableProbably notThe evaluator adds cost and latency for few corrections.
Responses must arrive in well under a secondOnly with a tiny graderEach grading call and any fallback adds delay.
No trusted fallback source existsPartlyYou can still discard bad evidence and refuse, but you lose the recovery path.
Questions need evidence from several sources in turnConsider agenticCorrective RAG repairs one retrieval; it does not plan multi-step research.

Trade-offs

DimensionEffectWhat to do about it
QualityFewer answers built on irrelevant evidence; cleaner context for the model.Measure faithfulness before and after so the gain is visible.
LatencyAt least one extra model call; more if the fallback runs.Use a small grader, parallel strip scoring, and a short fallback timeout.
CostGrading tokens on every request plus fallback calls on some.Grade only the top few documents and cache scores for repeated pairs.
ComplexityThresholds, a fallback integration, and a refinement step to maintain.Keep thresholds in configuration and log every decision.
Failure modesA poor grader discards good evidence or keeps bad evidence; fallback text may be untrusted or wrong.Test the grader on its own, cap rounds, and treat fallback text as untrusted.

Advanced RAG also improves retrieval, but it does so by tuning the pipeline: rewriting queries, reranking, compressing context. It usually does not decide to go elsewhere when the index fails. Corrective RAG adds that decision. The two combine well: rerank first, then grade the reranked list.

Self-RAG moves the checking into the model itself, with the model judging passages and its own output, while corrective RAG uses a separate evaluator before generation. Agentic RAG goes further by letting an agent plan several searches. If your only problem is that one retrieval sometimes fails, corrective RAG is the smaller step.

What this means for your role

Common mistakes

Further reading

Corrective RAG is a small change with a large effect: it makes the pipeline admit when its evidence is weak. Add it where a wrong answer costs more than an extra model call.

Search topics

↑↓ to move · Enter to open · Esc to close