Update README.md
Browse files
README.md
CHANGED
@@ -28,10 +28,30 @@ Use in pair with [mask filler](https://huggingface.co/IlyaGusev/sber_rut5_filler
|
|
28 |
|
29 |
#### How to use
|
30 |
|
31 |
-
Colab: [link](
|
32 |
|
33 |
```python
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
```
|
36 |
|
37 |
## Training data
|
|
|
28 |
|
29 |
#### How to use
|
30 |
|
31 |
+
Colab: [link](https://colab.research.google.com/drive/1NUSO1QGlDgD-IWXa2SpeND089eVxrCJW)
|
32 |
|
33 |
```python
|
34 |
+
import torch
|
35 |
+
from transformers import AutoTokenizer, pipeline
|
36 |
+
|
37 |
+
tagger_model_name = "IlyaGusev/rubertconv_toxic_editor"
|
38 |
+
|
39 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
40 |
+
device_num = 0 if device == "cuda" else -1
|
41 |
+
tagger_tokenizer = AutoTokenizer.from_pretrained(tagger_model_name)
|
42 |
+
tagger_pipe = pipeline(
|
43 |
+
"token-classification",
|
44 |
+
model=tagger_model_name,
|
45 |
+
tokenizer=tagger_model_name,
|
46 |
+
framework="pt",
|
47 |
+
device=device_num,
|
48 |
+
aggregation_strategy="max"
|
49 |
+
)
|
50 |
+
|
51 |
+
text = "..."
|
52 |
+
tagger_predictions = tagger_pipe([text], batch_size=1)
|
53 |
+
sample_predictions = tagger_predictions[0]
|
54 |
+
print(sample_predictions)
|
55 |
```
|
56 |
|
57 |
## Training data
|