🚀 用於MS Marco的交叉編碼器
本模型在MS Marco段落排序任務上進行了訓練。該模型可用於信息檢索,給定一個查詢,將查詢與所有可能的段落(例如通過ElasticSearch檢索到的段落)進行編碼,然後按降序對段落進行排序。更多詳細信息請參閱SBERT.net檢索與重排。訓練代碼可在此處獲取:SBERT.net訓練MS Marco。
🚀 快速開始
✨ 主要特性
- 基於MS Marco段落排序任務訓練,適用於信息檢索場景。
- 提供了使用
SentenceTransformers
和Transformers
庫的使用示例。
📦 安裝指南
文檔未提及具體安裝步驟,若使用相關代碼,需安裝SentenceTransformers
或Transformers
庫。
💻 使用示例
基礎用法(使用SentenceTransformers)
當你安裝了SentenceTransformers庫後,使用起來非常簡單。你可以像這樣使用預訓練模型:
from sentence_transformers import CrossEncoder
model = CrossEncoder('cross-encoder/ms-marco-MiniLM-L12-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-L12-v2')
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/ms-marco-MiniLM-L12-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段落重排數據集上的性能表現。
屬性 |
詳情 |
模型類型 |
交叉編碼器(Cross-Encoder) |
訓練數據 |
sentence-transformers/msmarco |
基礎模型 |
microsoft/MiniLM-L12-H384-uncased |
任務類型 |
文本排序(text-ranking) |
庫名稱 |
sentence-transformers |
標籤 |
transformers |
模型名稱 |
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許可證。