🚀 用於MS Marco的交叉編碼器
本模型針對MS Marco段落排序任務進行訓練。該模型可用於信息檢索:給定一個查詢,將查詢與所有可能的段落(例如通過ElasticSearch檢索到的段落)進行編碼,然後按降序對段落進行排序。更多詳細信息請參閱SBERT.net檢索與重排序。訓練代碼可在此處獲取:SBERT.net訓練MS Marco。
🚀 快速開始
✨ 主要特性
- 基於MS Marco段落排序任務訓練,適用於信息檢索場景。
- 提供多種預訓練版本,可根據不同需求選擇。
📦 安裝指南
文檔未提及安裝步驟,可參考相關庫的官方文檔進行安裝:
💻 使用示例
基礎用法
使用SentenceTransformers
庫調用模型:
from sentence_transformers import CrossEncoder
model = CrossEncoder('cross-encoder/ms-marco-MiniLM-L4-v2')
scores = model.predict([
("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
("How many people live in Berlin?", "Berlin is well known for its museums."),
])
print(scores)
高級用法
使用Transformers
庫調用模型:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/ms-marco-MiniLM-L4-v2')
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/ms-marco-MiniLM-L4-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)
📚 詳細文檔
在以下表格中,我們列出了各種預訓練的交叉編碼器及其在TREC深度學習2019和MS Marco段落重排序數據集上的性能表現。
模型名稱 |
NDCG@10 (TREC DL 19) |
MRR@10 (MS Marco Dev) |
文檔/秒 |
版本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 |
基礎模型 |
cross-encoder/ms-marco-MiniLM-L12-v2 |
任務類型 |
文本排序 |
庫名稱 |
sentence-transformers |
標籤 |
transformers |