Evaluation, diagnostics, benchmarks, and additional tests · Evaluation, diagnostics, benchmarks, and additional hypothesis tests · EVA036 · Metric
Recall@k, MRR, and nDCG for retrieval
Evaluate whether ranked documents, images, audio clips, or video clips place relevant items near the top.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- Ranking and retrieval quality Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Runs in CodeSplash
- Code example
- Complete calculation
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through evaluate.ranking. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Evaluate whether ranked documents, images, audio clips, or video clips place relevant items near the top.
Question / hypotheses
Does the retrieval stage expose the evidence or item a downstream model needs?
Architecture / computational structure
A fixed scoring/calibration pipeline applied to model outputs or supplied observations; the formula and usage sections identify its operations.
Assumptions
Specify relevance judgments, candidate pool, duplicate handling, query weighting, and ties. Unjudged items should not automatically be assumed irrelevant without acknowledging evaluation incompleteness.
Formula / computational definition
Parameters and notation
r_q is first relevant rank; missing hits contribute zero. k and gain function are evaluation hyperparameters. Recall@k divides retrieved relevant items by all relevant items, not by k.
Fitting, fine-tuning, and adaptation
There is no model fine-tuning step for this evaluation procedure. Freeze the evaluated systems and evaluator before the final test. Select evaluation settings on development data; if a learned evaluator or calibration model is adapted, use separate fitting data, version it, and reassess its validity.
How to use and calibrate
Evaluate retrieval separately from generation, with query-level confidence intervals. Include hard negatives and a realistic candidate pool; report latency and index size.
Example application
Measure whether a RAG system retrieves the supporting source before testing answer quality.
Interpretation / pitfalls
Watch out
High retrieval recall does not establish answer faithfulness. Scores on a small sampled candidate pool can overstate full-index performance.
Python and R code examples
Scope: Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.
Validation: Python — Executed successfully on synthetic inputs. R — reviewed but not executed in this environment. Python dependencies are explicit imports; R uses base R unless a package/bridge is explicitly named.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline. · needs numpy
import numpy as np
rel=np.array([0,2,1,0]); k=3; gains=2**rel[:k]-1; discount=np.log2(np.arange(2,k+2))
ideal=np.sort(rel)[::-1][:k]; print(np.sum(gains/discount)/np.sum((2**ideal-1)/discount))
Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.
rel <- c(0,2,1,0); k <- 3; discount <- log2(2:(k+1)); ideal <- sort(rel,decreasing=TRUE)[1:k]
print(sum((2^rel[1:k]-1)/discount)/sum((2^ideal-1)/discount))
Sources
- Source 1scikit-learn.org
- Source 2nlp.stanford.edu
From the CodeSplash reference, entry EVA036.