Evaluating RAG end to end
Measure retrieval and generation separately so you know which stage to fix.
Split evaluation in two. Retrieval metrics ask whether the right passages were found: recall@k, mean reciprocal rank and nDCG against labelled relevant passages. Generation metrics ask whether the answer is good given the context: faithfulness to the sources, relevance to the question, completeness and correct refusal.
Build a golden set from real questions plus the documents that answer them. Start with 50 to 100, hand-checked. Synthetic questions generated from your documents extend coverage cheaply, but review them, since they skew easy and mirror the document's own wording. Include unanswerable questions to test refusal, and adversarial ones.
Run the suite on every change to chunking, embeddings, retrieval or prompts, and look at per-category results. When an answer is wrong, check retrieval first: if the evidence was not retrieved, fix retrieval. If it was retrieved and ignored, fix assembly or generation.
Key points
- Evaluate retrieval and generation separately.
- Use recall@k, MRR and nDCG for retrieval. Faithfulness and relevance for answers.
- Build a golden set from real questions. Include unanswerable and adversarial cases.
- Diagnose failures retrieval-first.
Answer these out loud
- 1recall@5 is 0.92 but faithfulness is 0.70. Where do you look first and why?
- 2Why can an LLM judge be biased towards longer answers, and how do you check your judge against human labels?
Build it
Build a 60-question golden set for your corpus and a script that reports recall@5, MRR and a faithfulness score per category, then use it to compare two chunking strategies.
Use this from an agent
Any MCP client, including Grok, can read this lesson. See how to connect.
curl https://engineeros-delta.vercel.app/api/v1/topics/rag-evaluation