pytrec-eval-terrier
Provides Python bindings for popular Information Retrieval measures implemented within trec_eval.
What it is and what it does
pytrec_eval_terrier is a Python wrapper around TREC's trec_eval evaluation tool, designed to eliminate custom implementations of Information Retrieval metrics in Python. It exposes a simple API for computing standard IR measures—such as MAP (Mean Average Precision) and NDCG (Normalized Discounted Cumulative Gain)—on ranked search results against relevance judgments. The package accepts query-document relevance labels and ranked runs as nested dictionaries, then returns computed metrics per query.
This fork, maintained by the University of Glasgow, provides pre-built wheels for modern Python versions (3.10–3.14) and multiple platforms (Linux, macOS, Windows), reducing installation friction compared to building from source. It depends on numpy and scipy for numerical operations and wraps C++ code from the original trec_eval project, making it both fast and reliable for research and production IR evaluation workflows.
Use it for:
- Evaluate search engine or ranking model performance using standard TREC metrics without writing custom metric code.
- Compute statistical significance between two ranked runs to compare IR system improvements.
- Benchmark information retrieval systems in research papers or academic projects.
- Integrate IR evaluation into automated testing or continuous evaluation pipelines.
- Validate ranking quality during development of search applications or recommendation systems.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python bindings to TREC's trec_eval tool for computing standard Information Retrieval evaluation measures like MAP and NDCG on ranked search results.
Yes. The package is actively maintained, has no known vulnerabilities, installs cleanly on modern Python versions via pre-built wheels, and solves a real problem—standardized IR evaluation—with a proven, well-cited implementation. Use it if you need to evaluate ranked search results against relevance judgments; the MIT license and permissive treatment pose no barrier.
Install
pytrec-eval-terrier on PyPI
pip
pip install pytrec-eval-terrieruv
uv add pytrec-eval-terrierpoetry
poetry add pytrec-eval-terrierInstalling pytrec-eval-terrier
Before you install
Medium install friction due to compiled C++ components; pre-built wheels available for Python 3.10–3.14 on Linux, macOS, and Windows. Actively maintained with recent releases. Depends on numpy and scipy.
License in practice
Licensed under the MIT license (permissive), allowing broad reuse. Note that the underlying trec_eval tool is licensed separately; check its terms if you modify or redistribute.
Quickstart
pip install pytrec_eval_terrier
import pytrec_eval
qrel = {'q1': {'d1': 0, 'd2': 1}}
run = {'q1': {'d1': 1.0, 'd2': 0.0}}
evaluator = pytrec_eval.RelevanceEvaluator(qrel, {'map', 'ndcg'})
print(evaluator.evaluate(run))
Requires Python 3 or later; numpy and scipy must be installed.
Verify before relying
- Whether the fork maintains full API compatibility with the original pytrec_eval project.
- Performance characteristics when evaluating large-scale ranking runs.
- Availability of documentation beyond the GitHub README and examples.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — numpy, scipy |
| Maintenance | actively maintained — 298 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,240,259/month — #4,173 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytrec_eval_terrier-0.5.10-cp310-cp310-macosx_10_9_universal2.whl; pytrec_eval_terrier-0.5.10-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pytrec_eval_terrier-0.5.10-cp310-cp310-musllinux_1_2_x86_64.whl; pytrec_eval_terrier-0.5.10-cp310-cp310-win_amd64.whl; pytrec_eval_terrier-0.5.10-cp311-cp311-macosx_10_9_universal2.whl; pytrec_eval_terrier-0.5.10-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pytrec_eval_terrier-0.5.10-cp311-cp311-musllinux_1_2_x86_64.whl; pytrec_eval_terrier-0.5.10-cp311-cp311-win_amd64.whl; pytrec_eval_terrier-0.5.10-cp312-cp312-macosx_10_13_universal2.whl; pytrec_eval_terrier-0.5.10-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pytrec_eval_terrier-0.5.10-cp312-cp312-musllinux_1_2_x86_64.whl; pytrec_eval_terrier-0.5.10-cp312-cp312-win_amd64.whl; pytrec_eval_terrier-0.5.10-cp313-cp313-macosx_10_13_universal2.whl; pytrec_eval_terrier-0.5.10-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pytrec_eval_terrier-0.5.10-cp313-cp313-musllinux_1_2_x86_64.whl; pytrec_eval_terrier-0.5.10-cp313-cp313-win_amd64.whl; pytrec_eval_terrier-0.5.10-cp314-cp314-macosx_10_15_universal2.whl; pytrec_eval_terrier-0.5.10-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pytrec_eval_terrier-0.5.10-cp314-cp314-musllinux_1_2_x86_64.whl; pytrec_eval_terrier-0.5.10-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Keywords: trec_eval, information retrieval, evaluation, ranking
Tags
More General packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
nltkNLTK is a Python library for natural language…
permissive · top 1,000 on PyPI
humanizeConverts numbers, dates, times, and file sizes…
permissive · top 1,000 on PyPI
pytrec-evalProvides Python bindings to compute standard…
permissive · top 15,000 on PyPI
trec-car-toolsProvides Python and Java bindings to read TREC…
permissive · top 15,000 on PyPI
ir-measuresProvides a unified Python interface to compute…
permissive · top 15,000 on PyPI
ranxranx computes ranking evaluation metrics…
permissive · top 15,000 on PyPI
mir-evalmir_eval computes standard accuracy metrics for…
permissive · top 15,000 on PyPI
ir-datasetsProvides a unified Python interface to…
permissive · top 15,000 on PyPI
colbert-aiColBERT is a BERT-based retrieval model that…
unclear · top 15,000 on PyPI
py-expression-evalParses and evaluates mathematical expressions…
permissive · top 15,000 on PyPI
deepevalDeepEval is an LLM evaluation framework that…
permissive · top 5,000 on PyPI
nemo-evaluatorNeMo Evaluator runs standardized benchmarks…
permissive · top 15,000 on PyPI