Views
No views yet
| Input | Output |
|---|---|
| weight loss | The Last Weight Loss Plan: Lose Weight, Feel Great, and Get in Shape How to Lose Weight Without Giving Up Your Favorite Foods I Lost Weight and Finally Feel Good About My Body |
| property rental, property management | Property rental: The new way to make money We take the hassle out of property rental Is property management your new best friend? |
| diabetic diet plan | A diabetic diet plan that actually works! Lose weight, feel great, and live better with our diabetic diet plan! Diet has never been so tasty: Our diabetic diet plan puts you to the test! |
1import torch
2from transformers import T5ForConditionalGeneration,T5Tokenizer
3
4device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5
6model = T5ForConditionalGeneration.from_pretrained("EnglishVoice/t5-base-keywords-to-headline")
7tokenizer = T5Tokenizer.from_pretrained("EnglishVoice/t5-base-keywords-to-headline")
8model = model.to(device)
9
10keywords = "weight loss, weight pills"
11
12text = "headline: " + keywords
13encoding = tokenizer.encode_plus(text, return_tensors = "pt")
14input_ids = encoding["input_ids"].to(device)
15attention_masks = encoding["attention_mask"].to(device)
16beam_outputs = model.generate(
17 input_ids = input_ids,
18 attention_mask = attention_masks,
19 do_sample = True,
20 num_return_sequences = 5,
21 temperature = 0.95,
22 early_stopping = True,
23 top_k = 50,
24 top_p = 0.95,
25)
26
27for i in range(len(beam_outputs)):
28 result = tokenizer.decode(beam_outputs[i], skip_special_tokens=True)
29 print(result)I Am Losing Weight and I Love It!
New Weight Loss Pill Helps You Get the Body You Want!
I Lost Weight By Taking Pills!
The Truth About Weight Loss Pills!
The Best Weight Loss Pills Money Can Buy!