Evaluating RAG Systems: Retrieval Metrics, Faithfulness and LLM-as-Judge
How to measure RAG quality: build a golden dataset, measure recall and precision of retrieval, faithfulness and relevance of answers, and run evals in CI.
Published December 1, 2026
Without measurement, every change to a RAG system, a new chunk size, embedding model or prompt, is a guess. Evaluation turns those guesses into numbers. The good news is that a useful evaluation setup is small: a few dozen real questions with known answers, a handful of metrics, and a script you run before every change ships.
The concept
Evaluate the two halves separately. Retrieval metrics ask whether the right chunks were found: recall@k (did the relevant document appear in the top k?), precision@k, and ranking quality like MRR or nDCG. Generation metrics ask whether the answer is good: faithfulness (is every claim supported by the retrieved context?), answer relevance (does it address the question?) and correctness against a reference answer.
Generation quality is hard to score with simple string matching, so teams use LLM-as-judge: a separate model call grades answers against a rubric. Judges are useful but imperfect; calibrate them against human ratings on a sample, keep rubrics concrete, and prefer pass/fail or small scales over 1-10 scores.
Core metrics
| Metric | Measures | How |
|---|---|---|
| Recall@k | Relevant doc retrieved in top k | Compare retrieved IDs to labelled IDs |
| MRR / nDCG | How high relevant docs rank | Rank-aware formulas |
| Faithfulness | Answer claims supported by context | LLM judge checks each claim |
| Answer relevance | Answer addresses the question | LLM judge or embedding similarity |
| Correctness | Matches reference answer | Judge vs reference, or exact facts |
| Latency / cost | p95 time, tokens per answer | Instrumentation |
Building an eval
- Collect 50-200 real questions (logs, support tickets)
- Label the source documents and a reference answer for each
- Run retrieval: compute recall@k and MRR
- Run full pipeline: judge faithfulness and correctness
- Track results per change; block regressions in CI
Evals make progress visible
Practical examples
Recall@k in a few lines
Retrieval quality without any LLM calls.
def recall_at_k(dataset, retrieve, k=5):
hits = 0
for row in dataset:
ids = [c.doc_id for c in retrieve(row["question"], k=k)]
hits += any(d in ids for d in row["relevant_doc_ids"])
return hits / len(dataset)A faithfulness judge prompt
Concrete rubric, binary verdict, short reason.
You are grading an answer for faithfulness.
Context:\n{context}\nAnswer:\n{answer}
List each factual claim in the answer. For each, say SUPPORTED or UNSUPPORTED by the context.
Final line: VERDICT: PASS if all claims are supported, otherwise FAIL.Run evals in CI
Fail the build if quality drops.
- name: RAG evals
run: python evals/run.py --dataset evals/golden.jsonl --min-recall 0.85 --min-faithfulness 0.9Common mistakes
- Judging quality from a handful of manual spot checks.
- Evaluating only end-to-end, so you cannot tell whether retrieval or generation broke.
- Trusting LLM judges without checking them against human labels.
- Golden sets made of easy, synthetic questions that do not resemble real traffic.
Key takeaways
- Measure retrieval and generation separately.
- Start with recall@k, faithfulness and correctness on real questions.
- Calibrate LLM judges against human ratings.
- Run evals on every change and block regressions.
FAQ
How big should the golden dataset be?
Even 50 good questions catch most regressions. Grow it with real failures from production.
Are there libraries for this?
Yes, several open-source evaluation frameworks implement RAG metrics, but simple custom scripts are often enough to start.
Can I generate test questions with an LLM?
Synthetic questions help with coverage, but always include real user questions, which are messier and more representative.