介绍
huggingface_hub Python 库提供了一个内置 CLI 工具:hf。通过该工具可以直接在命令行中与 Hugging Face Hub 进行交互,包括不限:
- 登录;
- 创建仓库;
- 下载文件 等。
安装
- macOS 和 Linux
curl -LsSf https://hf.co/cli/install.sh | bash- Windows
powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"安装包会同时安装全局hf-cli skill,供任何读取 ~/.agents/skills 目录的 agent 使用。使用 --exclude-skill 参数可以避免安装:
# macOS 和 Linux
curl -LsSf https://hf.co/cli/install.sh | bash -s -- --exclude-skill
# Windows
powershell -ExecutionPolicy ByPass -c "& ([scriptblock]::Create((irm https://hf.co/cli/install.ps1))) -ExcludeSkill"hf download
下载文件到指定目录
下载一个文件到指定目录
hf download JonathanColetti/Qwen3.8-27B-Uncensored-GGUF Qwen3.8-27B-Uncensored-Q5_K_M.gguf --local-dir ~/models/qwen3.8下载多个文件到指定目录:
hf download JonathanColetti/Qwen3.8-27B-Uncensored-GGUF \
Qwen3.8-27B-Uncensored-Q5_K_M.gguf \
mmproj-Qwen3.8-27B-Uncensored-F16.gguf \
--local-dir ~/models/qwen3.8