koziev ilya
commited on
Commit
•
702b4da
1
Parent(s):
1d118db
adding usage example
Browse files
README.md
CHANGED
@@ -4,8 +4,28 @@ license: lgpl-3.0
|
|
4 |
|
5 |
# t5_interpreter
|
6 |
|
7 |
-
A rut5-based model for incomplete utterance restoration, spellchecking and text normalization for
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
<<<...mode information coming soon...>>>
|
11 |
|
|
|
4 |
|
5 |
# t5_interpreter
|
6 |
|
7 |
+
A rut5-based model for incomplete utterance restoration, spellchecking and text normalization for dialogue utterances.
|
8 |
|
9 |
+
Read more about the task [here](https://huggingface.co/inkoziev/rugpt_interpreter).
|
10 |
+
|
11 |
+
|
12 |
+
# Usage example
|
13 |
+
|
14 |
+
```
|
15 |
+
import torch
|
16 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
17 |
+
|
18 |
+
model_name = 'inkoziev/t5_interpreter'
|
19 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name,)
|
20 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
21 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
22 |
+
model.eval()
|
23 |
+
|
24 |
+
t5_input = '- Тебя как зовут?\n- Мальвина #'
|
25 |
+
input_ids = tokenizer(t5_input, return_tensors='pt').input_ids
|
26 |
+
out_ids = model.generate(input_ids=input_ids, max_length=40, eos_token_id=tokenizer.eos_token_id, early_stopping=True)
|
27 |
+
t5_output = tokenizer.decode(out_ids[0][1:])
|
28 |
+
print(t5_output)
|
29 |
+
```
|
30 |
|
|
|
31 |
|