huggingface-hub
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHugging Face CLI (hf
) Reference Guide
hfHugging Face CLI(hf
)参考指南
hfThe command is the modern command-line interface for interacting with the Hugging Face Hub, providing tools to manage repositories, models, datasets, and Spaces.
hfIMPORTANT: Thecommand replaces the now deprecatedhfcommand.huggingface-cli
hf重要提示:命令已取代现已弃用的hf命令。huggingface-cli
Quick Start
快速开始
- Installation:
curl -LsSf https://hf.co/cli/install.sh | bash -s - Help: Use to view all available functions and real-world examples.
hf --help - Authentication: Recommended via environment variable or the
HF_TOKENflag.--token
- 安装:
curl -LsSf https://hf.co/cli/install.sh | bash -s - 帮助: 使用查看所有可用功能及实际示例。
hf --help - 身份验证: 推荐通过环境变量或
HF_TOKEN标志进行验证。--token
Core Commands
核心命令
General Operations
常规操作
- : Download files from the Hub.
hf download REPO_ID - : Upload files/folders (recommended for single-commit).
hf upload REPO_ID - : Recommended for resumable uploads of large directories.
hf upload-large-folder REPO_ID LOCAL_PATH - : Sync files between a local directory and a bucket.
hf sync - /
hf env: View environment and version details.hf version
- :从Hub下载文件。
hf download REPO_ID - :上传文件/文件夹(推荐用于单次提交)。
hf upload REPO_ID - :推荐用于大目录的可恢复上传。
hf upload-large-folder REPO_ID LOCAL_PATH - :在本地目录与存储桶之间同步文件。
hf sync - /
hf env:查看环境和版本详情。hf version
Authentication (hf auth
)
hf auth身份验证(hf auth
)
hf auth- /
login: Manage sessions using tokens from huggingface.co/settings/tokens.logout - /
list: Manage and toggle between multiple stored access tokens.switch - : Identify the currently logged-in account.
whoami
- /
login:使用huggingface.co/settings/tokens获取的令牌管理会话。logout - /
list:管理并切换多个已存储的访问令牌。switch - :查看当前登录的账户。
whoami
Repository Management (hf repos
)
hf repos仓库管理(hf repos
)
hf repos- /
create: Create or permanently remove repositories.delete - : Clone a model, dataset, or Space to a new ID.
duplicate - : Transfer a repository between namespaces.
move - /
branch: Manage Git-like references.tag - : Remove specific files using patterns.
delete-files
- /
create:创建或永久删除仓库。delete - :将模型、数据集或Space克隆到新ID。
duplicate - :在命名空间之间转移仓库。
move - /
branch:管理类Git引用。tag - :使用模式删除特定文件。
delete-files
Specialized Hub Interactions
专属Hub交互
Datasets & Models
数据集与模型
- Datasets: ,
hf datasets list, andinfo(list parquet URLs).parquet - SQL Queries: — Execute raw SQL via DuckDB against dataset parquet URLs.
hf datasets sql SQL - Models: and
hf models list.info - Papers: — View daily papers.
hf papers list
- 数据集: 、
hf datasets list和info(列出parquet URL)。parquet - SQL查询: — 通过DuckDB针对数据集parquet URL执行原生SQL。
hf datasets sql SQL - 模型: 和
hf models list。info - 论文: — 查看每日论文。
hf papers list
Discussions & Pull Requests (hf discussions
)
hf discussions讨论与拉取请求(hf discussions
)
hf discussions- Manage the lifecycle of Hub contributions: ,
list,create,info,comment,close, andreopen.rename - : View changes in a PR.
diff - : Finalize pull requests.
merge
- 管理Hub贡献的生命周期:、
list、create、info、comment、close和reopen。rename - :查看PR中的变更。
diff - :完成拉取请求。
merge
Infrastructure & Compute
基础设施与计算
- Endpoints: Deploy and manage Inference Endpoints (,
deploy,pause,resume,scale-to-zero).catalog - Jobs: Run compute tasks on HF infrastructure. Includes for running Python scripts with inline dependencies and
hf jobs uvfor resource monitoring.stats - Spaces: Manage interactive apps. Includes and
dev-modefor Python files without full restarts.hot-reload
- 端点: 部署并管理推理端点(、
deploy、pause、resume、scale-to-zero)。catalog - 任务: 在HF基础设施上运行计算任务。包括用于运行带有内联依赖的Python脚本,以及
hf jobs uv用于资源监控。stats - Spaces: 管理交互式应用。包括和
dev-mode,无需完全重启即可更新Python文件。hot-reload
Storage & Automation
存储与自动化
- Buckets: Full S3-like bucket management (,
create,cp,mv,rm).sync - Cache: Manage local storage with ,
list(remove detached revisions), andprune(checksum checks).verify - Webhooks: Automate workflows by managing Hub webhooks (,
create,watch/enable).disable - Collections: Organize Hub items into collections (,
add-item,update).list
- 存储桶: 完整的类S3存储桶管理(、
create、cp、mv、rm)。sync - 缓存: 通过、
list(移除分离的修订版本)和prune(校验和检查)管理本地存储。verify - Webhooks: 通过管理Hub Webhooks(、
create、watch/enable)实现工作流自动化。disable - 集合: 将Hub项目组织到集合中(、
add-item、update)。list
Advanced Usage & Tips
高级用法与技巧
Global Flags
全局标志
- : Produces machine-readable output for automation.
--format json - /
-q: Limits output to IDs only.--quiet
- :生成机器可读的输出以用于自动化。
--format json - /
-q:将输出限制为仅显示ID。--quiet
Extensions & Skills
扩展与技能
- Extensions: Extend CLI functionality via GitHub repositories using .
hf extensions install REPO_ID - Skills: Manage AI assistant skills with .
hf skills add
- 扩展: 使用通过GitHub仓库扩展CLI功能。
hf extensions install REPO_ID - Skills: 使用管理AI助手技能。
hf skills add