RAGcore
Evaluating retrieval and answers
Measure retrieval and generation separately, or you can’t tell which one broke.
What it is and why it exists
Retrieval metrics on a labelled query set: recall@k (did a relevant chunk make the top k), precision@k, MRR (how high the first relevant hit is), nDCG (graded relevance with position discount). Answer metrics: correctness against a reference, faithfulness (claims supported by context), answer relevance, citation accuracy.
Quick prototype
Ten questions you check by eye.
In production, at scale
A versioned set of a few hundred labelled queries (from real traffic), retrieval metrics computed on every chunking/embedding/index change, answer metrics with calibrated judges, all in CI with thresholds.
Vendors and tools
| Ragas | Context precision/recall, faithfulness, answer relevance |
|---|---|
| DeepEval / TruLens / Arize Phoenix | RAG metrics and tracing |
| ranx / pytrec_eval | IR metrics |
On AWS: Bedrock Evaluations supports RAG evaluation of Knowledge Bases (retrieval and retrieve-and-generate).
How it fails
- Only measuring end answers — a retrieval regression hides behind a lucky model
- Labelled set written by the team, not drawn from real questions
What the interviewer asks next
Recall@5 is 0.95 but answers are wrong. What next?
Retrieval is fine; look at generation: the context assembly (order, truncation), the prompt, conflicting sources, or the model ignoring evidence. Check faithfulness per item.
Define MRR.
Mean over queries of 1 / rank of the first relevant result (0 if none). Rewards putting a correct hit first.