🚀 用於MS Marco的交叉編碼器
本模型用於解決信息檢索中的排序問題,基於MS Marco數據集訓練,可對查詢和段落進行打分排序,為信息檢索提供更精準的結果。
🚀 快速開始
此模型在 MS Marco段落排序 任務上進行了訓練。
該模型可用於信息檢索:給定一個查詢,將該查詢與所有可能的段落(例如通過ElasticSearch檢索得到的段落)進行編碼。然後按降序對段落進行排序。更多詳細信息請參閱 SBERT.net 檢索與重排序。訓練代碼可在此處獲取:SBERT.net 訓練 MS Marco
💻 使用示例
與Transformers庫一起使用
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/ms-marco-TinyBERT-L2-v2')
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/ms-marco-TinyBERT-L2-v2')
features = tokenizer(['How many people live in Berlin?', 'How many people live in Berlin?'], ['Berlin has a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers.', 'New York City is famous for the Metropolitan Museum of Art.'], padding=True, truncation=True, return_tensors="pt")
model.eval()
with torch.no_grad():
scores = model(**features).logits
print(scores)
與SentenceTransformers庫一起使用
當你安裝了 SentenceTransformers 庫後,使用起來會更簡單。你可以像這樣使用預訓練模型:
from sentence_transformers import CrossEncoder
model = CrossEncoder('cross-encoder/ms-marco-TinyBERT-L2-v2', max_length=512)
scores = model.predict([('Query', 'Paragraph1'), ('Query', 'Paragraph2') , ('Query', 'Paragraph3')])
📚 詳細文檔
在下表中,我們提供了各種預訓練的交叉編碼器及其在 TREC深度學習2019 和 MS Marco段落重排序 數據集上的性能表現。
模型名稱 |
TREC DL 19的NDCG@10 |
MS Marco Dev的MRR@10 |
每秒處理文檔數 |
版本2模型 |
|
|
|
cross-encoder/ms-marco-TinyBERT-L2-v2 |
69.84 |
32.56 |
9000 |
cross-encoder/ms-marco-MiniLM-L2-v2 |
71.01 |
34.85 |
4100 |
cross-encoder/ms-marco-MiniLM-L4-v2 |
73.04 |
37.70 |
2500 |
cross-encoder/ms-marco-MiniLM-L6-v2 |
74.30 |
39.01 |
1800 |
cross-encoder/ms-marco-MiniLM-L12-v2 |
74.31 |
39.02 |
960 |
版本1模型 |
|
|
|
cross-encoder/ms-marco-TinyBERT-L2 |
67.43 |
30.15 |
9000 |
cross-encoder/ms-marco-TinyBERT-L4 |
68.09 |
34.50 |
2900 |
cross-encoder/ms-marco-TinyBERT-L6 |
69.57 |
36.13 |
680 |
cross-encoder/ms-marco-electra-base |
71.99 |
36.41 |
340 |
其他模型 |
|
|
|
nboost/pt-tinybert-msmarco |
63.63 |
28.80 |
2900 |
nboost/pt-bert-base-uncased-msmarco |
70.94 |
34.75 |
340 |
nboost/pt-bert-large-msmarco |
73.36 |
36.48 |
100 |
Capreolus/electra-base-msmarco |
71.23 |
36.89 |
340 |
amberoad/bert-multilingual-passage-reranking-msmarco |
68.40 |
35.54 |
330 |
sebastian-hofstaetter/distilbert-cat-margin_mse-T2-msmarco |
72.82 |
37.88 |
720 |
注意:運行時間是在V100 GPU上計算得出的。
📄 許可證
本項目採用Apache-2.0許可證。
📦 模型信息
屬性 |
詳情 |
模型類型 |
用於文本排序的交叉編碼器 |
訓練數據 |
sentence-transformers/msmarco |
基礎模型 |
nreimers/BERT-Tiny_L-2_H-128_A-2 |
庫名稱 |
sentence-transformers |
標籤 |
transformers |