-
Notifications
You must be signed in to change notification settings - Fork 28.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pegasus for summarization ! #4918
Comments
Thanks! The model checkpoints are available actually. Check here :) |
Hope to provide a pytorch version code |
I might try the Huggingface's weight transfer code from tensorflow to pytorch in July if nobody's working on this post |
Work has started on this, but we are still a few weeks out. |
Just wanted to know when this model will be available |
We're a little behind schedule. I'd say 60% by August 1, 90% by Sept 1. |
this is awesome. |
Very cool! Can it also be evaluated with Bert-Score? |
Can't wait for this... |
Converted torch checkpoints are now available on master if you build from source. Usage: from transformers import PegasusForConditionalGeneration, PegasusTokenizer
src_text = [
""" PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow."""
]
model_name = 'google/pegasus-xsum'
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)
batch = tokenizer.prepare_seq2seq_batch(src_text, truncation=True, padding='longest').to(torch_device)
translated = model.generate(**batch)
tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
assert tgt_text[0] == "California's largest electricity provider has turned off power to tens of thousands of customers." Please make a new issue if you encounter a bug with the torch checkpoints and assign @sshleifer . Still TODO:
|
I assume these checkpoints are based on Mixed & Stochastic models, as opposed to models trained exclusively on either C4 or HugeNews? |
Yes! |
@sshleifer I am trying this code on Colab but running into below error. Can you let me know what is the issue?
|
I'm having the same issue as @chetanambi |
I think you need to install from source, it's not part of the latest release. (will be in the next release). |
for the following model: I encountered this error when running: ~/anaconda3/envs/abstractive_summarizer/lib/python3.8/site-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs) ~/projects/transformers/src/transformers/generation_utils.py in generate(self, input_ids, max_length, min_length, do_sample, early_stopping, num_beams, temperature, top_k, top_p, repetition_penalty, bad_words_ids, bos_token_id, pad_token_id, eos_token_id, length_penalty, no_repeat_ngram_size, num_return_sequences, attention_mask, decoder_start_token_id, use_cache, **model_specific_kwargs) ~/anaconda3/envs/abstractive_summarizer/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs) ~/projects/transformers/src/transformers/modeling_bart.py in forward(self, input_ids, attention_mask, output_attentions, output_hidden_states, return_dict) ~/anaconda3/envs/abstractive_summarizer/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs) ~/anaconda3/envs/abstractive_summarizer/lib/python3.8/site-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs) ~/projects/transformers/src/transformers/modeling_bart.py in forward(self, input_ids, use_cache) ~/anaconda3/envs/abstractive_summarizer/lib/python3.8/site-packages/torch/nn/modules/sparse.py in forward(self, input) ~/anaconda3/envs/abstractive_summarizer/lib/python3.8/site-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse) IndexError: index out of range in self' |
@yxyzzz can you make a new issue and follow the bug-report template. I can't reproduce based on what you've provided. Thanks! |
Could you please let me know how to do this. Thanks!! |
@chetanambi The instructions are provided here |
@sshleifer
question It is the problem with the current Thank you in advance for the info! |
master fixed by #6754 . |
(1) I confirm that (2) Is there any way to control a length of a resulting summary made by PEGASUS? I would like to generate longer summaries. |
You can (1) fine-tune PEGASUS on a customised dataset which has longer summaries (2) tune the hyper-parameter |
Be that
|
Is there a short finetuning example somewhere? |
Nothing short. Finetuning with |
I was able to run the models successfully. During the summarization I would like to run with different beam size. How can I do this? Thanks!! |
Interesting, when I ran the example in the documentation (copied below). I got the output: Whereas the assertion output was: Could someone shine a light on why this might be the case and which one is the 'correct' output? I'm certain I didn't change anything.
|
The docs are wrong, the code is right: |
@sshleifer I am trying to implement this in a machine that is not connected to internet. So, I will have to download the model (ex: reddit-tifu) and pass the location to from_pretrained. Could you please suggest what all the files I need to download. Apperciate your help.
|
You can figure that out on your machine with internet by calling from transformers import AutoTokenizer, AutoModelWithLMHead
tokenizer = AutoTokenizer.from_pretrained("google/pegasus-reddit_tifu")
model = AutoModelWithLMHead.from_pretrained("google/pegasus-reddit_tifu")
model.save_pretrained('local_pegasus')
tokenizer.save_pretrained('local_pegasus') Should contain |
Thanks @sshleifer . I was able to figure it out by looking at the implementation for |
Thanks @sshleifer for all of your efforts on this. Your & HF's work is such a big win for the NLP community, I can't thank you enough. Out of curiosity, any sense for when TF2.0 support may go live? |
🌟 New model addition
Model description
https://ai.googleblog.com/2020/06/pegasus-state-of-art-model-for.html?m=1
https://arxiv.org/abs/1912.08777
Abstract
Recent work pre-training Transformers with self-supervised objectives on large text corpora has shown great success when fine-tuned on downstream NLP tasks including text summarization. However, pre-training objectives tailored for abstractive text summarization have not been explored. Furthermore there is a lack of systematic evaluation across diverse domains. In this work, we propose pre-training large Transformer-based encoder-decoder models on massive text corpora with a new self-supervised objective. In PEGASUS, important sentences are removed/masked from an input document and are generated together as one output sequence from the remaining sentences, similar to an extractive summary. We evaluated our best PEGASUS model on 12 downstream summarization tasks spanning news, science, stories, instructions, emails, patents, and legislative bills. Experiments demonstrate it achieves state-of-the-art performance on all 12 downstream datasets measured by ROUGE scores. Our model also shows surprising performance on low-resource summarization, surpassing previous state-of-the-art results on 6 datasets with only 1000 examples. Finally we validated our results using human evaluation and show that our model summaries achieve human performance on multiple datasets.
Open source status
The text was updated successfully, but these errors were encountered: