pipeline_tag: 文本排序
language: 法语
license: mit
datasets:
- unicamp-dl/mmarco
metrics:
- 召回率
tags:
- 段落重排序
library_name: sentence-transformers
base_model: intfloat/multilingual-e5-base
model-index:
- name: crossencoder-me5-base-mmarcoFR
results:
- task:
type: 文本分类
name: 段落重排序
dataset:
name: mMARCO-fr
type: unicamp-dl/mmarco
config: 法语
split: 验证集
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
crossencoder-me5-base-mmarcoFR
这是一个法语交叉编码器模型。它对问题-段落对执行交叉注意力机制并输出相关性分数。
该模型应用于语义搜索的重新排序阶段:给定查询和由高效初检系统(如BM25或微调的单向量双编码器)检索出的一组潜在相关段落,对每个查询-段落对进行编码,并根据模型预测的分数按相关性降序排列段落。
使用方式
以下是使用Sentence-Transformers、FlagEmbedding或HuggingFace Transformers调用模型的示例。
使用Sentence-Transformers
首先安装库:pip install -U sentence-transformers
,然后按如下方式使用:
from sentence_transformers import CrossEncoder
pairs = [('问题', '段落1'), ('问题', '段落2'), ('问题', '段落3')]
model = CrossEncoder('antoinelouis/crossencoder-me5-base-mmarcoFR')
scores = model.predict(pairs)
print(scores)
使用FlagEmbedding
首先安装库:pip install -U FlagEmbedding
,然后按如下方式使用:
from FlagEmbedding import FlagReranker
pairs = [('问题', '段落1'), ('问题', '段落2'), ('问题', '段落3')]
reranker = FlagReranker('antoinelouis/crossencoder-me5-base-mmarcoFR')
scores = reranker.compute_score(pairs)
print(scores)
使用HuggingFace Transformers
首先安装库:pip install -U transformers
,然后按如下方式使用:
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
pairs = [('问题', '段落1'), ('问题', '段落2'), ('问题', '段落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)
评估
模型在mMARCO-fr的小型开发集上进行评估,该数据集包含6,980个查询,每个查询需对包含正例和ColBERTv2困难负例的1000个段落进行重排序。我们报告不同截断值(R@k)下的平均倒数排名(MRR)和召回率。要了解其与其他法语神经检索模型的对比,请查看DécouvrIR排行榜。
训练
数据
我们使用来自mMARCO数据集的法语训练样本,这是MS MARCO的多语言机器翻译版本,包含880万段落和53.9万训练查询。我们未使用官方数据集提供的BM25负例,而是从12种不同的密集检索器中挖掘更困难的负例,采用msmarco-hard-negatives蒸馏数据集。最终,我们采样了260万组(查询,段落,相关性)训练三元组,正负样本比例为1:1(即50%相关对和50%不相关对)。
实现
模型初始化自intfloat/multilingual-e5-base检查点,并通过二元交叉熵损失优化(如monoBERT)。在一块80GB NVIDIA H100 GPU上微调20,000步,使用AdamW优化器,批量大小为128,恒定学习率2e-5。设置拼接后的问题-段落对最大序列长度为256个token,使用sigmoid函数将分数映射到0-1区间。
引用
@online{louis2024decouvrir,
author = '安托万·路易',
title = 'DécouvrIR:法语信息检索模型鲁棒性评估基准',
publisher = 'Hugging Face',
month = '3月',
year = '2024',
url = 'https://huggingface.co/spaces/antoinelouis/decouvrir',
}