nci-document-retrieval-eval
A Neural Corpus Indexer for Document Retrieval — Wang et al. (2022) (arXiv:2206.02743, 2022)
What this evaluates
Evaluates a model's ability to retrieve relevant documents from a large corpus given a natural language query. It measures ranking quality and recall at various cutoffs to assess end-to-end document retrieval performance.
Datasets
- NQ320k — total 320000; splits: train (-1), val (-1)
- TriviaQA — total 78000; splits: train (-1), val (-1)
Metrics
Recall@1 (primary) — range: [0, 1]
- Measures how often the desired document is hit by the top-1 retrieved candidate.
Recall@10 — range: [0, 1]
- Measures how often the desired document is hit by the top-10 retrieved candidates.
Recall@100 — range: [0, 1]
- Measures how often the desired document is hit by the top-100 retrieved candidates.
MRR@100 — range: [0, 1]
- Calculates the reciprocal of the rank at which the first relevant document is retrieved, computed over the top-100 results.
R-Precision — range: [0, 1]
- Precision after R documents have been retrieved, where R is the number of relevant documents for the query.
Input / output format
Input: Natural language query.
Output: A ranked list of document identifiers (or documents) retrieved for the query.
Scoring recipe
def compute_metrics(predictions, gold):
recalls, mrrs, r_precs = [], [], []
for pred, rels in zip(predictions, gold):
top100 = pred[:100]
for N in [1, 10, 100]:
recalls.append(len(set(pred[:N]) & set(rels)) / len(rels))
mrr = 0.0
for i, doc in enumerate(top100):
if doc in rels:
mrr = 1.0 / (i + 1)
break
mrrs.append(mrr)
R = len(rels)
topR = pred[:R]
r_precs.append(len(set(topR) & set(rels)) / R)
return {
'Recall@1': sum(recalls[::3]) / len(recalls[::3]),
'Recall@10': sum(recalls[1::3]) / len(recalls[1::3]),
'Recall@100': sum(recalls[2::3]) / len(recalls[2::3]),
'MRR@100': sum(mrrs) / len(mrrs),
'R-Precision': sum(r_precs) / len(r_precs)
}
Common pitfalls
- Recall is evaluated at different cutoffs (@1, @10, @100) depending on the dataset; ensure the correct cutoff is used for each benchmark.
- R-Precision uses R = number of relevant documents per query, which can be >1 in TriviaQA, unlike standard single-relevance benchmarks.
- MRR is computed over the top-100 results, not the full generated list.
Evidence (verbatim from paper)
Recall@N measures how often the desired document is hit by the top-N retrieved candidates. MRR calculates the reciprocal of the rank at which the first relevant document is retrieved. R-Precision is the precision after R documents have been retrieved, where R is the number of relevant documents for the query.
Citation
@misc{wang2022neuralcorpusindexer,
title={A Neural Corpus Indexer for Document Retrieval},
author={Wang et al. (2022)},
year={2022},
note={arXiv:2206.02743}
}
1---2name: nci-document-retrieval-eval3description: Evaluates a model's ability to retrieve relevant documents from a large corpus given a natural language query. It measures ranking quality and recall at various cutoffs to assess end-to-end document retrieval performance. Use when the user wants to benchmark on NQ320k, TriviaQA, or asks about evaluating this task. Reports Recall@1.4metadata:5 source: https://skillmd.com/skills/qhjqhj00/nci-document-retrieval-eval6 skill_kind: dataset_eval7 source_arxiv: 2206.027438 bibtex_key: wang2022neuralcorpusindexer9 confidence: high10---1112# nci-document-retrieval-eval1314> A Neural Corpus Indexer for Document Retrieval — Wang et al. (2022) (arXiv:2206.02743, 2022)1516## What this evaluates1718Evaluates a model's ability to retrieve relevant documents from a large corpus given a natural language query. It measures ranking quality and recall at various cutoffs to assess end-to-end document retrieval performance.1920## Datasets2122- **NQ320k** — total 320000; splits: train (-1), val (-1)23- **TriviaQA** — total 78000; splits: train (-1), val (-1)2425## Metrics2627- `Recall@1` **(primary)** — range: [0, 1]28 - Measures how often the desired document is hit by the top-1 retrieved candidate.29- `Recall@10` — range: [0, 1]30 - Measures how often the desired document is hit by the top-10 retrieved candidates.31- `Recall@100` — range: [0, 1]32 - Measures how often the desired document is hit by the top-100 retrieved candidates.33- `MRR@100` — range: [0, 1]34 - Calculates the reciprocal of the rank at which the first relevant document is retrieved, computed over the top-100 results.35- `R-Precision` — range: [0, 1]36 - Precision after R documents have been retrieved, where R is the number of relevant documents for the query.3738## Input / output format3940**Input**: Natural language query.4142**Output**: A ranked list of document identifiers (or documents) retrieved for the query.4344## Scoring recipe4546```python47def compute_metrics(predictions, gold):48 recalls, mrrs, r_precs = [], [], []49 for pred, rels in zip(predictions, gold):50 top100 = pred[:100]51 for N in [1, 10, 100]:52 recalls.append(len(set(pred[:N]) & set(rels)) / len(rels))53 mrr = 0.054 for i, doc in enumerate(top100):55 if doc in rels:56 mrr = 1.0 / (i + 1)57 break58 mrrs.append(mrr)59 R = len(rels)60 topR = pred[:R]61 r_precs.append(len(set(topR) & set(rels)) / R)62 return {63 'Recall@1': sum(recalls[::3]) / len(recalls[::3]),64 'Recall@10': sum(recalls[1::3]) / len(recalls[1::3]),65 'Recall@100': sum(recalls[2::3]) / len(recalls[2::3]),66 'MRR@100': sum(mrrs) / len(mrrs),67 'R-Precision': sum(r_precs) / len(r_precs)68 }69```7071## Common pitfalls7273- Recall is evaluated at different cutoffs (@1, @10, @100) depending on the dataset; ensure the correct cutoff is used for each benchmark.74- R-Precision uses R = number of relevant documents per query, which can be >1 in TriviaQA, unlike standard single-relevance benchmarks.75- MRR is computed over the top-100 results, not the full generated list.7677## Evidence (verbatim from paper)7879> Recall@N measures how often the desired document is hit by the top-N retrieved candidates. MRR calculates the reciprocal of the rank at which the first relevant document is retrieved. R-Precision is the precision after R documents have been retrieved, where R is the number of relevant documents for the query.8081## Citation8283```bibtex84@misc{wang2022neuralcorpusindexer,85 title={A Neural Corpus Indexer for Document Retrieval},86 author={Wang et al. (2022)},87 year={2022},88 note={arXiv:2206.02743}89}90```9192- arXiv: 2206.02743