14

我正在关注变压器的预训练模型xlm-roberta-large-xnli示例

from transformers import pipeline
classifier = pipeline("zero-shot-classification",
                      model="joeddav/xlm-roberta-large-xnli")

我收到以下错误

ValueError: Couldn't instantiate the backend tokenizer from one of: (1) a `tokenizers` library serialization file, (2) a slow tokenizer instance to convert or (3) an equivalent slow tokenizer class to instantiate and convert. You need to have sentencepiece installed to convert a slow tokenizer to a fast one.

我正在使用变形金刚版本'4.1.1'

4

3 回答 3

24

根据 Transformers v4.0.0 releasesentencepiece已作为必需的依赖项被删除。这意味着

“依赖于 SentencePiece 库的分词器将不适用于标准转换器安装”

包括XLMRobertaTokenizer. 但是,sentencepiece可以作为额外的依赖项安装

pip install transformers[sentencepiece]

或者

pip install sentencepiece

如果您已经安装了变压器。

于 2020-12-23T22:44:30.850 回答
7

如果你在谷歌合作:

  1. 恢复出厂设置运行时。
  2. 使用以下命令升级 pip (pip install --upgrade pip)
  3. 使用以下命令安装句子 (!pip install sentencepiece)
于 2021-04-01T18:43:08.560 回答
3

以下前面的代码在 colab 笔记本中为我工作

!pip install transformers[sentencepiece]
于 2021-08-24T04:37:00.373 回答