Views
No views yet

pip install transformers1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3tokenizer = AutoTokenizer.from_pretrained("Mr-Vicky-01/Bart-Finetuned-conversational-summarization")
4model = AutoModelForSeq2SeqLM.from_pretrained("Mr-Vicky-01/Bart-Finetuned-conversational-summarization")
5
6def generate_summary(text):
7 inputs = tokenizer([text], max_length=1024, return_tensors='pt', truncation=True)
8 summary_ids = model.generate(inputs['input_ids'], max_new_tokens=100, do_sample=False)
9 summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
10 return summary
11
12text_to_summarize = """Now, there is no doubt that one of the most important aspects of any Pixel phone is its camera.
13And there might be good news for all camera lovers. Rumours have suggested that the Pixel 9 could come with a telephoto lens,
14improving its photography capabilities even further. Google will likely continue to focus on using AI to enhance its camera performance,
15in order to make sure that Pixel phones remain top contenders in the world of mobile photography."""
16summary = generate_summary(text_to_summarize)
17
18print(summary)Google is rumoured to be about to unveil its next-generation Pixel smartphone,
the Google Pixel 9,which is expected to come with a telephoto lens and an artificial intelligence (AI)
system to improve its camera capabilities, as well as improve the quality of its images.1num_train_epochs=1,
2warmup_steps = 500,
3per_device_train_batch_size=4,
4per_device_eval_batch_size=4,
5weight_decay = 0.01,
6gradient_accumulation_steps=16