WRITE · TRACE · UNDERSTAND
Evaluate retrieval with relevance and rank
Implement retrieval_metrics(ranked,relevant,k) returning dict recall,mrr.
Read lesson: Evaluate retrieval with relevance and rank →
Your experiment
Implement retrieval_metrics(ranked,relevant,k) returning dict recall,mrr. Deduplicate ranked preserving order, then take k. mrr is reciprocal first relevant rank or 0. No relevant ids gives None values. Require k>=1 integer.
Python runs in your browser. Your draft stays on this device.
What to look for
Retrieval metrics evaluate the judged identifiers and ordering. They do not establish answer faithfulness, citation correctness or resistance to prompt injection; those require separate evaluation cases.
Watch your code work
Ready to experimentWrite a solution or load the worked answer, then choose Trace & check.
Step through arrays, variables and training curves produced by your own Python.
