60-second card
Retrieval metrics
Retrieval metrics check whether the right chunks were found, before you judge the answer.
- Recall@k: share of the relevant chunks found in the top k.
- Precision@k: share of the top k that are relevant.
- MRR rewards putting the first relevant chunk near the top.
relevant, found_in_top5 = 4, 3
print(f"recall@5 {found_in_top5 / relevant:.0%}, precision@5 {found_in_top5 / 5:.0%}")Prints
recall@5 75%, precision@5 60%Remember: If retrieval misses, no prompt can fix the answer.
Common mistake: Only scoring final answers, so you can't tell whether search or generation failed.