【问题标题】:Getting started: Huggingface Model Cards入门:Huggingface 模型卡
【发布时间】:2020-10-07 13:43:10
【问题描述】:

我最近才开始研究 huggingface 转换器库。 当我尝试开始使用模型卡代码时,例如community model

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")
model = AutoModel.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")

但是,我收到以下错误:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    tokenizer = AutoTokenizer.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")
  File "/Users/Lukas/miniconda3/envs/nlp/lib/python3.7/site-packages/transformers/tokenization_auto.py", line 124, in from_pretrained
    "'xlm', 'roberta', 'ctrl'".format(pretrained_model_name_or_path))
ValueError: Unrecognized model identifier in emilyalsentzer/Bio_ClinicalBERT. Should contains one of 'bert', 'openai-gpt', 'gpt2', 'transfo-xl', 'xlnet', 'xlm', 'roberta', 'ctrl'

如果我尝试使用不同的标记器,例如“baykenney/bert-base-gpt2detector-topp92”,我会收到以下错误:

OSError: Model name 'baykenney/bert-base-gpt2detector-topp92' was not found in tokenizers model name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese, bert-base-german-cased, bert-large-uncased-whole-word-masking, bert-large-cased-whole-word-masking, bert-large-uncased-whole-word-masking-finetuned-squad, bert-large-cased-whole-word-masking-finetuned-squad, bert-base-cased-finetuned-mrpc, bert-base-german-dbmdz-cased, bert-base-german-dbmdz-uncased). We assumed 'baykenney/bert-base-gpt2detector-topp92' was a path or url to a directory containing vocabulary files named ['vocab.txt'] but couldn't find such vocabulary files at this path or url.

我错过了什么开始了吗?我觉得模型卡片表明这三行代码应该足够上手了。

我正在使用 Python 3.7 以及转换器库版本 2.1.1 和 pytorch 1.5。

【问题讨论】:

    标签: python pytorch huggingface-transformers huggingface-tokenizers


    【解决方案1】:

    请将您的转换器库更新到至少 2.4.0。您应该创建一个新的 conda 环境,并使用 pip 直接从 pypi 安装所有软件包以获取最新版本(当前为 2.11.0)。

    【讨论】:

    • 感谢您的帮助。我使用 conda 安装了转换器库,目前可用的版本似乎已经过时了。
    猜你喜欢
    • 2015-08-04
    • 2013-06-06
    • 2021-11-14
    • 2021-12-08
    • 2020-12-15
    • 2023-01-28
    • 2021-12-18
    • 2021-08-29
    • 2021-11-08
    相关资源
    最近更新 更多