Sufy CDN - 🤗 Huggingface 镜像站

热门排行🔥

全部
模型
数据集

如何使用镜像站 🌟

本站域名 hf-cdn.sufy.com 镜像 huggingface.co 域名作为一个公益项目,致力于帮助AI开发者快速、稳定地下载模型和数据集。感谢支持!

方法一:使用命令行环境变量

非侵入式:

huggingface python 库工具链会获取环境变量 HF_ENDPOINT 值来确定下载文件所用的域名,因此可以通过设置该变量来解决。

HF_ENDPOINT=https://hf-cdn.sufy.com python your_script.py

侵入式(修改Python代码)

import os
os.environ['HF_ENDPOINT'] = 'hf-cdn.sufy.com'

方法二:使用 huggingface-cli 工具

huggingface-cli 是 Hugging Face 官方提供的命令行工具,自带完善的下载功能。

1. 安装依赖
pip install -U huggingface_hub
2. 设置环境变量

Linux 环境下执行以下命令

可将下面这一行写入 ~/.bashrc 来进行持久化,避免每次重启终端时需要重复操作。
export HF_ENDPOINT=https://hf-cdn.sufy.com

Windows Powershell 环境下执行:

可将下面环境变量加到 设置 | 系统 | 系统信息 | 高级系统设置 | 环境变量 中。
$env:HF_ENDPOINT = "https://hf-cdn.sufy.com"
3.1 下载模型
huggingface-cli download --resume-download deepseek-ai/DeepSeek-R1-Distill-Qwen-14B --local-dir Qwen-14B
3.2 下载数据集
huggingface-cli download --repo-type dataset --resume-download open-r1/OpenR1-Math-220k --local-dir OpenR1-Math-220k

可以添加 --local-dir-use-symlinks False 参数禁用文件软链接,这样下载路径下所见即所得。

方法三:使用 hfd 脚本工具

hfd 是 huggingface 下载脚本, 基于curl、wget和aria2等工具,实现稳定下载。

1. 下载 hfd 脚本
wget https://hf-cdn.sufy.com/hfd/hfd.sh
chmod a+x hfd.sh
2. 设置环境变量

Linux 系统

export HF_ENDPOINT=https://hf-cdn.sufy.com

Windows Powershell 环境

$env:HF_ENDPOINT = "https://hf-cdn.sufy.com"
3.1 下载模型
./hfd.sh deepseek-ai/DeepSeek-R1-Distill-Qwen-14B --tool aria2c -x 4
3.2 下载数据集
./hfd.sh open-r1/OpenR1-Math-220k --dataset --tool aria2c -x 4

常见问题

Q: 有些项目需要登录,如何下载?

A:部分 Gated Repo 需登录申请许可。为保障账号安全,本站不支持登录,需先前往 Hugging Face 官网登录、申请许可,在 官网这里获取 Access Token 后回镜像站用命令行下载。
部分工具下载 Gated Repo 的方法:

huggingface-cli: 添加 --token 参数
huggingface-cli download --token hf_*** --resume-download deepseek-ai/DeepSeek-R1-Distill-Qwen-14B --local-dir Qwen-14B
hfd: 添加 --hf_username--hf_token 参数
hfd deepseek-ai/DeepSeek-R1-Distill-Qwen-14B --hf_username YOUR_HF_USERNAME --hf_token hf_***
其余如 from_pretrainedwgetcurl 如何设置认证 token,详细请参考各个工具的官方文档。