【问题标题】:Transformers v4.x: Convert slow tokenizer to fast tokenizerTransformers v4.x:将慢分词器转换为快分词器
【发布时间】:2021-04-02 12:32:57
【问题描述】:

我正在关注转换器的预训练模型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'

【问题讨论】:

    标签: python nlp huggingface-transformers huggingface-tokenizers


    【解决方案1】:

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

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

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

    pip install transformers[sentencepiece]
    

    pip install sentencepiece
    

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

    【讨论】:

    • pip install 语句然后内核/运行时重启解决了这个问题。
    【解决方案2】:

    如果你在谷歌合作中:

    1. 将运行时恢复出厂设置。
    2. 使用以下命令升级 pip (pip install --upgrade pip)
    3. 使用以下命令安装句子 (!pip install sentencepiece)

    【讨论】:

      【解决方案3】:

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

      !pip install transformers[sentencepiece]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-24
        • 2021-12-15
        • 1970-01-01
        • 2020-06-11
        相关资源
        最近更新 更多