XLNetTokenizer 需要 SentencePiece 库,但在您的环境中找不到

Ash*_*man 2 transformer-model google-colaboratory huggingface-transformers huggingface-tokenizers

我正在尝试在 Google Collaboratory 上实施 XL​​NET。但我得到以下问题。

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.
Run Code Online (Sandbox Code Playgroud)

我还尝试了以下步骤:

!pip install -U transformers
!pip install sentencepiece

from transformers import XLNetTokenizer
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased-spiece.model')
Run Code Online (Sandbox Code Playgroud)

提前谢谢你的帮助。

Ano*_*ram 5


!pip install tr​​ansformers 和 !pip install sentencepiece 之后,
请重新启动您的运行时,然后执行所有其他代码。