Update README.md
Browse files
README.md
CHANGED
@@ -5,4 +5,36 @@ datasets:
|
|
5 |
language:
|
6 |
- ru
|
7 |
library_name: sentence-transformers
|
8 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
language:
|
6 |
- ru
|
7 |
library_name: sentence-transformers
|
8 |
+
---
|
9 |
+
|
10 |
+
## Пример 1
|
11 |
+
```python
|
12 |
+
from transformers import AutoModel, AutoTokenizer, AutoModelForSequenceClassification
|
13 |
+
import torch
|
14 |
+
sigmoid_fn = torch.nn.Sigmoid()
|
15 |
+
# model = AutoModelForSequenceClassification.from_pretrained("/home/jovyan/pakorolev/ranker/deep_pavlov_mrr_0_8413")
|
16 |
+
# tokenizer = AutoTokenizer.from_pretrained("/home/jovyan/pakorolev/ranker/deep_pavlov_mrr_0_8413")
|
17 |
+
|
18 |
+
model = AutoModelForSequenceClassification.from_pretrained("PitKoro/cross-encoder-ru-msmarco-passage")
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained("PitKoro/cross-encoder-ru-msmarco-passage")
|
20 |
+
|
21 |
+
text = [['привет', 'привет'],['привет', 'пока']]
|
22 |
+
tokenized = tokenizer(text, return_tensors='pt')
|
23 |
+
|
24 |
+
logits = model(**tokenized).logits
|
25 |
+
output = sigmoid_fn(logits.flatten())
|
26 |
+
|
27 |
+
print(output)
|
28 |
+
```
|
29 |
+
|
30 |
+
## Пример 2
|
31 |
+
```python
|
32 |
+
from sentence_transformers.cross_encoder import CrossEncoder
|
33 |
+
|
34 |
+
model = CrossEncoder("PitKoro/cross-encoder-ru-msmarco-passage")
|
35 |
+
text = [['привет', 'привет'],['привет', 'пока']]
|
36 |
+
|
37 |
+
output = model.predict(text)
|
38 |
+
|
39 |
+
print(output)
|
40 |
+
```
|