Downloads · 30 days
13
1% of all-time downloads
AlekseyKulnevich/Pegasus-HeaderGeneration
Pegasus-HeaderGeneration 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 header generation task
Downloads · 30 days
13
1% of all-time downloads
All-time downloads
925
Public
Repo size
4.6 GB
Likes
2
Trending 2
Click a slice to open those files.
.bin2.3 GB · 100%
From the Hugging Face model README
Usage HuggingFace Transformers for header generation task
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained("AlekseyKulnevich/Pegasus-HeaderGeneration")
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']
headers = model.generate(input_ids=input_ids,
attention_mask=input_mask,
num_beams=32,
no_repeat_ngram_size=2,
early_stopping=True,
num_return_sequences=10)
headers = tokenizer.batch_decode(headers, skip_special_tokens=True)
Decoder configuration examples:
Input text you can see here
headers = model.generate(input_ids=input_ids,
attention_mask=input_mask,
num_beams=32,
no_repeat_ngram_size=2,
early_stopping=True,
num_return_sequences=20)
tokenizer.batch_decode(headers, skip_special_tokens=True)
output: