Views
No views yet
train_script.py.1from sentence_transformers import CrossEncoder
2model = CrossEncoder('model_name', max_length=512)
3query = 'How many people live in Berlin?'
4docs = ['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.']
5pairs = [(query, doc) for doc in docs]
6scores = model.predict(pairs)1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model = AutoModelForSequenceClassification.from_pretrained('model_name')
5tokenizer = AutoTokenizer.from_pretrained('model_name')
6
7features = 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")
8
9model.eval()
10with torch.no_grad():
11 scores = model(**features).logits
12 print(scores)| Model-Name | TREC-DL19 EN-EN | TREC-DL19 DE-EN | GermanDPR DE-DE | Docs / Sec |
|---|---|---|---|---|
| BM25 | 45.46 | - | 35.85 | - |
| Cross-Encoder Re-Rankers | ||||
| cross-encoder/msmarco-MiniLM-L6-en-de-v1 | 72.43 | 65.53 | 46.77 | 1600 |
| cross-encoder/msmarco-MiniLM-L12-en-de-v1 | 72.94 | 66.07 | 49.91 | 900 |
| svalabs/cross-electra-ms-marco-german-uncased (DE only) | - | - | 53.67 | 260 |
| deepset/gbert-base-germandpr-reranking (DE only) | - | - | 53.59 | 260 |
| Bi-Encoders (re-ranking) | ||||
| sentence-transformers/msmarco-distilbert-multilingual-en-de-v2-tmp-lng-aligned | 63.38 | 58.28 | 37.88 | 940 |
| sentence-transformers/msmarco-distilbert-multilingual-en-de-v2-tmp-trained-scratch | 65.51 | 58.69 | 38.32 | 940 |
| svalabs/bi-electra-ms-marco-german-uncased (DE only) | - | - | 34.31 | 450 |
| deepset/gbert-base-germandpr-question_encoder (DE only) | - | - | 42.55 | 450 |