Offline Evaluation for Ranking Systems
Ah, a query on the arcane art of ranking evaluation—straight from the annals of information retrieval. As Sherlock, I'll deduce and dissect this systematically: labels for ground truth, MRR/NDCG as core metrics, and bias checks for fairness. Offline eval uses historical data (queries, documents/items, interactions) to simulate ranking without live traffic. Let's break it down.
1. Labels (Ground Truth Relevance)
- What? Human-annotated or proxy labels indicating relevance (e.g., 0=irrelevant, 1=relevant, 3=perfect match, 4=highly relevant). Essential for supervised eval.
- Sources:
| Type | Pros | Cons | Examples |
|---|
| Explicit (e.g., crowdsourced) | High quality | Expensive, slow | TREC, MS MARCO datasets |
| Implicit (clicks, dwells, purchases) | Cheap, abundant | Noisy (position bias) | Logs from search engines |
| Pointwise (per doc) | Simple | Ignores ranking | Binary relevance |
| Pairwise/Listwise | Ranking-aware | Complex annotation | Graded scales (0-5) |
- Prep Tips:
- Use qrels (query-relevance) files:
qid docid grade.
- Handle multi-level: Average or use gain functions.
- Pitfall: Position bias—unbiased estimators like IPS (Inverse Propensity Scoring) correct for it.
2. Core Metrics: MRR and NDCG
| Metric | Best For | Example Score (Query w/ Rels at 1,3,5) |
|---|
| MRR | Single-rel | 1 (if first is rel) |
| nDCG@5 | Graded | ~0.9 (good) vs. 1.0 (perfect) |
-
Implementation Snippet (Python, ranklib/terrier style):
from sklearn.metrics import ndcg_score
import numpy as np
y_true = np.array([[3, 2, 1, 0]]) # Graded relevance
y_pred = np.array([[0.9, 0.7, 0.5, 0.1]]) # Scores
ndcg = ndcg_score(y_true, y_pred, k=3) # ~0.98
# MRR: custom or via reciprocal_rank
-
When to Use: MRR for precision@1; NDCG for holistic ranking quality. Avg over queries; report @1/5/10.
3. Bias Checks (Fairness & Equity)
- Ranking amplifies bias—top positions get 10x+ exposure.
- Key Checks:
| Bias Type | Metric | Goal | How |
|---|
| Group (Demographic) | ΔNDCG (group gaps) | Equal perf across subgroups (e.g., gender, race) | Compute NDCG per group (e.g., female/male creators); flag >5-10% gap. |
| Exposure | Avg Position / Visibility | Fair promotion | ( E_g = \sum \frac{1}{\log_2(pos+1)} ) per protected group. |
| Amplification | Disparity = ( \frac{ | E_{prot} - E_{unprot} | }{E_{unprot}} ) |
| Statistical Parity | Group rel % in top-k | Match pop. dist. | χ² test on top-k composition. |
- Tools/Libs:
- FAIR (Python):
evaluate_fairness(ranked_lists, protected_groups).
- RankLib/LTR: Built-in group NDCG.
- Datasets: MKQA (multilingual bias), BiasBench.
- Mitigation: Re-ranking (e.g., MADP), calibrated scores, or adversarial training.
- Pitfall: Trade-off—fairness vs. utility (monitor ΔNDCG <10%).
Full Eval Pipeline
- Data Split: Train/Val/Test (e.g., time-based for recsys).
- Run: Score model rankings against labels.
- Aggregate: Mean ± std over folds/queries.
- Baselines: Random, BM25, PopRank.
- Holistic: MRR/NDCG + ERR (Expected Reciprocal Rank for clicks) + Bias Δ.
Example Scores on MS MARCO:
Model | MRR@10 | nDCG@10 | Bias Δ (Gender)
BM25 | 0.185 | 0.285 | 0.12
BERT | 0.348 | 0.418 | 0.08 ← Wins!
If this is for a specific dataset/model (e.g., TREC, RecSys), provide more details—I've deduced the essentials, but the game is afoot for refinements! 🔍