Update README.md
Browse files
README.md
CHANGED
@@ -21,29 +21,28 @@ This is the model for abstractive summarization for Russian based on [rut5-base]
|
|
21 |
|
22 |
#### How to use
|
23 |
|
24 |
-
|
25 |
-
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
26 |
|
27 |
-
|
|
|
28 |
|
29 |
model_name = "IlyaGusev/rut5-base-sum-gazeta"
|
30 |
-
tokenizer =
|
31 |
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
32 |
|
|
|
|
|
33 |
input_ids = tokenizer(
|
34 |
[article_text],
|
35 |
add_special_tokens=True,
|
36 |
padding="max_length",
|
37 |
truncation=True,
|
38 |
-
max_length=400,
|
39 |
return_tensors="pt"
|
40 |
)["input_ids"]
|
41 |
|
42 |
output_ids = model.generate(
|
43 |
input_ids=input_ids,
|
44 |
-
max_length=200,
|
45 |
no_repeat_ngram_size=3,
|
46 |
-
num_beams=5,
|
47 |
early_stopping=True
|
48 |
)[0]
|
49 |
|
|
|
21 |
|
22 |
#### How to use
|
23 |
|
24 |
+
Colab: [link](https://colab.research.google.com/drive/1re5E26ZIDUpAx1gOCZkbF3hcwjozmgG0)
|
|
|
25 |
|
26 |
+
```python
|
27 |
+
from transformers import AutoTokenizer, T5ForConditionalGeneration
|
28 |
|
29 |
model_name = "IlyaGusev/rut5-base-sum-gazeta"
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
31 |
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
32 |
|
33 |
+
article_text = ".."
|
34 |
+
|
35 |
input_ids = tokenizer(
|
36 |
[article_text],
|
37 |
add_special_tokens=True,
|
38 |
padding="max_length",
|
39 |
truncation=True,
|
|
|
40 |
return_tensors="pt"
|
41 |
)["input_ids"]
|
42 |
|
43 |
output_ids = model.generate(
|
44 |
input_ids=input_ids,
|
|
|
45 |
no_repeat_ngram_size=3,
|
|
|
46 |
early_stopping=True
|
47 |
)[0]
|
48 |
|