Lesson 5 of 6
Evaluating retrieval and answer quality
9 min
Listen to this lesson
A RAG assistant that "seems good" in a demo is not ready for a hypercare desk. You need evidence, the same way you need evidence before you sign off a business process. The evidence comes from a gold question set: real questions, the documents that should answer them, and the answers a key user agrees are right. With it, you can measure retrieval and generation separately and decide go or no-go with numbers.
Build the gold set
- Collect real questions. Pull them from the defect tool, the hypercare channel and workshop notes. Contoso collected 120; Priya kept 80 that are answerable from program documents and 20 that deliberately aren't.
- Label the expected sources. For each answerable question, record the document IDs and sections that contain the answer, for example FS-O2C-014 section 3.2.
- Write reference answers. A key user writes the short correct answer. Maria owns order-to-cash questions; Dan owns finance; Luis owns cutover.
- Add the "no answer" cases. For the 20 unanswerable questions, the expected behavior is a clear "I can't find this in the program documents."
- Freeze and version it. Store the set in the repository so every change to chunking, prompts or models is measured against the same questions.
Measure retrieval first
Run every question through the Retrieval API (or your HANA query) without the model, and compare the returned chunks with the labeled sources. Two simple metrics do most of the work. Hit rate at k is the share of questions where at least one correct source appears in the top k chunks. Mean reciprocal rank rewards having the correct source near the top. If hit rate is low, stop: no prompt can rescue answers built on the wrong passages. Fix chunking, metadata, filters or the embedding model, and rerun.
Then measure the answers
With retrieval in shape, run the full pipeline and score each answer on three questions. Is it correct against the reference answer? Is it faithful (grounded), meaning every claim is supported by the retrieved chunks? Does it refuse properly when the documents don't contain the answer? SAP's generative AI hub evaluation offers LLM-as-a-judge metrics for two of these ideas. Groundedness checks whether the response relies only on the provided context; context relevance checks whether the retrieved context matches the query. SAP reports validating them against public and internal datasets, with judge correlations of roughly 79 to 87 percent against ground truth depending on the judge model. That is useful for screening large sets, not a replacement for a person reviewing a sample.
| Metric | What it tells you | Contoso target before pilot sign-off |
|---|---|---|
| Hit rate at 5 (retrieval) | The right source is in the top five chunks | 90% or better on the 80 answerable questions |
| Correctness (key user review) | The answer matches the reference answer | 85% or better, with zero wrong thresholds or dates |
| Groundedness (judge plus spot check) | Claims are supported by retrieved text | 95% or better; every ungrounded answer reviewed |
| Refusal rate on unanswerable questions | It says "not found" instead of guessing | 18 of 20 or better |
| Citation present | Every answer links to its source document | 100% |
Illustrative targets Contoso set for its program assistant; set yours with the business owners.
Keep evaluating after go-live
Documents change daily and models change on SAP's schedule, so a pass today is not a pass forever. Treat the gold set as a regression suite. Rerun it when the pipeline scope changes, when you change the model in the orchestration configuration, and on a fixed cadence (Contoso reruns monthly during hypercare). Log user feedback with the question, the retrieved chunks and the answer, so a bad answer can be reproduced and added to the gold set.
- Week 1Gold set built120 questions collected; 100 kept, with sources and reference answers.
- Week 2Retrieval tuningHit rate at 5 rises from 71% to 92% after structure-aware chunking and cycle metadata.
- Week 3Answer tuningRefusal rule added; unanswerable questions answered correctly rise from 9 to 19 of 20.
- Week 4Key user review and sign-offMaria, Dan and Luis review samples; Priya signs off the pilot for hypercare.
- MonthlyRegression rerunSame gold set, results compared with the signed baseline.
What would you do?
After tuning, Contoso's assistant scores 94% correctness, but 4 of the 20 unanswerable questions get confident answers drawn from general SAP knowledge. Grace asks if it can go live for hypercare. What should Priya recommend?
- Build a versioned gold set with real questions, labeled sources, reference answers and unanswerable cases.
- Measure retrieval (hit rate, rank) before answers; fix retrieval problems at the source.
- Score answers for correctness, groundedness, refusal and citation, with key user review on a sample.
- Rerun the gold set whenever the model, prompt, chunking or scope changes.
Check your understanding · not graded
Lesson check
1. Why should a gold set include questions the documents can't answer?
2. Retrieval hit rate at 5 is 60%. What should the team do next?
3. What does the groundedness metric in SAP's generative AI hub evaluation assess?
4. When should Contoso rerun its gold set after go-live?