Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Build Text Rerankers with Deep Language Models
| Date | Stars |
|---|---|
| 2026-08-05 | 265 |
| 2026-09-24 | 265 |
| 2026-10-24 | 264 |
| 2026-11-04 | 264 |
Today
— stars today
This week
— stars this week
This month
-1 stars this month
Momentum
0.0
growth rate 0.00%/day
# Reranker
Reranker is a lightweight, effective and efficient package for training and deploying deep languge model reranker in information retrieval (IR), question answering (QA) and many other natural language processing (NLP) pipelines.
The training procedure follows our ECIR paper [Rethink Training of BERT Rerankers in Multi-Stage Retrieval Pipeline](https://arxiv.org/abs/2101.08751) using a localized constrastive esimation (LCE) loss.
Reranker speaks Huggingface🤗 language! This means that you instantly get all state-of-the-art pre-trained models as soon as they are ported to HF transformers. You also get the familiar model and trainer interfaces.
### Stae of the Art Performance.
Reranker has two submissions to MS MARCO document leaderboard. Each got 1st place, advancing the SOTA!
| Date | Submission Name | Dev MRR@100 | Eval MRR@100 |
|---|---|---|---|
| 2021/01/20 | LCE loss + HDCT (ensemble) | 0.464 | 0.405|
| 2020/09/09 | HDCT top100 + BERT-base FirstP (single) | 0.434 | 0.382 |
### Features
- Training rerankers from the state-of-the-art pre-trained language models like BERT, RoBERTa and ELECTRA.
- The state-of-the-art reranking performance with our LCE loss based training pipeline.
- GPU memory optimizations: Loss Parallelism and Gradient Cache which allow training of larger model.
- Faster training
- Distributed Data Parallel (DDP) for multi GPUs.
- Automatic Mixed Precision (AMP) training and inference with up to 2x speedup!
- Break CPU RAM limitation by memory mapping datasets with `pyarrow` through `datasets` package interface.
- Checkpoint interoperability with Hugging Face `transformers`.
### Design Philosophy
The library is designed to be dedicated for text reranking modeling, training and testing. This helps us keep the code concise and focus on a more specific task.
Under the hood, Reranker provides a thin layer of wrapper over Huggingface libraries. Our model wraps `PreTrainedModel` and our trainer sub-class Huggingface `Trainer`. You can then work with the familiar interfaces.
## Installation and Dependencies
Reranker uses Pytorch, Huggingface Transformers and Datasets. Install with the following commands,
```
git clone https://github.com/luyug/Reranker.git
cd Reranker
pip install .
```
Reranker has been tested with `torch==1.6.0, transformers==4.2.0, datasets==1.1.3`.
For development, install as editable,
```
pip install -e .
```
## Workflow
### Inference (Reranking)
The easiest way to do inference is to use one of our uploaded [trained checkpoints](https://huggingface.co/Luyu) with `RerankerForInference`.
```
from reranker import RerankerForInference
rk = RerankerForInference.from_pretrained("Luyu/bert-base-mdoc-bm25") # load checkpoint
inputs = rk.tokenize('weather in new york', 'it is cold today in new york', return_tensors='pt')
score = rk(inputs).logits
```
### Training
For training, you will need a model, a dataset and a trainer. Say we have parsed arguments into
`model_args`, `data_args` and `training_args` with `reranker.arguments`. First,
initialize the reranker and tokenizer from one of
[pre-tained language models](https://huggingface.co/transformers/pretrained_models.html) from Hugging Face.
For example, let's use RoBERTa by loading `roberta-base`.
```
from reranker import Reranker
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('roberta-base')
model = Reranker.from_pretrained(model_args, data_args, training_args, 'roberta-base')
```
Then create the dataset,
```
from reranker.data import GroupedTrainDataset
train_dataset = GroupedTrainDataset(
data_args, data_args.train_path,
tokenizer=tokenizer, train_args=training_args
)
```
Create a trainer and train,
```
from reranker import RerankerTrainer
trainer = RerankerTrainer(
model=model,
args=training_args,
train_dataset=train_dataset,
data_collator=GroupCollator(tokenizer),
)
trainer.train()
```
See full examples in our [examples](exampleExcerpt of 8,062 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:f942071111e98756, name:reranker