This is a cross-encoder model for French. It performs cross-attention between a question-passage pair and outputs a relevance score.
The model should be used 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), encode each query-passage pair and sort the passages in a decreasing order of
relevance according to the model's predicted scores.
Start by installing the
library:
pip install -U sentence-transformers. Then, you can use the model like this:
1from sentence_transformers import CrossEncoder
2
3pairs = [('Question', 'Paragraphe 1'), ('Question', 'Paragraphe 2') , ('Question', 'Paragraphe 3')]
4
5model = CrossEncoder('antoinelouis/crossencoder-camemberta-L10-mmarcoFR')
6scores = model.predict(pairs)
7print(scores)
Start by installing the
library:
pip install -U FlagEmbedding. Then, you can use the model like this:
1from FlagEmbedding import FlagReranker
2
3pairs = [('Question', 'Paragraphe 1'), ('Question', 'Paragraphe 2') , ('Question', 'Paragraphe 3')]
4
5reranker = FlagReranker('antoinelouis/crossencoder-camemberta-L10-mmarcoFR')
6scores = reranker.compute_score(pairs)
7print(scores)
Start by installing the
library:
pip install -U transformers. Then, you can use the model like this:
1import torch
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4pairs = [('Question', 'Paragraphe 1'), ('Question', 'Paragraphe 2') , ('Question', 'Paragraphe 3')]
5
6tokenizer = AutoTokenizer.from_pretrained('antoinelouis/crossencoder-camemberta-L10-mmarcoFR')
7model = AutoModelForSequenceClassification.from_pretrained('antoinelouis/crossencoder-camemberta-L10-mmarcoFR')
8model.eval()
9
10with torch.no_grad():
11 inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
12 scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
13print(scores)
The model is evaluated on the smaller development set of
mMARCO-fr, which consists of 6,980 queries for which
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.
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).
The model is initialized from the
antoinelouis/camemberta-L10 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.
1@online{louis2024decouvrir,
2 author = 'Antoine Louis',
3 title = 'DécouvrIR: A Benchmark for Evaluating the Robustness of Information Retrieval Models in French',
4 publisher = 'Hugging Face',
5 month = 'mar',
6 year = '2024',
7 url = 'https://huggingface.co/spaces/antoinelouis/decouvrir',
8}