Views
No views yet
1from transformers import AutoTokenizer, T5ForConditionalGeneration
2
3model_name = "mlenjoyneer/rut5_large_sum_gazeta"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = T5ForConditionalGeneration.from_pretrained(model_name)
6
7article_text = "..."
8
9input_ids = tokenizer(
10 [article_text],
11 max_length=600,
12 add_special_tokens=True,
13 padding="max_length",
14 truncation=True,
15 return_tensors="pt"
16)["input_ids"]
17
18output_ids = model.generate(
19 input_ids=input_ids,
20 no_repeat_ngram_size=4
21)[0]
22
23summary = tokenizer.decode(output_ids, skip_special_tokens=True)
24print(summary)| Model | R-1-f | R-2-f | R-L-f | chrF | BLEU | Avg char length |
|---|---|---|---|---|---|---|
| IlyaGusev/mbart_ru_sum_gazeta | 28.7 | 11.1 | 24.4 | 37.3 | 9.4 | 373 |
| IlyaGusev/rut5_base_sum_gazeta | 28.6 | 11.1 | 24.5 | 37.2 | 9.4 | 331 |
| IlyaGusev/rugpt3medium_sum_gazeta | 24.1 | 6.5 | 19.8 | 32.1 | 3.6 | 242 |
| rut5-large_sum_gazeta | 29.6 | 11.7 | 25.2 | 37.3 | 9.4 | 304 |