4

I am trying to implement the XLNET on Google Collaboratory. But I get the following issue.

ImportError: 
XLNetTokenizer 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.

I have also tried the following steps:

!pip install -U transformers
!pip install sentencepiece

from transformers import XLNetTokenizer
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased-spiece.model')

Thank you for your help in advance.

Ashok Kumar Jayaraman
  • 2,887
  • 2
  • 32
  • 40

3 Answers3

12

After the
!pip install transformers and !pip install sentencepiece
please restart your runtime and then execute all other codes.

0

I got the same error in google colab. Restarting the runtime did it for me.

bogdantmm
  • 13
  • 3
0

Restart the runtime in colab did it for me. like the one mention aboved

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 08 '23 at 09:18