cointegrated
commited on
Commit
•
1296e93
1
Parent(s):
2431f32
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: "ru"
|
3 |
+
tags:
|
4 |
+
- normalization
|
5 |
+
- denoising autoencoder
|
6 |
+
- russian
|
7 |
+
license: mit
|
8 |
+
---
|
9 |
+
This is a small Russian denoising autoencoder. It can be used for restoring corrupted sentences.
|
10 |
+
|
11 |
+
This model was produced by fine-tuning the [rut5-small](https://huggingface.co/cointegrated/rut5-small) model on the task of reconstructing a sentence:
|
12 |
+
* restoring word positions (after slightly shuffling them)
|
13 |
+
* restoring dropped words and punctuation marks (after dropping some of them randomly)
|
14 |
+
* restoring inflection of words (after changing their inflection randomly using [natasha](https://github.com/natasha/natasha) and [pymorphy2](https://github.com/kmike/pymorphy2) packages)
|
15 |
+
|
16 |
+
The fine-tuning was performed on a [Leipzig web corpus](https://wortschatz.uni-leipzig.de/en/download/Russian) of Russian sentences.
|
17 |
+
|
18 |
+
The model can be applied as follows:
|
19 |
+
```
|
20 |
+
# !pip install transformers sentencepiece
|
21 |
+
import torch
|
22 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
23 |
+
tokenizer = T5Tokenizer.from_pretrained("cointegrated/rut5-small-normalizer")
|
24 |
+
model = T5ForConditionalGeneration.from_pretrained("cointegrated/rut5-small-normalizer")
|
25 |
+
|
26 |
+
text = 'меня тобой не понимать'
|
27 |
+
inputs = tokenizer(text, return_tensors='pt')
|
28 |
+
with torch.no_grad():
|
29 |
+
hypotheses = model.generate(
|
30 |
+
**inputs,
|
31 |
+
do_sample=True, top_p=0.95,
|
32 |
+
num_return_sequences=5,
|
33 |
+
repetition_penalty=2.5,
|
34 |
+
max_length=32,
|
35 |
+
)
|
36 |
+
for h in hypotheses:
|
37 |
+
print(tokenizer.decode(h, skip_special_tokens=True))
|
38 |
+
```
|
39 |
+
A possible output is:
|
40 |
+
```
|
41 |
+
# Мне тебя не понимать.
|
42 |
+
# Если бы ты понимаешь меня?
|
43 |
+
# Я с тобой не понимаю.
|
44 |
+
# Я тебя не понимаю.
|
45 |
+
# Я не понимаю о чем ты.
|
46 |
+
```
|