Downloads · 30 days
13
1% of all-time downloads
AlekseyKulnevich/Pegasus-Summarization
Pegasus-Summarization is a machine learning model from AlekseyKulnevich. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
Usage HuggingFace Transformers for summarization task
Downloads · 30 days
13
1% of all-time downloads
All-time downloads
2.5K
Public
Repo size
6.9 GB
Likes
4
Public
Click a slice to open those files.
.bin2.3 GB · 100%
From the Hugging Face model README
Usage HuggingFace Transformers for summarization task
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained("AlekseyKulnevich/Pegasus-Summarization")
tokenizer = PegasusTokenizer.from_pretrained('google/pegasus-large')
input_text # your text
input_ = tokenizer.batch_encode_plus([input_text], max_length=1024, pad_to_max_length=True,
truncation=True, padding='longest', return_tensors='pt')
input_ids = input_['input_ids']
input_mask = input_['attention_mask']
summary = model.generate(input_ids=input_ids,
attention_mask=input_mask,
num_beams=32,
min_length=100,
no_repeat_ngram_size=2,
early_stopping=True,
num_return_sequences=10)
questions = tokenizer.batch_decode(summary, skip_special_tokens=True)
Decoder configuration examples:
Input text you can see here
summary = model.generate(input_ids=input_ids,
attention_mask=input_mask,
num_beams=32,
min_length=100,
no_repeat_ngram_size=2,
early_stopping=True,
num_return_sequences=1)
tokenizer.batch_decode(summary, skip_special_tokens=True)
output:
summary = model.generate(input_ids=input_ids,
attention_mask=input_mask,
top_k=30,
no_repeat_ngram_size=2,
early_stopping=True,
min_length=100,
num_return_sequences=1)
tokenizer.batch_decode(summary, skip_special_tokens=True)
output:
Also you can play with the following parameters in generate method:
-top_k
-top_p
Meaning of parameters to generate text you can see here