国内无 vpn 无法访问 Huggingface
使用 huggingface 镜像站:https://hf-mirror.com/
附:如何快速下载huggingface模型——全方法总结
具体操作详见上述链接
安装依赖:
pip install -U huggingface_hub
基本命令示例:
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download --resume-download --local-dir-use-symlinks False bigscience/bloom-560m --local-dir bloom-560m
# --local-dir-use-symlinks False 参数可选,因为huggingface的工具链默认会使用符号链接来存储下载的文件,导致--local-dir指定的目录中都是一些“链接文件”,真实模型则存储在~/.cache/huggingface下,如果不喜欢这个可以用 --local-dir-use-symlinks False取消这个逻辑。
import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'