Reranker Msmarco ModernBERT Base Lambdaloss
這是一個從ModernBERT-base微調而來的交叉編碼器模型,用於計算文本對的分數,適用於文本重排序和語義搜索任務。
下載量 89
發布時間 : 3/17/2025
模型概述
該模型基於ModernBERT-base架構,使用sentence-transformers庫在msmarco數據集上訓練,專門用於計算文本對的相似度分數,可應用於信息檢索、問答系統等場景。
模型特點
高效文本重排序
能夠快速計算文本對的相似度分數,有效提升檢索系統的排序質量
大序列長度支持
支持最大8192個標記的序列長度,適合處理長文本
高性能指標
在多個評估數據集上表現出色,如NanoMSMARCO_R100上ndcg@10達到0.7251
模型能力
文本相似度計算
信息檢索結果重排序
問答系統答案排序
語義搜索
使用案例
信息檢索
搜索引擎結果重排序
對搜索引擎返回的結果進行二次排序,提高相關文檔的排名
在MSMARCO數據集上map達到0.6768
問答系統
答案相關性排序
對候選答案進行相關性評分,選擇最相關的答案
在NanoNQ_R100數據集上mrr@10達到0.7402
🚀 基於answerdotai/ModernBERT-base的交叉編碼器
本模型是基於answerdotai/ModernBERT-base
的交叉編碼器,在msmarco
數據集上使用sentence-transformers
庫進行微調。它可以計算文本對的得分,可用於文本重排序和語義搜索。
🚀 快速開始
直接使用(Sentence Transformers)
首先安裝Sentence Transformers庫:
pip install -U sentence-transformers
然後你可以加載這個模型並進行推理。
from sentence_transformers import CrossEncoder
# 從🤗 Hub下載模型
model = CrossEncoder("tomaarsen/reranker-msmarco-ModernBERT-base-lambdaloss")
# 獲取文本對的得分
pairs = [
['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (3,)
# 或者根據與單個文本的相似度對不同文本進行排序
ranks = model.rank(
'How many calories in an egg',
[
'There are on average between 55 and 80 calories in an egg depending on its size.',
'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
'Most of the calories in an egg come from the yellow yolk in the center.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
✨ 主要特性
- 基於
answerdotai/ModernBERT-base
模型進行微調,具有良好的文本處理能力。 - 能夠計算文本對的得分,可用於文本重排序和語義搜索。
- 支持最大長度為8192個標記的輸入序列。
📦 安裝指南
安裝Sentence Transformers庫:
pip install -U sentence-transformers
💻 使用示例
基礎用法
from sentence_transformers import CrossEncoder
# 從🤗 Hub下載模型
model = CrossEncoder("tomaarsen/reranker-msmarco-ModernBERT-base-lambdaloss")
# 獲取文本對的得分
pairs = [
['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (3,)
高級用法
from sentence_transformers import CrossEncoder
# 從🤗 Hub下載模型
model = CrossEncoder("tomaarsen/reranker-msmarco-ModernBERT-base-lambdaloss")
# 根據與單個文本的相似度對不同文本進行排序
ranks = model.rank(
'How many calories in an egg',
[
'There are on average between 55 and 80 calories in an egg depending on its size.',
'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
'Most of the calories in an egg come from the yellow yolk in the center.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
📚 詳細文檔
模型詳情
模型描述
屬性 | 詳情 |
---|---|
模型類型 | 交叉編碼器 |
基礎模型 | answerdotai/ModernBERT-base |
最大序列長度 | 8192個標記 |
輸出標籤數量 | 1個標籤 |
訓練數據集 | msmarco |
語言 | 英語 |
模型來源
- 文檔:Sentence Transformers文檔
- 文檔:交叉編碼器文檔
- 倉庫:GitHub上的Sentence Transformers
- Hugging Face:Hugging Face上的交叉編碼器
評估
指標
交叉編碼器重排序
- 數據集:
NanoMSMARCO_R100
、NanoNFCorpus_R100
和NanoNQ_R100
- 使用
CrossEncoderRerankingEvaluator
進行評估,參數如下:{ "at_k": 10, "always_rerank_positives": true }
指標 | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
---|---|---|---|
map | 0.6768 (+0.1872) | 0.3576 (+0.0966) | 0.7134 (+0.2938) |
mrr@10 | 0.6690 (+0.1915) | 0.5819 (+0.0820) | 0.7402 (+0.3135) |
ndcg@10 | 0.7251 (+0.1847) | 0.4143 (+0.0892) | 0.7594 (+0.2587) |
交叉編碼器Nano BEIR
- 數據集:
NanoBEIR_R100_mean
- 使用
CrossEncoderNanoBEIREvaluator
進行評估,參數如下:{ "dataset_names": [ "msmarco", "nfcorpus", "nq" ], "rerank_k": 100, "at_k": 10, "always_rerank_positives": true }
指標 | 值 |
---|---|
map | 0.5826 (+0.1925) |
mrr@10 | 0.6637 (+0.1957) |
ndcg@10 | 0.6329 (+0.1776) |
訓練詳情
訓練數據集
評估數據集
訓練超參數
- 非默認超參數:
eval_strategy
: stepsnum_train_epochs
: 1warmup_ratio
: 0.1seed
: 12bf16
: Trueload_best_model_at_end
: True
框架版本
- Python: 3.11.10
- Sentence Transformers: 3.5.0.dev0
- Transformers: 4.49.0
- PyTorch: 2.5.1+cu124
- Accelerate: 1.2.0
- Datasets: 2.21.0
- Tokenizers: 0.21.0
🔧 技術細節
損失函數
使用LambdaLoss
損失函數,參數如下:
{
"weighting_scheme": "sentence_transformers.cross_encoder.losses.LambdaLoss.NDCGLoss2PPScheme",
"k": null,
"sigma": 1.0,
"eps": 1e-10,
"reduction_log": "binary",
"activation_fct": "torch.nn.modules.linear.Identity",
"mini_batch_size": 8
}
訓練日誌
點擊展開
輪次 | 步數 | 訓練損失 | 驗證損失 | NanoMSMARCO_R100_ndcg@10 | NanoNFCorpus_R100_ndcg@10 | NanoNQ_R100_ndcg@10 | NanoBEIR_R100_mean_ndcg@10 |
---|---|---|---|---|---|---|---|
-1 | -1 | - | - | 0.0234 (-0.5170) | 0.3412 (+0.0161) | 0.0321 (-0.4686) | 0.1322 (-0.3231) |
0.0000 | 1 | 0.8349 | - | - | - | - | - |
0.0040 | 200 | 0.8417 | - | - | - | - | - |
... | ... | ... | ... | ... | ... | ... | ... |
0.8014 | 40000 | 0.1381 | 0.1289 | 0.7251 (+0.1847) | 0.4143 (+0.0892) | 0.7594 (+0.2587) | 0.6329 (+0.1776) |
... | ... | ... | ... | ... | ... | ... | ... |
- 加粗行表示保存的檢查點。
📄 許可證
本模型使用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",
}
LambdaLoss
@inproceedings{wang2018lambdaloss,
title={The lambdaloss framework for ranking metric optimization},
author={Wang, Xuanhui and Li, Cheng and Golbandi, Nadav and Bendersky, Michael and Najork, Marc},
booktitle={Proceedings of the 27th ACM international conference on information and knowledge management},
pages={1313--1322},
year={2018}
}
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