🚀 crossencoder-me5-base-mmarcoFR
This is a cross-encoder model designed for the French language. It conducts cross-attention between a question-passage pair and outputs a relevance score. The model serves as a reranker for semantic search. Given a query and a set of potentially relevant passages retrieved by an efficient first-stage retrieval system (e.g., BM25 or a fine-tuned dense single-vector bi-encoder), it encodes each query-passage pair and sorts the passages in descending order of relevance based on the model's predicted scores.
🚀 Quick Start
The model can be used with different libraries. Here are the steps for using it with Sentence-Transformers, FlagEmbedding, or Huggingface Transformers.
📦 Installation
Using Sentence-Transformers
Install the library:
pip install -U sentence-transformers
Using FlagEmbedding
Install the library:
pip install -U FlagEmbedding
Using HuggingFace Transformers
Install the library:
pip install -U transformers
💻 Usage Examples
Basic Usage
Using Sentence-Transformers
from sentence_transformers import CrossEncoder
pairs = [('Question', 'Paragraphe 1'), ('Question', 'Paragraphe 2') , ('Question', 'Paragraphe 3')]
model = CrossEncoder('antoinelouis/crossencoder-me5-base-mmarcoFR')
scores = model.predict(pairs)
print(scores)
Using FlagEmbedding
from FlagEmbedding import FlagReranker
pairs = [('Question', 'Paragraphe 1'), ('Question', 'Paragraphe 2') , ('Question', 'Paragraphe 3')]
reranker = FlagReranker('antoinelouis/crossencoder-me5-base-mmarcoFR')
scores = reranker.compute_score(pairs)
print(scores)
Using HuggingFace Transformers
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
pairs = [('Question', 'Paragraphe 1'), ('Question', 'Paragraphe 2') , ('Question', 'Paragraphe 3')]
tokenizer = AutoTokenizer.from_pretrained('antoinelouis/crossencoder-me5-base-mmarcoFR')
model = AutoModelForSequenceClassification.from_pretrained('antoinelouis/crossencoder-me5-base-mmarcoFR')
model.eval()
with torch.no_grad():
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
print(scores)
📚 Documentation
Evaluation
The model is evaluated on the smaller development set of mMARCO-fr, which consists of 6,980 queries. For these queries, an ensemble of 1000 passages containing the positive(s) and ColBERTv2 hard negatives need to be reranked. We report the mean reciprocal rank (MRR) and recall at various cut-offs (R@k). To see how it compares to other neural retrievers in French, check out the DécouvrIR leaderboard.
Training
Data
We use the French training samples from the mMARCO dataset, a multilingual machine-translated version of MS MARCO that contains 8.8M passages and 539K training queries. We do not use the BM25 negatives provided by the official dataset but instead sample harder negatives mined from 12 distinct dense retrievers, using the msmarco-hard-negatives distillation dataset. Eventually, we sample 2.6M training triplets of the form (query, passage, relevance) with a positive-to-negative ratio of 1 (i.e., 50% of the pairs are relevant and 50% are irrelevant).
Implementation
The model is initialized from the intfloat/multilingual-e5-base checkpoint and optimized via the binary cross-entropy loss (as in monoBERT). It is fine-tuned on one 80GB NVIDIA H100 GPU for 20k steps using the AdamW optimizer with a batch size of 128 and a constant learning rate of 2e-5. We set the maximum sequence length of the concatenated question-passage pairs to 256 tokens. We use the sigmoid function to get scores between 0 and 1.
🔧 Technical Details
Property |
Details |
Pipeline Tag |
text-ranking |
Language |
French |
License |
MIT |
Datasets |
unicamp-dl/mmarco |
Metrics |
recall |
Tags |
passage-reranking |
Library Name |
sentence-transformers |
Base Model |
intfloat/multilingual-e5-base |
Model Index
- Name: crossencoder-me5-base-mmarcoFR
- Results:
- Task:
- Type: text-classification
- Name: Passage Reranking
- Dataset:
- Name: mMARCO-fr
- Type: unicamp-dl/mmarco
- Config: french
- Split: validation
- Metrics:
- Type: recall_at_500
- Value: 96.32
- Name: Recall@500
- Type: recall_at_100
- Value: 85.73
- Name: Recall@100
- Type: recall_at_10
- Value: 60.88
- Name: Recall@10
- Type: mrr_at_10
- Value: 34.26
- Name: MRR@10
📄 License
This project is licensed under the MIT license.
📖 Citation
@online{louis2024decouvrir,
author = 'Antoine Louis',
title = 'DécouvrIR: A Benchmark for Evaluating the Robustness of Information Retrieval Models in French',
publisher = 'Hugging Face',
month = 'mar',
year = '2024',
url = 'https://huggingface.co/spaces/antoinelouis/decouvrir',
}