The model was trained on forum topics names and first posts (100 - 150 words). It generates short headlines (3 - 5 words) in the opposite to headlines from models trained on newspaper articles.
"I do not know how to title this post" can be a valid headline.
"What would you do in my place?" is one of the most popular headline.
1from transformers import AutoTokenizer, T5ForConditionalGeneration
2
3model_name = "Kateryna/eva_ru_forum_headlines"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = T5ForConditionalGeneration.from_pretrained(model_name)
6
7text = "Я влюбилась в одного парня. Каждый раз, когда он меня видит, он плюется и переходит на другую сторону улицы. Как вы думаете, он меня любит?"
8
9input_ids = tokenizer(
10 [text],
11 max_length=150,
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 max_length=25,
21 num_beams=4,
22 repetition_penalty=5.0,
23 no_repeat_ngram_size=4
24)[0]
25
26headline = tokenizer.decode(output_ids, skip_special_tokens=True)
27
28print(headline)
From all available posts and topics names I selected only posts and abstractive topic names e.g. the topic name does not match exactly anything in the correspondent post.
ROUGE and BLUE scores were not very helpful to choose a best model.
I manually estimated ~100 results in each candidate model.