huggingface 模型的操作系统错误

问题描述 投票:0回答:3

我正在尝试使用拥抱模型(CamelBERT),但在加载分词器时出现错误: 代码:

from transformers import AutoTokenizer, AutoModelForMaskedLM
tokenizer = AutoTokenizer.from_pretrained("CAMeL-Lab/bert-base-arabic-camelbert-ca")
model = AutoModelForMaskedLM.from_pretrained("CAMeL-Lab/bert-base-arabic-camelbert-ca")

错误:

OSError: Can't load config for 'CAMeL-Lab/bert-base-arabic-camelbert-ca'. Make sure that:

- 'CAMeL-Lab/bert-base-arabic-camelbert-ca' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'CAMeL-Lab/bert-base-arabic-camelbert-ca' is the correct path to a directory containing a config.json file

由于此错误,我无法运行模型。

python deep-learning nlp huggingface-transformers bert-language-model
3个回答
6
投票

huggingface 中的 model_id 是有效的并且应该可以工作。如果您的项目中有本地文件夹

CAMeL-Lab/bert-base-arabic-camelbert-ca
,则可能会导致问题。在这种情况下,huggingface 会将其优先于在线版本,尝试加载它,如果它不是经过充分训练的模型/空文件夹,则会失败。

如果这是您的情况的问题,请避免在模型参数中使用确切的 model_id 作为 output_dir。因为如果你在模型没有完全训练好时取消并且没有手动删除它,就会导致这个问题。

如果这不是问题,这可能是一个错误,按照@dennlinger的建议更新你的变形金刚版本可能是你最好的选择。


2
投票

跑步

pip install -U huggingface_hub
解决了我的这个问题。
看来 HuggingFace hub 改变了后端的一些逻辑,所以旧客户端不再工作了。


0
投票

我也有同样的问题,可以看到如下: OSError:我们无法连接到“https://huggingface.co”来加载此文件,在缓存文件中找不到它,并且看起来 m3hrdadfi/wav2vec2-xlsr-greek-speech-emotion-recognition 不是包含名为 config.json 的文件的目录的路径。 检查您的互联网连接或了解如何在离线模式下运行该库,网址为“https://huggingface.co/docs/transformers/installation#offline-mode”。

© www.soinside.com 2019 - 2024. All rights reserved.