Pegasus Tokenizer Error

While working with pegasus(using hugging face tranformer implimentation) I got this error… also tried to install sentencepiece library using pip… still showing the same error can anyone help? this is my code

model_name = ‘google/pegasus-aeslc’#'google/pegasus-xsum’
torch_device = ‘cuda’ if torch.cuda.is_available() else 'cpu’
tokenizer1 = PegasusTokenizer.from_pretrained(model_name)
model = PegasusForConditionalGeneration.from_pretrained(model_name).to(torch_device)

Error:
PegasusTokenizer requires the SentencePiece library but it was not found in your environment. Checkout the instructions on the
installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones
that match your environment.

You are not showing the error, but I am having the same problem with the SentencePiece library and PegasusTokenizer.

If you have same error as mine then

use
!pip install Transformers==3.2.0 instead of !pip install Transformers

1 Like

Opening an issue on GitHub
#8963

Restarting the kernel and using
!pip install Transformers==3.2.0 instead of !pip install Transformers, worked for me

Use:

!pip install transformers==3.2.0
!pip install transformers[sentencepiece]
!pip install sentencepiece

Make sure to restart your runtime before running again