pipeline_tag: 文本排序
language: 法语
license: mit
datasets:
- unicamp-dl/mmarco
metrics:
- 召回率
tags:
- 段落重排序
library_name: sentence-transformers
base_model: microsoft/mdeberta-v3-base
model-index:
- name: crossencoder-mdebertav3-base-mmarcoFR
results:
- task:
type: 文本分类
name: 段落重排序
dataset:
name: mMARCO-fr
type: unicamp-dl/mmarco
config: 法语
split: 验证集
metrics:
- type: recall_at_500
value: 97.4
name: Recall@500
- type: recall_at_100
value: 87.41
name: Recall@100
- type: recall_at_10
value: 62.52
name: Recall@10
- type: mrr_at_10
value: 36.16
name: MRR@10
crossencoder-mdebertav3-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-mdebertav3-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-mdebertav3-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-mdebertav3-base-mmarcoFR')
model = AutoModelForSequenceClassification.from_pretrained('antoinelouis/crossencoder-mdebertav3-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个段落进行重排序。我们报告不同截断点的平均倒数排名(MRR)和召回率(R@k)。要了解其在法语神经检索模型中的表现,请查看DécouvrIR排行榜。
训练
数据
我们使用来自mMARCO数据集的法语训练样本,这是MS MARCO的多语言机器翻译版本,包含880万段落和53.9万训练查询。我们未使用官方数据集提供的BM25负例,而是从12种不同的密集检索器中挖掘更困难的负例,采用msmarco-hard-negatives蒸馏数据集。最终,我们采样了260万组训练三元组(查询、段落、相关性),正负样本比例为1:1(即50%相关对和50%不相关对)。
实现
模型初始化为microsoft/mdeberta-v3-base检查点,并通过二元交叉熵损失优化(如monoBERT)。在一块80GB NVIDIA H100 GPU上微调20k步,使用AdamW优化器,批量大小为128,恒定学习率2e-5。设置拼接后的问题-段落对最大序列长度为256个token,使用sigmoid函数将分数限定在0到1之间。
引用
@online{louis2024decouvrir,
author = 'Antoine Louis',
title = 'DécouvrIR: 法语信息检索模型鲁棒性评估基准',
publisher = 'Hugging Face',
month = '3月',
year = '2024',
url = 'https://huggingface.co/spaces/antoinelouis/decouvrir',
}