Skip to main content
Core8 min1365 words

Evaluating RAG: retrieval, groundedness, and answer-quality metrics

A practical RAG evaluation system that separates retrieval from generation, links metrics to failure modes, calibrates LLM judges, and turns the eval set into a release gate.

Article contents
  1. 01Short answer: do not reduce RAG to a single score
  2. 02Measure retrieval against labels, not the impression left by the answer
  3. 03Evaluate groundedness at the level of atomic claims
  4. 04Answer quality depends on the task, not only on similarity
  5. 05The eval set must represent the corpus, risk, and real traffic
  6. 06The error matrix tells you which component to change
  7. 07A release gate and production loop complete the evaluation

Prerequisites

Short answer: do not reduce RAG to a single score

Reliable RAG evaluation answers at least three different questions: did the retriever find the required evidence, is the answer grounded in the retrieved context, and does it solve the user task. One aggregate score hides the cause of failure. High groundedness does not help if the system faithfully summarizes an irrelevant chunk, and a correct answer does not prove retrieval quality because the model may have reproduced the fact from parametric memory.

Build the eval as a diagnostic tree. First pin the corpus version, query, allowed documents, and relevance labels. Then store retrieved IDs, ranks, and texts, and only after that the answer, citations, and grader verdicts. This trace distinguishes an ingestion defect from a retrieval miss, reranker regression, unsupported claim, or poor answer form. A release gate should use separate thresholds and critical failure cases instead of one attractive average.

  • Retrieval: whether the required documents or chunks appear in top-k and at which positions.
  • Grounding: whether the context supports every verifiable claim in the answer.
  • Answer quality: whether the answer is correct, relevant, complete, and useful for the task.
  • Operations: latency, cost, empty retrieval, timeout, and stale-source outcomes.
  • Safety: ACL leakage, prompt injection, unsafe citations, and correct abstention.

Measure retrieval against labels, not the impression left by the answer

For every eval query, label the relevant document or chunk IDs, ideally with graded relevance: critical evidence, useful context, and irrelevant material. Recall@k shows what share of the required objects the system found in the first k results; precision@k shows how many of those results are actually relevant. Mean reciprocal rank is useful when the first correct result matters, while nDCG accounts for ordering and multiple relevance grades.

Tie the metric to the UX and generator contract. If the answer can consume only four chunks, Recall@50 does not describe the effective context. Evaluate document-level and chunk-level retrieval separately: the correct document combined with poor chunking can look like a partial success. For metadata filters, tenant ACLs, and time-sensitive queries, add constraint correctness: a relevant but unauthorized or stale document is an error, not a positive result.

Evaluate groundedness at the level of atomic claims

Break the answer into verifiable claims and, for each one, store supported, contradicted, or not-in-context together with the exact source spans. Groundedness or faithfulness measures support from the supplied context, but it does not guarantee that the source itself is true. Evaluate citation correctness separately: the citation must point to the fragment that proves the claim, not merely to a thematically related document.

A reference-free judge is useful for a broad regression suite, but its verdict is not ground truth. Calibrate the judge on a human-labeled slice, measure agreement and run-to-run stability, pin the judge version and prompt, and send borderline and high-risk cases to a person. Include negative examples with conflicting chunks, missing answers, and attempts to induce the model to use external knowledge; otherwise the grader teaches the team to optimize only easy positive cases.

Answer quality depends on the task, not only on similarity

Answer correctness compares the result with a reference answer or rubric, but literal matching is rarely sufficient for open-ended responses. Define mandatory facts, acceptable formulations, prohibited claims, required format, and abstention conditions. For extraction, field-level precision and recall are appropriate; for support, resolution correctness and escalation; for research, coverage of key claims, provenance, and presentation of uncertainty.

Answer relevance checks whether the system answered the actual question, while completeness checks whether required parts were omitted. Do not reward verbosity: a short, supported answer may be better than a comprehensive but risky response. Introduce a separate abstention score for queries that the corpus does not cover. A RAG system that refuses without evidence may have a lower superficial answer rate but better error control.

The eval set must represent the corpus, risk, and real traffic

Start with a small set of manually verified production-like queries and a versioned manifest. Stratify it by intent, difficulty, language, answer length, source type, freshness, ACL, and cost of error. Add easy lookups, multi-hop questions, ambiguous phrasing, no-answer cases, adversarial instructions inside documents, and queries after corpus updates. Do not split train and test with random near-duplicates from the same document.

Synthetic questions help expand coverage but do not replace human review: a generator can create a query that unnaturally repeats the chunk and inflates retrieval scores. Mark the provenance of every case and report human, production, and synthetic slices separately. Every incident or confirmed user correction should produce a sanitized regression case when data policy permits it.

The error matrix tells you which component to change

If retrieval recall is low, investigate ingestion coverage, chunk boundaries, query rewriting, embeddings, filters, and hybrid search before changing the generator prompt. If recall is good but precision or nDCG is weak, tune ranking, deduplication, and top-k. If the evidence is correct but groundedness drops, inspect context assembly, instruction hierarchy, claim scope, and citation generation. If groundedness is high but the answer score is low, the problem may be an incomplete corpus or a mismatched task rubric.

Change one controlled factor per experiment and preserve retrieved snapshots for paired comparison. Otherwise, changing chunking, the embedding model, and the prompt at the same time will not explain the improvement or regression. Segment-level results matter more than the portfolio average: gains on easy FAQ queries must not hide deterioration in ACL, no-answer, or multilingual slices.

  • Missed evidence → investigate ingestion, query, filter, embedding, or retrieval.
  • Evidence ranked too low → investigate reranking, hybrid weights, deduplication, or top-k.
  • Supported context, unsupported claim → investigate generation, context assembly, or the judge.
  • Correct answer, wrong citation → treat citation alignment as a separate defect.
  • Good offline score, poor production outcome → investigate dataset drift or rubric mismatch.

A release gate and production loop complete the evaluation

In CI, run deterministic retrieval metrics against a pinned corpus snapshot, and run model-based graders with pinned versions, prompts, and retry policy. A gate may require zero critical ACL leaks, no-answer false confidence below an agreed threshold, non-regression on key slices, and bounded latency and cost. Set concrete thresholds from the baseline and risk appetite of your own system; there is no universal safe number.

After canary rollout, collect privacy-safe traces, user corrections, citation opens, empty retrieval, and escalation outcomes, but do not treat an implicit click as proof of correctness. Sampling routes difficult cases to review, and confirmed failures return to the eval set. Rollback restores previous corpus, retriever, reranker, and prompt versions as a coordinated bundle. The audit trail must show which dataset, code, data, and graders authorized the release.

Practical examples

Eval contract for an internal policy assistant

The team prepares 180 versioned queries covering direct lookup, multi-policy synthesis, superseded policy, no-answer, and cross-tenant traps. For every case, reviewers label allowed document IDs, graded relevance, required facts, and acceptable abstention. CI calculates Recall@5 and nDCG@5, then claim-level groundedness and citation alignment. Release is blocked by any cross-tenant retrieval, regression in critical slices, or unsupported mandatory claim; canary feedback adds confirmed corrections back into the set without storing private user text.

FAQ

What is the single most important metric for RAG?

There is no single sufficient metric. Start with retrieval recall for the required evidence, but always combine it with groundedness, task-specific answer quality, and critical safety cases.

Do RAG evaluations need reference answers?

They are very useful for correctness and controlled releases, but some groundedness can be evaluated against the context without a reference answer. Judge-based scores still need calibration on human labels.

How does groundedness differ from correctness?

Groundedness asks whether the supplied context supports the answer. Correctness asks whether the answer is right for the task or reference. A false source can support a grounded but incorrect answer.

How many queries should an eval dataset contain?

Start with a set that covers the important intents and worst risks rather than an arbitrary number. Expand it with production failures, new corpus slices, and statistically more stable samples.

Related materials

Sources

  1. RAG evaluators — Microsoft Foundryofficial
  2. Knowledge base evaluation metrics — Amazon Bedrockofficial
  3. Evaluate your RAG system — NVIDIA RAG Blueprintofficial
  4. Evals API — OpenAIofficial
  5. RAGAS: Automated Evaluation of Retrieval Augmented Generationprimary