Create README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
How to use:
|
2 |
+
|
3 |
+
With sentence transformers:
|
4 |
+
```
|
5 |
+
from sentence_transformers import CrossEncoder
|
6 |
+
model_path = "clarin-knext/herbert-large-msmarco"
|
7 |
+
model = CrossEncoder(model_path, max_length=512)
|
8 |
+
|
9 |
+
scores = model.predict([('Query', 'Paragraph1'), ('Query', 'Paragraph2') , ('Query', 'Paragraph3')])
|
10 |
+
```
|
11 |
+
|
12 |
+
With transformers:
|
13 |
+
```
|
14 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
15 |
+
import torch
|
16 |
+
|
17 |
+
model_path = "clarin-knext/herbert-large-msmarco"
|
18 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
20 |
+
|
21 |
+
features = tokenizer(['Jakie miasto jest stolica Polski?', 'Stolicą Polski jest Warszawa.'], padding=True, truncation=True, return_tensors="pt")
|
22 |
+
|
23 |
+
model.eval()
|
24 |
+
with torch.no_grad():
|
25 |
+
scores = model(**features).logits
|
26 |
+
print(scores)
|
27 |
+
```
|