快速下载 huggingface 模型的两种方法。推荐第二种。
git配置代理
git config配置代理语法
1 | git config --global http.proxy http://<proxy_user>:<proxy_password>@<proxy_host>:<proxy_port> |
比如
1 | git config --global http.proxy socks5://127.0.0.1:7899 |
下载完之后在取消代理
1 | git config --global --unset http.proxy |
代理网站
使用 huggingface-cli + https://hf-mirror.com/ 方案。
首先安装huggingface-cli
1 | pip install -U huggingface_hub |
配置环境变量
Windows在 Powershell中配置
1 | $env:HF_ENDPOINT = "https://hf-mirror.com" |
下载模型
- 不需要授权
1 | huggingface-cli download --resume-download moka-ai/m3e-base --local-dir m3e-base |
- 需要授权
在 https://huggingface.co/settings/tokens 生成token (只读即可)
配置token下载
1 | huggingface-cli download --token hf_xxx --resume-download maidalun1020/bce-embedding-base_v1 --local-dir bce-embedding-base_v1 |