Evaluating retrieval and grounded answers
How to measure whether a retrieval step finds the right passages and whether the generated answer sticks to them: recall and precision at k, nDCG, faithfulness, and the grounding check that runs before an answer is shown.
What it is
A retrieval-augmented pipeline has two parts that fail in different ways: a retriever that searches for passages, and a generator that writes an answer from them. Evaluating it means asking two questions in turn: did the retriever bring back the passages that hold the answer, and did the generator stay inside them? Each question has its own metrics and its own inputs, and a single score on the final answer doesn't tell you which part broke.
Retrieval metrics come from classic information retrieval. Precision is the fraction of retrieved documents that are relevant; recall is the fraction of relevant documents that were retrieved. Because a user reads the top results and not the whole list, both are usually cut at a rank: precision@10 counts relevant results among the first ten, though it ignores where in those ten they sit. Discounted cumulative gain (DCG) fixes that with graded relevance and a logarithmic discount for lower positions, and nDCG divides by the DCG of the ideal ordering, so each query scores between 0 and 1 and queries can be compared. Offline, these scores rest on relevance judgments: a person, or a model, marks each returned document as relevant or not, on a binary or a graded scale.
In a RAG setting the "documents" are chunks, and Ragas names the same idea context precision: it averages precision@k over the ranks at which a relevant chunk appears, so a relevant chunk ranked first counts for more than one ranked fifth. Version 0.2 offers three ways to decide what is relevant: an LLM compares each chunk with a reference answer, an LLM compares each chunk with the generated response when no reference exists, or a non-LLM distance measure compares each chunk with reference chunks you labeled, with no model involved.
Faithfulness measures the generator. In the Ragas definition, the answer is split into individual claims, each claim is checked against the retrieved context to see whether it can be inferred from it, and the score is the number of supported claims divided by the total, from 0 to 1. Its worked example: an answer that says Einstein was born in Germany on 20 March 1879, checked against a passage giving 14 March, has one supported claim out of two and scores 0.5. Note what the score compares against: the retrieved text, not the truth. If retrieval brings back the wrong policy and the answer repeats it faithfully, faithfulness stays high.
| Metric | Question it answers | Needs | Blind spot |
|---|---|---|---|
Recall@k | Are the passages that hold the answer in the top k? | Labeled relevant chunks per question | Says nothing about order or about the answer |
Precision@k | How much of the top k is noise? | Same labels | Ignores position inside the top k |
nDCG | Are the best passages ranked highest? | Relevance labels, graded or binary | More labeling work than binary |
Context precision | Are relevant chunks near the top of what was passed to the model? | A reference answer, reference chunks, or an LLM judge | Depends on the judge when no reference exists |
Faithfulness | Is each claim in the answer supported by the retrieved text? | A claim checker (an LLM judge or a classifier), no reference | Blind to wrong retrieval |
Answer relevance or completeness | Does the answer address the question asked? | An LLM judge, no reference | Blind to invented facts |
Who does the labeling. Ranking metrics need a relevance label on each chunk, and a model can produce them: an LLM reads the question and the chunk and returns relevant or not, and the labels feed the ranking metrics. The same technique, an LLM as judge, grades faithfulness and completeness. Evidently's guide to building one starts with a small, varied dataset that you label by hand, then a prompt written for your own failure modes, then a comparison of the judge's labels with yours using precision and recall. Its practical rules: ask yes-or-no questions, split tone and accuracy into separate judges rather than one combined score, and ask the model for its reasoning so you can debug a disagreement.
The same check in the request path. Cloud vendors sell a grounding check that takes a generated text plus the source passages and reports how well the text is supported. Google's check grounding API, as documented in November 2026, scores how grounded a text is in a set of reference texts and can return supporting citations that show where the reference texts back it; contradicting citations are an experimental addition. Azure AI Content Safety's groundedness detection has a non-reasoning mode that returns a grounded or ungrounded verdict quickly for online use, and a reasoning mode that explains each ungrounded segment, meant for development and debugging; it accepts a QnA or a summarization task, offers a correction feature in preview that rewrites the ungrounded span from the source, and is tuned for English. Its published retirement date is April 30, 2027, so a design that leans on it needs a replacement plan; the suggested one is a grounding check you own, built on an LLM.
When to use it
On each change to the pipeline, before it ships. A change to how documents are split alters which chunks exist and which ones the retriever returns, so the first place it shows is recall@k and precision@k on the labeled question set, before any answer is generated. Our advice: keep that set in the repository and run it as a check on each pull request that touches chunking, the embedding model, the reranker or the prompt, with a threshold per metric that fails the build. A reference-based judge fits the same slot: it compares the new answer with the previously approved one for the same question, a regression test that suits a model or prompt change.
After it ships, on a sample. Direct-scoring judges work online as well as offline, so a faithfulness and a completeness judge can grade a sample of live answers continuously. Search logs give cheaper signals alongside them: the share of sessions with no click, click-through on cited documents, and the zero-result rate, which points at a recall problem or at content missing from the index. A drop in these after a release, with the offline set unchanged, is worth checking against the labeled set: if it doesn't cover what employees are now asking, add those questions to it.
An inline grounding check when a wrong answer costs more than a slower one. In a company-documents assistant, questions about leave, pay, benefits and health are where we'd put it: a claim about leave entitlement that the handbook doesn't support shouldn't reach the employee. Put the fast, binary mode in the request path and keep the explaining mode for offline review of what it flagged. What happens on a failed check is a design decision: cut the unsupported sentences, retry generation with a stricter prompt, or decline and show the retrieved passages with a link instead of an answer. Say which one you'd pick and why.
When not to
Skip nDCG when the model reads all you retrieve. If the top k chunks all go into the prompt, whether a relevant chunk is first or fourth matters less than whether it is there at all, and recall@k with binary labels is enough. Graded relevance labels cost more to collect, so save them for a reranking stage where order decides what gets cut.
Don't reach for an LLM judge where a deterministic check works. Whether a cited document id is in the retrieved set, whether a quoted span appears verbatim in its source, and whether a reference answer matches exactly are string checks: no model call, repeatable and fast. A judge costs a model call per answer and can disagree with itself across runs. Evidently positions the correctness judge as an alternative to deterministic matching for cases where many differently worded answers are right, which is also the case where matching fails.
Don't put the grounding check inline on all traffic. It adds a second model call and its latency to each request, and it conflicts with streaming tokens to the user, since a verdict needs the finished answer. For low-stakes drafts that a person reviews anyway, or for an internal prototype, sampling answers offline with a judge is the better trade. Watch the limits of a bought check too: the Azure one is tuned for English, so a multilingual handbook needs a different plan for other languages.
Don't trust a judge you haven't calibrated. A faithfulness score of 0.9 from a prompt nobody validated against human labels is a number without a meaning. The calibration set can be small, but it has to exist, and it should hold the hard cases: partially supported claims, numbers that are close but wrong, and an answer that declines when it should.
Compared
| Approach | What it catches | Right choice when | Weaker option is better when |
|---|---|---|---|
Recall@k on a labeled set | Retrieval that misses the source passage | You changed chunking, embeddings or the index | You have no labeled questions yet; start with a judge on live answers while you build the set |
nDCG | Relevant passages ranked below noise | A reranker decides what gets cut before the prompt | All retrieved chunks reach the model; binary recall@k is cheaper to label |
Faithfulness judge | Claims the retrieved text doesn't support | You need a score on open-ended answers at scale | A string check answers the question: cited id present, quote found in source |
Reference-based correctness judge | An answer that drifted from an approved one | Regression testing after a model or prompt change | The approved answers themselves are stale; refresh them first |
Inline grounding check | An unsupported claim about to be shown | A wrong answer costs more than added latency | Answers stream token by token to a low-stakes reader; sample offline instead |
Human review of a sample | What the automated scores miss | Calibrating judges, or a new domain | You need a verdict per request; people don't scale to that |
Online signals (no-click sessions, zero results) | Gaps between the labeled set and real questions | Watching a release in production | Diagnosing a specific regression; they don't say which layer broke |
In a picture
Step 1 of 3
Score retrieval against labels
A question set with the chunks that hold each answer runs through the retriever. Recall@k and nDCG compare the top k with the labels. This is where a chunking change shows first.
How to say it in an interview
The common mistake
Quiz
Questions that use this
Related
- Retrieval-augmented generation
- Hybrid search and reranking
- Staged rollouts and canaries
- Experiment statistics: split checks, peeking and corrections
- Failing open or failing closed
- Streaming LLM tokens
Sources
- Ragas documentation: Faithfulness
- Ragas 0.2.3 documentation: Context Precision
- Wikipedia: Evaluation measures (information retrieval)
- Azure AI Content Safety: Groundedness detection
- Evidently AI: LLM-as-a-judge: a complete guide to using LLMs for evaluations
- Google Cloud: Vertex AI APIs for building search and RAG experiences