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

XLNetTokenizer requires the SentencePiece library but it was not found in your environment

我正在尝试在 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.

我也试过以下步骤:

!pip install -U transformers
!pip install sentencepiece

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

提前感谢您的帮助。


之后 !pip 安装变压器和 !pip 安装句子
请重新启动您的运行时,然后执行所有其他代码。