MirrorsProxy.Download

换源/Hugging Face

Hugging Face 镜像源

Hugging Face 模型与数据集国内镜像 hf-mirror.com,HF_ENDPOINT 环境变量 + hf / hfd 下载命令,解决模型下载慢。

HuggingFace 模型 / 数据集体积大、国内直连慢;hf-mirror 提供全量镜像。gated 模型需官方申请 token,xet 下载 404 时禁用 xet 重试。

可用镜像源(3)

源地址
hf-mirror(公益)https://hf-mirror.com
官方https://huggingface.co
ModelScope(替代平台)https://modelscope.cn

换源方法

设置 endpoint 环境变量

写入 ~/.zshrc / ~/.bashrc;PowerShell 用 $env:HF_ENDPOINT = "https://hf-mirror.com"

export HF_ENDPOINT=https://hf-mirror.com

安装 / 升级 CLI 并下载模型

新版命令为 hf(旧版 huggingface-cli 仍可用)

python -m pip install -U huggingface_hub
hf download openai-community/gpt2 --local-dir gpt2

下载数据集

hf download --repo-type dataset <org>/<dataset> --local-dir ./data

hfd 脚本(aria2 多线程断点续传)

从 hf-mirror.com 获取 hfd.sh;大模型推荐

export HF_ENDPOINT=https://hf-mirror.com
./hfd.sh <org>/<model>
# 数据集加 --dataset

常见问题

xet-read-token 404 时禁用 xet;gated 模型需先在官网申请权限并带 --token

export HF_HUB_DISABLE_XET=1
hf download <org>/<model> --token hf_xxx --local-dir ./model

常见问题

下载很慢 / 断?

用 hfd(aria2 多线程断点续传)。

报 xet-read-token 404?

export HF_HUB_DISABLE_XET=1 后重试。

gated 模型 403?

官网申请权限后带 --token 下载。

使用提示

  • ·模型权重体积大,务必断点续传(hfd / aria2 / 平台自带下载器)。
  • ·gated 模型需先在官方申请权限并带 token,镜像不代申请。
  • ·下载后校验 SHA256 / 官方哈希,避免权重损坏。
  • ·国内平台(ModelScope 等)常有同步仓库,缺的再回 hf-mirror。

其他工具

← 返回换源索引