import torch from transformers import T5ForConditionalGeneration, T5Tokenizer Check…
- User
import torch from transformers import T5ForConditionalGeneration, T5Tokenizer
Check device (CPU or GPU)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
Load model and tokenizer
model = T5ForConditionalGeneration.from_pretrained("EnglishVoice/t5-base-keywords-to-headline") tokenizer = T5Tokenizer.from_pretrained("EnglishVoice/t5-base-keywords-to-headline") model = model.to(device)
List of keywords for your sentences
keywords_list = [ "access request, site number", "logs, mangate, two hours", "site number, access granted, construction" ]
Generate headlines for each set of keywords
for keywords in keywords_list: print(f"Keywords: {keywords}")
codetext = "headline: " + keywords encoding = tokenizer.encode_plus(text, return_tensors="pt") input_ids = encoding["input_ids"].to(device) attention_masks = encoding["attention_mask"].to(device) # Generate headlines using beam search beam_outputs = model.generate( input_ids=input_ids, attention_mask=attention_masks, do_sample=True, num_return_sequences=3, # Generate 3 variations per input temperature=0.95, early_stopping=True, top_k=50, top_p=0.95, ) # Print the generated headlines for i, beam_output in enumerate(beam_outputs): result = tokenizer.decode(beam_output, skip_special_tokens=True) print(f"Headline {i + 1}: {result}") print("-" * 50)how can we make this better
Error displaying widget Sentence: Thank you for calling me to see now for speaking. Can I assist you? I need access to a side, please. Glam key number? Charlie Papa 87. Charlie Papa 87. 87. Speaking to Leon. Leon, yeah. Side number? 353380. 353380. Side number three five double three eight oh three five double three eight oh, yeah, I'm going to the main listening. No, I'm saying how long? How long? Give us two hours, please. All right, you cannot make sure to close any of that. I'll do that. Thank you. All right, thank you. Bye. Bye-bye.
Keywords:
- keywords, Thank you, calling, speaking, side,
Sentence: Thanks for calling me. It was nice. Yeah. that's nice yeah you need only mangate and the DC tank are all the logs including the DP and all the news sample What are you going to do inside? What are you going to do inside? What are you going to do inside? Oh, okay. There. Yes. Yes. Yes. Yes. Yes do you be inside? Maybe two hours. Yes, it is being granted with me. You recognize it? No, thank you. Thank you so much. I love you. Okay, you too. Thank you. Bye.
- Assistant