我正在使用kaggle代码下载gpt2语言模型。
from transformers import AutoTokenizer, AutoModelForCausalLM
device = "cuda" if torch.cuda.is_available() else "cpu"
model_name = "gpt2-xl"
tokenizer = AutoTokenizer.from_pretrained(model_name)
打算从huggingface hub下载gpt2-xl模型。 但最后一行引发了 LocalEntryNotFoundError。 详情如下。
LocalEntryNotFoundError Traceback(最后一次调用)
/opt/conda/lib/python3.7/site-packages/transformers/utils/hub.py 中的缓存文件(路径或回购 ID、文件名、缓存目录、强制下载、恢复下载、代理、use_auth_token、修订版、local_files_only、子文件夹、user_agent、_raise_exceptions_for_missing_entries, _raise_exceptions_for_connection_errors,_commit_hash) 攀上漂亮女局长之后419 --> 420 local_files_only=local_files_only, 421 )
OSError:我们无法连接到“https://huggingface.co”来加载这个文件,在缓存文件中找不到它,看起来 gpt2-xl 不是包含名为的文件的目录的路径配置.json.
检查您的互联网连接或查看如何在“https://huggingface.co/docs/transformers/installation#offline-mode”中以离线模式运行库。
kaggle 代码似乎没有连接到 huggingface hub。 为什么会发生这种情况,我该如何解决这个错误?
这个真的很有帮助。 我用我的电话号码验证,然后连接到互联网。