Registry / data / ir-datasets

ir-datasets

JSON →
library0.6.3pypypi✓ verified 20d ago

ir_datasets provides a common interface to many Information Retrieval (IR) ad-hoc ranking benchmarks, training datasets, and more. It handles downloading, extracting, and providing a unified iterator format for various IR datasets. The library is actively maintained with frequent updates, currently at version 0.5.11, with new datasets and bug fixes released regularly.

pip install ir-datasets
INSTALL
IMPORT
SIG · IR-DATASETS
I
ir-datasets
datapythonv0.6.3
Install
5.4s avg
Import
976ms
Disk
119MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.4s · import 0.976s · 116MB
119MB installed
● package 119MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ir_datasets
import ir_datasets

This quickstart demonstrates how to load a dataset, such as MS MARCO, and iterate through its documents, queries, and relevance judgments using the `ir_datasets.load()` function and its iterator methods.

import ir_datasets # Load a dataset, e.g., MS-MARCO passage ranking training set dataset = ir_datasets.load('msmarco-passage/train') # Iterate through documents print("First 3 documents:") for i, doc in enumerate(dataset.docs_iter()): print(f" Doc ID: {doc.doc_id}, Text: {doc.text[:70]}...") if i >= 2: break # Iterate through queries print("\nFirst 3 queries:") for i, query in enumerate(dataset.queries_iter()): print(f" Query ID: {query.query_id}, Text: {query.text}") if i >= 2: break # Access relevance judgments (qrels) print("\nFirst 3 qrels:") for i, qrel in enumerate(dataset.qrels_iter()): print(f" Query ID: {qrel.query_id}, Doc ID: {qrel.doc_id}, Relevance: {qrel.relevance}") if i >= 2: break
Debug
Known issues
gotchaConverting iterators to dictionaries (e.g., `dataset.qrels_dict()`) will load the entire dataset's relevance judgments into memory. For very large datasets, this can lead to high memory consumption and potential crashes. Use iterators (`dataset.qrels_iter()`) for memory efficiency with large collections.
fix
Prefer `dataset.docs_iter()`, `dataset.queries_iter()`, and `dataset.qrels_iter()` for memory-efficient processing of large datasets. Only use dictionary-based access like `dataset.qrels_dict()` when you are certain the data will fit in memory.
affects: All versions
gotchair_datasets includes a 'Beta Python API' which offers alternative access patterns (e.g., `dataset.docs` as an iterable object with slicing). This API is experimental, may contain bugs, and is subject to breaking changes in future versions.
fix
For stable code, rely on the official Python API methods like `dataset.docs_iter()` as described in the main documentation. If using the Beta API, be aware of its experimental nature and potential for changes.
affects: Versions 0.5.0 and later (since beta API introduction)
gotchaSome datasets are not publicly available and require manual steps (e.g., data usage agreements, local file paths) to access. `ir_datasets` will provide instructions on how to obtain these datasets, but it cannot automate their download in all cases.
fix
Always check the specific dataset's documentation or the output from `ir_datasets` when attempting to load a new collection. Be prepared to follow manual instructions for non-public datasets.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ir_datasets'
The ir-datasets library is not installed in the current Python environment or the environment is not activated correctly.
fix
Install the library using `pip install ir-datasets` or activate the correct virtual environment where it is installed.
KeyError: 'dataset_id not found' (or similar, e.g., 'KeyError: 'dataset_name'')'
The specified dataset ID or name does not exist or is misspelled in the ir-datasets registry.
fix
Verify the correct dataset ID from the `ir_datasets` documentation (e.g., `ir_datasets.list_datasets()`) and ensure it is spelled correctly.
FileNotFoundError: [Errno 2] No such file or directory: '...' (pointing to a dataset file path)
A required dataset file was not found, likely due to a failed or incomplete download, corrupted cache, or incorrect path configuration for the dataset storage.
fix
Clear the `ir_datasets` cache (e.g., by deleting the `~/.ir_datasets/` directory) and retry the dataset access. Ensure sufficient disk space and stable network connectivity, and verify the `IR_DATASETS_HOME` environment variable if using a custom data directory.
ModuleNotFoundError: No module named 'warc' (or 'unlzw3', 'lz4', etc.)
The dataset you are trying to access requires an optional dependency for a specific data format (e.g., WARC, Z-compressed files) which has not been installed.
fix
Install the necessary optional dependency. For example, if 'warc' is missing, run `pip install ir-datasets[warc]`. Consult the `ir-datasets` documentation for the correct optional dependencies for your dataset.
Upgrade
Version history
0.6.3latest on PyPI · released Jul 18, 2026
Audit
Dependencies
ir-measuresoptionalCommonly used for evaluating IR experiments, integrates directly with ir_datasets qrels.
PyTerrieroptionalPopular IR experimentation toolkit that integrates with ir_datasets.
Agent activity
23 hits · last 30 days
node
22
Resources