pegasus_summarizer / README.md
tuner007's picture
Create README.md
e36f32d
|
raw
history blame
2.39 kB
---
language: en
license: apache-2.0
tags:
- pegasus
- seq2seq
- summarization
---
## Model description
[PEGASUS](https://github.com/google-research/pegasus) fine-tuned for summarization
## Model in Action ๐Ÿš€
```
import torch
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
model_name = 'tuner007/pegasus_summarizer'
torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'
tokenizer = PegasusTokenizer.from_pretrained(model_name)
model = PegasusForConditionalGeneration.from_pretrained(model_name).to(torch_device)
def get_response(input_text):
batch = tokenizer([input_text],truncation=True,padding='longest',max_length=1024, return_tensors="pt").to(torch_device)
gen_out = model.generate(**batch,max_length=128,num_beams=4, num_return_sequences=1, temperature=1.5)
output_text = tokenizer.batch_decode(gen_out, skip_special_tokens=True)
return output_text
```
#### Example:
context = """"
Actor John Abraham and a clutch of venture capital (VC) funds have invested Rs 4 crore in NOTO, the low-calorie and high-protein icecream brand said on Tuesday.The VC funds, who have invested alongside the actor in the pre-Series A round, include Titan Capital, Rockstud Capital, and WEH Ventures, an official statement said adding that some angel investors also participated.Founded by the couple Varun and Ashni Sheth in 2018, the brand will invest the money raised in geographical expansion, product development and hiring talent, the statement said."After our investment in sport, Priya (wife) and I are identifying health and fitness businesses that have growth potential as well as which align with our lifestyle, and NOTO is one such business."We see NOTO as the leading healthy ice cream in the industry with strong promoters and on-point branding," Abraham said.
"""
```
get_response(context)
```
#### Output:
Actor John Abraham and a clutch of venture capital (VC) funds have invested 4 crore in NOTO, the low-calorie and high-protein ice cream brand. The VC funds, who have invested alongside the actor in the pre-Series A round, include Titan Capital, Rockstud Capital, and WEH Ventures. NOTO was founded by Varun Sheth and Ashni Sheth in 2018.
> Created by [Arpit Rajauria](https://twitter.com/arpit_rajauria)
[![Twitter icon](https://cdn0.iconfinder.com/data/icons/shift-logotypes/32/Twitter-32.png)](https://twitter.com/arpit_rajauria)