Reranker ModernBERT Base Gooaq Bce
这是一个从ModernBERT-base微调而来的交叉编码器模型,用于文本重排序和语义搜索任务。
下载量 483
发布时间 : 3/20/2025
模型简介
该模型是一个基于ModernBERT-base的交叉编码器,专门用于计算文本对的相似度分数,适用于信息检索中的重排序任务。
模型特点
长文本处理能力
支持最大8192个标记的序列长度,适合处理长文本
高效重排序
专为文本重排序任务优化,在GooAQ数据集上表现出色
二元分类
使用二元交叉熵损失进行训练,输出文本对的相关性分数
模型能力
文本相似度计算
信息检索结果重排序
语义搜索
使用案例
信息检索
搜索引擎结果重排序
对初步检索结果进行重排序以提高相关性
在GooAQ开发集上达到0.7713的NDCG@10
问答系统
对候选答案进行相关性排序
在NanoNQ数据集上达到0.4630的NDCG@10
🚀 在GooAQ上训练的ModernBERT-base
这是一个基于answerdotai/ModernBERT-base,使用sentence-transformers库微调得到的交叉编码器模型。它可以为文本对计算得分,这些得分可用于文本重排序和语义搜索。
训练脚本请参考training_gooaq_bce.py。该脚本也在交叉编码器 > 训练概述文档和使用Sentence Transformers v4训练和微调重排序模型博客文章中有所描述。
🚀 快速开始
本模型是一个基于answerdotai/ModernBERT-base微调的交叉编码器模型,可用于文本对得分计算,适用于文本重排序和语义搜索任务。
✨ 主要特性
- 基于预训练的
answerdotai/ModernBERT-base
模型进行微调,能有效计算文本对的得分。 - 可用于文本重排序和语义搜索,为相关任务提供支持。
📦 安装指南
首先安装Sentence Transformers库:
pip install -U sentence-transformers
💻 使用示例
基础用法
from sentence_transformers import CrossEncoder
# 从🤗 Hub下载模型
model = CrossEncoder("tomaarsen/reranker-ModernBERT-base-gooaq-bce")
# 获取文本对的得分
pairs = [
['why are rye chips so good?', "It makes them taste that much better! The rye chips are tasty because they stand out--they're the saltiest thing in the bag. It's not because rye bread is inherently awesome. ... You could just buy a bag of rye chips."],
['why are rye chips so good?', 'There are no substantial technical, nutritional or performance issues associated with rye that would limit its use for pets. Rye is a fairly common ingredient in human foods and beverages. The most prevalent occurrence is in crackers and breads.'],
['why are rye chips so good?', 'Bread made wholly from rye flour is made in Germany and called pumpernickel. Rye is unique among grains for having a high level of fibre in its endosperm – not just in its bran. As such, the glycemic index (GI) of rye products is generally lower than products made from wheat and most other grains.'],
['why are rye chips so good?', 'KFC Chips – The salt mix on the seasoned chips and the actual chips do not contain any animal products. Our supplier/s of chips and seasoning have confirmed they are suitable for vegans.'],
['why are rye chips so good?', 'A study in the American Journal of Clinical Nutrition found that eating rye leads to better blood-sugar control compared to wheat. Rye bread is packed with magnesium, which helps control blood pressure and optimize heart health. Its high levels of soluble fibre can also reduce cholesterol.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# 或者根据与单个文本的相似度对不同文本进行排序
ranks = model.rank(
'why are rye chips so good?',
[
"It makes them taste that much better! The rye chips are tasty because they stand out--they're the saltiest thing in the bag. It's not because rye bread is inherently awesome. ... You could just buy a bag of rye chips.",
'There are no substantial technical, nutritional or performance issues associated with rye that would limit its use for pets. Rye is a fairly common ingredient in human foods and beverages. The most prevalent occurrence is in crackers and breads.',
'Bread made wholly from rye flour is made in Germany and called pumpernickel. Rye is unique among grains for having a high level of fibre in its endosperm – not just in its bran. As such, the glycemic index (GI) of rye products is generally lower than products made from wheat and most other grains.',
'KFC Chips – The salt mix on the seasoned chips and the actual chips do not contain any animal products. Our supplier/s of chips and seasoning have confirmed they are suitable for vegans.',
'A study in the American Journal of Clinical Nutrition found that eating rye leads to better blood-sugar control compared to wheat. Rye bread is packed with magnesium, which helps control blood pressure and optimize heart health. Its high levels of soluble fibre can also reduce cholesterol.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
📚 详细文档
模型详情
模型描述
属性 | 详情 |
---|---|
模型类型 | 交叉编码器 |
基础模型 | answerdotai/ModernBERT-base |
最大序列长度 | 8192个标记 |
输出标签数量 | 1个标签 |
语言 | 英语 |
许可证 | apache-2.0 |
模型来源
- 文档:Sentence Transformers文档
- 文档:交叉编码器文档
- 仓库:GitHub上的Sentence Transformers
- Hugging Face:Hugging Face上的交叉编码器
评估
交叉编码器重排序
- 数据集:
gooaq-dev
- 评估方法:使用
CrossEncoderRerankingEvaluator
,参数如下:{ "at_k": 10, "always_rerank_positives": false }
指标 | 值 |
---|---|
map | 0.7308 (+0.1997) |
mrr@10 | 0.7292 (+0.2052) |
ndcg@10 | 0.7713 (+0.1801) |
- 数据集:
gooaq-dev
- 评估方法:使用
CrossEncoderRerankingEvaluator
,参数如下:{ "at_k": 10, "always_rerank_positives": true }
指标 | 值 |
---|---|
map | 0.7908 (+0.2597) |
mrr@10 | 0.7890 (+0.2650) |
ndcg@10 | 0.8351 (+0.2439) |
- 数据集:
NanoMSMARCO_R100
、NanoNFCorpus_R100
和NanoNQ_R100
- 评估方法:使用
CrossEncoderRerankingEvaluator
,参数如下:{ "at_k": 10, "always_rerank_positives": true }
指标 | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
---|---|---|---|
map | 0.4579 (-0.0317) | 0.3414 (+0.0804) | 0.3932 (-0.0264) |
mrr@10 | 0.4479 (-0.0296) | 0.5340 (+0.0342) | 0.3918 (-0.0349) |
ndcg@10 | 0.5275 (-0.0130) | 0.3821 (+0.0571) | 0.4630 (-0.0377) |
交叉编码器Nano BEIR
- 数据集:
NanoBEIR_R100_mean
- 评估方法:使用
CrossEncoderNanoBEIREvaluator
,参数如下:{ "dataset_names": [ "msmarco", "nfcorpus", "nq" ], "rerank_k": 100, "at_k": 10, "always_rerank_positives": true }
指标 | 值 |
---|---|
map | 0.3975 (+0.0074) |
mrr@10 | 0.4579 (-0.0101) |
ndcg@10 | 0.4575 (+0.0022) |
训练详情
训练数据集
未命名数据集
- 大小:578,402个训练样本
- 列:
question
、answer
和label
- 基于前1000个样本的近似统计信息:
| | 问题 | 答案 | 标签 |
|------|------|------|------|
| 类型 | 字符串 | 字符串 | 整数 |
| 详情 |
- 最小:19个字符
- 平均:45.14个字符
- 最大:85个字符
- 最小:65个字符
- 平均:254.8个字符
- 最大:379个字符
- 0:~82.90%
- 1:~17.10%
- 样本:
| 问题 | 答案 | 标签 |
|------|------|------|
|
why are rye chips so good?
|It makes them taste that much better! The rye chips are tasty because they stand out--they're the saltiest thing in the bag. It's not because rye bread is inherently awesome. ... You could just buy a bag of rye chips.
|1
| |why are rye chips so good?
|There are no substantial technical, nutritional or performance issues associated with rye that would limit its use for pets. Rye is a fairly common ingredient in human foods and beverages. The most prevalent occurrence is in crackers and breads.
|0
| |why are rye chips so good?
|Bread made wholly from rye flour is made in Germany and called pumpernickel. Rye is unique among grains for having a high level of fibre in its endosperm – not just in its bran. As such, the glycemic index (GI) of rye products is generally lower than products made from wheat and most other grains.
|0
| - 损失函数:
BinaryCrossEntropyLoss
,参数如下:{ "activation_fct": "torch.nn.modules.linear.Identity", "pos_weight": 5 }
训练超参数
非默认超参数
eval_strategy
:stepsper_device_train_batch_size
:64per_device_eval_batch_size
:64learning_rate
:2e-05num_train_epochs
:1warmup_ratio
:0.1seed
:12bf16
:Truedataloader_num_workers
:4load_best_model_at_end
:True
训练日志
轮次 | 步骤 | 训练损失 | gooaq-dev_ndcg@10 | NanoMSMARCO_R100_ndcg@10 | NanoNFCorpus_R100_ndcg@10 | NanoNQ_R100_ndcg@10 | NanoBEIR_R100_mean_ndcg@10 |
---|---|---|---|---|---|---|---|
-1 | -1 | - | 0.1288 (-0.4624) | 0.0149 (-0.5255) | 0.2278 (-0.0972) | 0.0229 (-0.4777) | 0.0885 (-0.3668) |
0.0001 | 1 | 1.0435 | - | - | - | - | - |
0.0221 | 200 | 1.1924 | - | - | - | - | - |
0.0443 | 400 | 1.1531 | - | - | - | - | - |
0.0664 | 600 | 0.9371 | - | - | - | - | - |
0.0885 | 800 | 0.6993 | - | - | - | - | - |
0.1106 | 1000 | 0.669 | 0.7042 (+0.1130) | 0.4353 (-0.1051) | 0.3289 (+0.0039) | 0.4250 (-0.0757) | 0.3964 (-0.0590) |
0.1328 | 1200 | 0.6257 | - | - | - | - | - |
0.1549 | 1400 | 0.6283 | - | - | - | - | - |
0.1770 | 1600 | 0.6014 | - | - | - | - | - |
0.1992 | 1800 | 0.5888 | - | - | - | - | - |
0.2213 | 2000 | 0.5493 | 0.7425 (+0.1513) | 0.4947 (-0.0457) | 0.3568 (+0.0318) | 0.4634 (-0.0373) | 0.4383 (-0.0171) |
0.2434 | 2200 | 0.5479 | - | - | - | - | - |
0.2655 | 2400 | 0.5329 | - | - | - | - | - |
0.2877 | 2600 | 0.5208 | - | - | - | - | - |
0.3098 | 2800 | 0.5259 | - | - | - | - | - |
0.3319 | 3000 | 0.5221 | 0.7479 (+0.1567) | 0.5146 (-0.0258) | 0.3710 (+0.0460) | 0.4846 (-0.0160) | 0.4568 (+0.0014) |
0.3541 | 3200 | 0.4977 | - | - | - | - | - |
0.3762 | 3400 | 0.4965 | - | - | - | - | - |
0.3983 | 3600 | 0.4985 | - | - | - | - | - |
0.4204 | 3800 | 0.4907 | - | - | - | - | - |
0.4426 | 4000 | 0.5058 | 0.7624 (+0.1712) | 0.5166 (-0.0238) | 0.3665 (+0.0415) | 0.4868 (-0.0138) | 0.4567 (+0.0013) |
0.4647 | 4200 | 0.4885 | - | - | - | - | - |
0.4868 | 4400 | 0.495 | - | - | - | - | - |
0.5090 | 4600 | 0.4839 | - | - | - | - | - |
0.5311 | 4800 | 0.4983 | - | - | - | - | - |
0.5532 | 5000 | 0.4778 | 0.7603 (+0.1691) | 0.5110 (-0.0294) | 0.3540 (+0.0290) | 0.4809 (-0.0197) | 0.4487 (-0.0067) |
0.5753 | 5200 | 0.4726 | - | - | - | - | - |
0.5975 | 5400 | 0.477 | - | - | - | - | - |
0.6196 | 5600 | 0.4613 | - | - | - | - | - |
0.6417 | 5800 | 0.4492 | - | - | - | - | - |
0.6639 | 6000 | 0.4506 | 0.7643 (+0.1731) | 0.5275 (-0.0129) | 0.3639 (+0.0389) | 0.4913 (-0.0094) | 0.4609 (+0.0055) |
0.6860 | 6200 | 0.4618 | - | - | - | - | - |
0.7081 | 6400 | 0.463 | - | - | - | - | - |
0.7303 | 6600 | 0.4585 | - | - | - | - | - |
0.7524 | 6800 | 0.4612 | - | - | - | - | - |
0.7745 | 7000 | 0.4621 | 0.7649 (+0.1736) | 0.5105 (-0.0299) | 0.3688 (+0.0437) | 0.4552 (-0.0454) | 0.4448 (-0.0105) |
0.7966 | 7200 | 0.4536 | - | - | - | - | - |
0.8188 | 7400 | 0.4515 | - | - | - | - | - |
0.8409 | 7600 | 0.4396 | - | - | - | - | - |
0.8630 | 7800 | 0.4542 | - | - | - | - | - |
0.8852 | 8000 | 0.4332 | 0.7669 (+0.1757) | 0.5247 (-0.0157) | 0.3794 (+0.0544) | 0.4370 (-0.0637) | 0.4470 (-0.0083) |
0.9073 | 8200 | 0.447 | - | - | - | - | - |
0.9294 | 8400 | 0.4335 | - | - | - | - | - |
0.9515 | 8600 | 0.4179 | - | - | - | - | - |
0.9737 | 8800 | 0.4459 | - | - | - | - | - |
0.9958 | 9000 | 0.4196 | 0.7713 (+0.1801) | 0.5275 (-0.0130) | 0.3821 (+0.0571) | 0.4630 (-0.0377) | 0.4575 (+0.0022) |
-1 | -1 | - | 0.7713 (+0.1801) | 0.5275 (-0.0130) | 0.3821 (+0.0571) | 0.4630 (-0.0377) | 0.4575 (+0.0022) |
注:加粗行表示保存的检查点。
框架版本
- Python:3.11.10
- Sentence Transformers:3.5.0.dev0
- Transformers:4.49.0
- PyTorch:2.5.1+cu124
- Accelerate:1.5.2
- Datasets:2.21.0
- Tokenizers:0.21.0
📄 许可证
本模型使用apache-2.0许可证。
📚 引用
BibTeX
Sentence Transformers
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
Jina Embeddings V3
Jina Embeddings V3 是一个多语言句子嵌入模型,支持超过100种语言,专注于句子相似度和特征提取任务。
文本嵌入
Transformers 支持多种语言

J
jinaai
3.7M
911
Ms Marco MiniLM L6 V2
Apache-2.0
基于MS Marco段落排序任务训练的交叉编码器模型,用于信息检索中的查询-段落相关性评分
文本嵌入 英语
M
cross-encoder
2.5M
86
Opensearch Neural Sparse Encoding Doc V2 Distill
Apache-2.0
基于蒸馏技术的稀疏检索模型,专为OpenSearch优化,支持免推理文档编码,在搜索相关性和效率上优于V1版本
文本嵌入
Transformers 英语

O
opensearch-project
1.8M
7
Sapbert From PubMedBERT Fulltext
Apache-2.0
基于PubMedBERT的生物医学实体表征模型,通过自对齐预训练优化语义关系捕捉
文本嵌入 英语
S
cambridgeltl
1.7M
49
Gte Large
MIT
GTE-Large 是一个强大的句子转换器模型,专注于句子相似度和文本嵌入任务,在多个基准测试中表现出色。
文本嵌入 英语
G
thenlper
1.5M
278
Gte Base En V1.5
Apache-2.0
GTE-base-en-v1.5 是一个英文句子转换器模型,专注于句子相似度任务,在多个文本嵌入基准测试中表现优异。
文本嵌入
Transformers 支持多种语言

G
Alibaba-NLP
1.5M
63
Gte Multilingual Base
Apache-2.0
GTE Multilingual Base 是一个多语言的句子嵌入模型,支持超过50种语言,适用于句子相似度计算等任务。
文本嵌入
Transformers 支持多种语言

G
Alibaba-NLP
1.2M
246
Polybert
polyBERT是一个化学语言模型,旨在实现完全由机器驱动的超快聚合物信息学。它将PSMILES字符串映射为600维密集指纹,以数值形式表示聚合物化学结构。
文本嵌入
Transformers

P
kuelumbus
1.0M
5
Bert Base Turkish Cased Mean Nli Stsb Tr
Apache-2.0
基于土耳其语BERT的句子嵌入模型,专为语义相似度任务优化
文本嵌入
Transformers 其他

B
emrecan
1.0M
40
GIST Small Embedding V0
MIT
基于BAAI/bge-small-en-v1.5模型微调的文本嵌入模型,通过MEDI数据集与MTEB分类任务数据集训练,优化了检索任务的查询编码能力。
文本嵌入
Safetensors 英语
G
avsolatorio
945.68k
29
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98