Distinguish retrieval failure from answer failure
Use labeled evidence and controlled model comparisons to decide whether to promote a release.
Distinguish retrieval failure from answer failure
Work through the decision
For 100 test questions, a retriever finds an accepted source for 80. The model cites it correctly in 60 of those cases. What do the two rates tell you?
Check your reasoning
Evidence was available for 80% of questions. Conditional citation success was 60/80, or 75%. Overall supported answers reached 60%. Compare retrieval on fixed queries and generation on fixed passages before choosing what to change. Validate machine scoring against sampled human judgments.
Compare the choices
- Measure retrieval against labeled evidence
- Use expected document IDs to measure recall at k before sending context to a model. Compare configurations on the same queries.
- Evaluate generation with fixed context
- Hold retrieved passages constant and score factuality, completeness and citation fidelity as the model or prompt varies.
- Calibrate evaluators with people
- Use a rubric, sample human reviews, disagreements and user feedback. Inspect agreement across meaningful slices.
- Gate a limited release
- Combine offline thresholds with scoped shadow or canary traffic, task completion, business metrics and rollback criteria.
Change only one stage
Give both generators an identical set of approved passages and compare supported claims. Next, hold the generator fixed and change retrieval. A faulty retriever can cap answer quality even if generation is excellent when supplied the correct evidence.
Apply it on AWS
Separate retrieval-only evaluation from retrieve-and-generate evaluation in a Bedrock knowledge-base workflow. For an agent, also verify the tool result and final state. A fluent booking confirmation with no reservation in the ledger is a task failure.
Practice the guide skills
- Define a rubric for factual support, completeness and usefulness alongside numeric metrics. Score a representative fixed set. Watch 5:46:12
- Compare models on the same questions, passages and sampling settings. Inspect quality as well as time and cost. Watch 5:48:43
- Collect user corrections and abandoned tasks, then sample the feedback to find patterns without overrepresenting frequent reporters. Watch 5:30:38
- Block releases that regress past a threshold on critical cases. Save the evaluation set, model and prompt versions. Watch 5:58:20
- Compare automatic judges with human ratings. Review discrepancies and check metrics across distinct groups. Watch 5:50:15
- Compute recall at k using expected source IDs. Then evaluate answers with fixed passages to separate retrieval from generation. Watch 5:53:29
- Measure agent task completion, valid tool use, number of steps and unnecessary writes against the expected outcome. Watch 5:59:24
- Report cohort sizes, trends, cost per accepted case and uncertainty to decision makers; give engineers failed trace IDs. Watch 6:02:32
- Start in shadow traffic with side effects disabled or an approved small canary. Set rollback conditions before exposing more users. Watch 6:01:39
Official objectives for this lesson
Local lab · Separate evidence recall from answer support
Copy the script into retrieval_eval.py and run python3 retrieval_eval.py. Predict which misses can be fixed by improving retrieval. Each question has one accepted evidence ID. A supported answer must cite that ID and have it in the retrieved context.
cases = [
# expected evidence, retrieved sources in rank order, cited source
("P3", ["P3", "P1"], "P3"),
("P7", ["P1", "P7"], "P1"),
("P4", ["P2", "P5"], "P2"),
("P9", ["P9", "P6"], "P9"),
]
def evaluate(k):
found = supported = 0
for target, ranked, citation in cases:
available = target in ranked[:k]
found += available
supported += available and citation == target
conditional = f"{supported / found:.0%}" if found else "undefined"
print(f"k={k}: evidence {found}/{len(cases)}, "
f"supported {supported}/{len(cases)}, support given evidence {conditional}")
for depth in (1, 2):
evaluate(depth)
Check the result
k=1: evidence 2/4, supported 2/4, support given evidence 100% k=2: evidence 3/4, supported 2/4, support given evidence 67%
Increasing k exposes P7 but its answer still cites P1. Replace that citation with P7 and rerun. At depth two, three answers now have support. In production, a reviewer must also verify that the cited text entails the claim.
Related lesson · Evaluate the retriever, generator and business outcome
Distinguish retrieval failure from answer failure quiz
Answer 3 questions. Check each answer for an explanation.
Worked example · Distinguish retrieval failure from answer failure