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