Registry / ai-ml / rerankers

rerankers

JSON →
library0.10.0pypypi✓ verified 86d ago

A unified API for various document re-ranking models, supporting cross-encoders, ColBERT, T5-based, and API-based models. Current version: 0.10.0. Actively maintained with frequent releases.

pip install rerankers
INSTALL
IMPORT
SIG · RERANKERS
R
rerankers
ai-mlpythonv0.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Reranker
from rerankers import Reranker
from reranker import Reranker
Package name is 'rerankers' (plural), not 'reranker'.
CrossEncoder
from rerankers.cross_encoder import CrossEncoder

Quick example of re-ranking documents using a cross-encoder model.

from rerankers import Reranker ranker = Reranker('cross-encoder/ms-marco-MiniLM-L-6-v2', model_type='cross-encoder') results = ranker.rank(query='What is Python?', docs=['Python is a programming language.', 'Java is also a language.'], doc_ids=[1,2]) print(results)
Debug
Known issues
gotchaThe library name is 'rerankers' (plural). Installing with 'pip install reranker' will fail.
fix
Use 'pip install rerankers'.
affects: all
gotchaThe 'model_type' argument is required for some models (e.g., 'cross-encoder') to avoid automatic detection failures.
fix
Always specify 'model_type' explicitly.
affects: >=0.5.0
breakingIn version 0.8.0, the 'rank' method changed: 'query' and 'docs' parameters swapped order. Old code using positional arguments will break.
fix
Use keyword arguments: rank(query=..., docs=...)
affects: >=0.8.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'reranker'
Trying to import from 'reranker' (singular) instead of 'rerankers'.
fix
Install the correct package: pip install rerankers, then import from rerankers.
AttributeError: module 'rerankers' has no attribute 'Reranker'
Maybe the import is wrong or the package is outdated.
fix
Ensure you have rerankers installed (version >=0.5.0) and use: from rerankers import Reranker
ValueError: The 'model_type' must be specified when using this model.
Automatic model type detection failed.
fix
Provide the 'model_type' argument explicitly, e.g., model_type='cross-encoder'.
Upgrade
Version history
0.10.0latest on PyPI · released May 22, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
45 hits · last 30 days
node
40
OpenAI (training)
1
Resources
rerankers — pip install rerankers · libregistry