问题:在huggingface下载预训练模型权重时出现连接错误

命令行运行:

huggingface-cli download time-series-foundation-models/Lag-Llama lag-llama.ckpt --local-dir content/lag-llama

出现报错:

'huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.'

解决方法:

import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
!huggingface-cli download time-series-foundation-models/Lag-Llama lag-llama.ckpt --local-dir content/lag-llama

或者是在命令行加入

HF_ENDPOINT=https://hf-mirror.com python xxx.py
https://hf-mirrors.com