The assistant answers a leave-policy question in two confident sentences and cites the policy document. The citation is real. The passage it quotes comes from last year’s version, which a newer file replaced in March. Nobody noticed during the demo, because the demo questions were written by the people who built it.
That is the gap RAG evaluation exists to close. Retrieval-augmented generation, introduced under that name by Lewis et al. (2020), lets a language model answer from documents you supply instead of from memory alone. If you are new to the idea, RAG explained covers how it works. This piece assumes you have a RAG system, or are building one, and need to know whether it is any good.
Why a RAG system needs two kinds of evaluation
A RAG pipeline has two stages that fail in different ways. The retriever finds passages. The generator, a language model, writes an answer from those passages. An end-to-end score tells you something is wrong. It does not tell you where.
| Symptom | Likely stage | What to check |
|---|---|---|
| Answer is wrong and the right passage was never retrieved | Retrieval | Recall, chunking, query wording |
| Right passage retrieved, answer still wrong | Generation | Faithfulness, prompt, context order |
| Answer cites a passage that does not support it | Generation | Citation accuracy |
| Answer is faithful to an outdated or wrong passage | Corpus | Document versions and dates |
| Confident answer to a question the documents cannot answer | Generation | Abstention behavior |
Good RAG evaluation keeps these apart. You measure the retriever on its own, the generator given fixed context, and then the whole system on realistic questions.
Build a RAG evaluation set before you measure anything
Every metric below needs the same thing first: a set of test questions with known answers. Each item should carry four fields.
- The question, worded the way a real user would type it.
- The passages that contain the answer, identified by document and section.
- A short reference answer written by someone who knows the material.
- A type tag, so you can report results by kind of question.
Useful type tags include simple lookups, questions that need two passages combined, questions answered from a table, questions where the answer changed between document versions, ambiguous questions, and questions the documents cannot answer at all. That last group matters more than it looks. A system that never says “the documents do not cover this” will invent answers in production.
Take questions from real usage where you can: search logs, support tickets, questions people asked a human colleague. Questions written by the builders tend to use the documents’ own vocabulary, which makes retrieval look better than it is.
Start with fifty to a hundred items spread across the types. Grow the set from failures you find later. Keep a portion aside that you never look at while tuning, so you have one honest score at the end.
Measuring retrieval quality
Retrieval metrics compare what the retriever returned with the passages you marked as correct. Four are standard.
Recall at k asks: of the correct passages, how many appeared in the top k results? Precision at k asks: of the top k results, how many were correct? Mean reciprocal rank looks at the position of the first correct passage; first place scores 1, third place scores one third. Normalized discounted cumulative gain (nDCG) rewards correct passages more when they rank higher, and handles items with several correct passages.
A worked example makes them concrete. A question has two correct passages. The retriever returns five results, and one correct passage sits at rank three. Recall at 5 is 1 of 2, or 0.5. Precision at 5 is 1 of 5, or 0.2. The reciprocal rank is one third. Average these across the whole set, and report them by question type.
For RAG, recall usually matters most, because the generator cannot use a passage it never sees. Low recall points to a few common causes: chunks that split the answer across two pieces, an embedding model that does not know your domain’s vocabulary, or user wording that differs from the documents’ wording. Try hybrid search, combining keyword and vector retrieval, when exact terms such as product codes or clause numbers matter.
Context relevance
Retrieval metrics judge the ranked list. Context relevance judges what you actually send to the model. If you pass ten chunks and only one is relevant, the other nine are noise the model has to ignore.
Noise is not harmless. Liu and colleagues showed in their 2023 study “Lost in the Middle” that language models use information at the start and end of a long context more reliably than information in the middle. More context is not automatically better. Measure the share of passed chunks that are relevant, and test whether reranking or sending fewer chunks improves the final answer.
Faithfulness: is the answer supported by the context?
Faithfulness is the core generation metric in RAG evaluation. It asks whether every claim in the answer is supported by the retrieved passages, regardless of whether the answer is true in the wider world.
The standard method is claim decomposition. Split the answer into short, single claims. Label each one as supported by the context, contradicted by it, or not found in it. Faithfulness is the supported claims divided by all claims.
Say the answer to “How many days of parental leave do new fathers get?” reads: “New fathers get 15 days of paid leave, which must be taken within six months of the birth. The leave can be split into two blocks. Requests go to your line manager.”
That is four claims. The retrieved passage supports the 15 days, the six months and the line manager, but says nothing about splitting the leave. Faithfulness is 3 of 4. The fourth claim may be true, but the system had no grounds to say it.
Answer correctness and relevance
A faithful answer can still be wrong, because the retrieved passage can be wrong, outdated or about a different case. That is why faithfulness and correctness are separate measures. Compare the answer against your reference answer for correctness. Ask separately whether it addresses the question that was asked, or drifts into a nearby one.
Keep both numbers. High faithfulness with low correctness points to the corpus or the retriever. Low faithfulness with correct answers means the model is filling gaps from memory, which works until it does not.
Measuring hallucination in RAG
In a RAG system, a hallucination is a claim that neither the retrieved context nor the source documents support. The unsupported-claim rate from your faithfulness labels is the most direct measure. Three more checks catch what that rate misses.
Citation accuracy asks whether the passage each sentence cites actually supports that sentence. Systems often cite a relevant document while making a claim the document does not contain. Check a sample by hand, every time.
Abstention on unanswerable questions asks what happens when the answer is not in the documents. Count correct refusals and invented answers separately. A system that answers every unanswerable question is hallucinating by design.
False refusals ask the opposite: how often the system says “I cannot find that” when the answer was retrieved. A system tuned too hard against hallucination becomes useless in a different way.
Using a language model as the judge
Labeling claims by hand does not scale past a few hundred items. Most teams doing RAG evaluation at scale use a second language model as a judge, prompted to decompose answers and label support. Open-source frameworks such as RAGAS, described by Es and colleagues in 2023, implement faithfulness, answer relevance and context metrics this way.
An automated judge is a measuring instrument, and instruments need calibrating. Label a sample of fifty or so items by hand, run the judge on the same items, and compare. If the judge and your human labels disagree often, fix the judge prompt before you trust any dashboard. Fix the judge model and version too, so a change in the score means a change in the system and not in the ruler.
Watch for known judge habits. Judges tend to favor longer answers, answers in their own style, and answers that sound confident. A short, correct “the documents do not say” can score worse than a fluent invention unless your rubric rewards it.
Testing real-world RAG applications
Clean benchmark questions miss the failures that real document collections cause. Add targeted tests for each of these.
Document versions. Put old and new versions of the same policy in the corpus and ask questions whose answers changed. This is the failure in the opening example. Store dates as metadata and test that the newest version wins.
Tables and scanned PDFs. Many answers live in tables that text extraction mangles. Write questions whose answers need a specific row and column.
Access control. If users have different permissions, test that a user cannot retrieve passages from documents they are not allowed to see. Treat a failure here as a security bug, not an accuracy issue.
Follow-up questions. “And for part-time staff?” depends on the previous turn. Test multi-turn conversations as well as single questions.
Languages. If users ask in more than one language, evaluate each one; retrieval and generation quality both shift. Why AI models answer differently in Hindi and Bengali explains why.
Latency and cost. Record response time and tokens per query. A configuration that improves faithfulness slightly but doubles response time may not be worth it.
Finally, turn the evaluation set into a regression suite. Run it every time you change the chunk size, the embedding model, the prompt, the reranker or the language model version. Change one thing at a time. The NIST AI Risk Management Framework treats measurement as an ongoing activity rather than a launch gate, and RAG systems are a good example of why.
A RAG evaluation scorecard you can copy
RAG EVALUATION SCORECARD System version: [ ] Date: [ ]
Eval set: [n] items Held-out: [n] Judge model: [ ]
RETRIEVAL All Lookup Multi-passage Table Versioned
Recall@[k] [ ] [ ] [ ] [ ] [ ]
MRR [ ] [ ] [ ] [ ] [ ]
Context relevance [ ]
GENERATION
Faithfulness [ ]
Answer correctness [ ]
Answer relevance [ ]
Citation accuracy (manual) [ ] of [ ] checked
HALLUCINATION
Unsupported-claim rate [ ]
Correct refusals [ ] of [ ] unanswerable
False refusals [ ] of [ ] answerable
OPERATIONS
Median latency [ ]
Tokens per query [ ]
Permission test failures [ ] (must be 0)
Judge agreement with human labels on [n] items: [ ]
Changes since last run: [one change only]
Common RAG evaluation mistakes
Testing only easy questions. If every test question uses the documents’ own words, you are testing keyword matching. Use real user phrasing.
Reporting one average. A strong overall score can hide a system that fails every table question. Report by type.
Skipping unanswerable questions. Without them you cannot measure the most damaging failure: confident invention.
Trusting an uncalibrated judge. Check it against human labels before the first report, and again when you change it.
Tuning on the test set. If you adjust prompts until the eval set passes, the score stops meaning anything. Keep a held-out portion.
Changing several things at once. When the score moves, you will not know why.
Questions engineers ask
How large should the evaluation set be?
Large enough that each question type has a meaningful count. Fifty to a hundred items is a workable start for one domain. Add every production failure you find as a new item.
Can I evaluate without reference answers?
Partly. Faithfulness, context relevance and answer relevance need only the question, the context and the answer. Correctness needs a reference. Without one you know the system is consistent with its documents, not that it is right.
How is this different from evaluating a plain LLM?
A plain model has one stage to test. RAG adds a retriever, a corpus and the link between them, and each can fail on its own. The general routine in Evaluating LLMs at work still applies on top: a narrow task, real cases and a failure log.
Pick twenty real questions from your users this week, mark the passages that answer them, and compute recall at 5. That one number will tell you whether to work on retrieval or generation first.