TMN*_*TMN 4 python nlp deep-learning bert-language-model huggingface-transformers
我正在尝试使用拥抱模型(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")
Run Code Online (Sandbox Code Playgroud)
错误:
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
Run Code Online (Sandbox Code Playgroud)
由于此错误,我无法运行该模型。
Huggingface 中的 model_id 是有效的并且应该可以工作。如果您的项目中有本地文件夹,则可能会导致问题CAMeL-Lab/bert-base-arabic-camelbert-ca。在这种情况下,huggingface 会将其优先于在线版本,尝试加载它,如果它不是经过充分训练的模型/空文件夹,则会失败。
如果这是您的情况的问题,请避免在模型参数中使用确切的 model_id 作为 output_dir。因为如果您在模型尚未完全训练时取消并且没有手动删除它,就会导致此问题。
如果这不是问题,这可能是一个错误,按照 @dennlinger 的建议更新你的变形金刚版本可能是你最好的选择。