hf-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Install:
curl -LsSf https://hf.co/cli/install.sh | bash -s
.
The Hugging Face Hub CLI tool
hf
is available. IMPORTANT: The
hf
command replaces the deprecated
huggingface-cli
command.
Use
hf --help
to view available functions. Note that auth commands are now all under
hf auth
e.g.
hf auth whoami
.
Generated with
huggingface_hub v1.6.0
. Run
hf skills add --force
to regenerate.
安装命令:
curl -LsSf https://hf.co/cli/install.sh | bash -s
Hugging Face Hub CLI工具
hf
现已可用。重要提示:
hf
命令替代了已弃用的
huggingface-cli
命令。
使用
hf --help
查看可用功能。请注意,身份验证相关命令现已全部归类到
hf auth
下,例如
hf auth whoami
huggingface_hub v1.6.0
生成。运行
hf skills add --force
可重新生成。

Commands

命令

  • hf download REPO_ID
    — Download files from the Hub.
  • hf env
    — Print information about the environment.
  • hf sync
    — Sync files between local directory and a bucket.
  • hf upload REPO_ID
    — Upload a file or a folder to the Hub. Recommended for single-commit uploads.
  • hf upload-large-folder REPO_ID LOCAL_PATH
    — Upload a large folder to the Hub. Recommended for resumable uploads.
  • hf version
    — Print information about the hf version.
  • hf download REPO_ID
    — 从Hub下载文件。
  • hf env
    — 打印环境相关信息。
  • hf sync
    — 同步本地目录与存储桶之间的文件。
  • hf upload REPO_ID
    — 上传单个文件或文件夹到Hub,推荐用于单次提交上传场景。
  • hf upload-large-folder REPO_ID LOCAL_PATH
    — 上传大文件夹到Hub,推荐用于支持断点续传的上传场景。
  • hf version
    — 打印hf版本相关信息。

hf auth
— Manage authentication (login, logout, etc.).

hf auth
— 管理身份验证(登录、登出等)。

  • hf auth list
    — List all stored access tokens.
  • hf auth login
    — Login using a token from huggingface.co/settings/tokens.
  • hf auth logout
    — Logout from a specific token.
  • hf auth switch
    — Switch between access tokens.
  • hf auth whoami
    — Find out which huggingface.co account you are logged in as.
  • hf auth list
    — 列出所有已存储的访问令牌。
  • hf auth login
    — 使用huggingface.co/settings/tokens中生成的令牌登录。
  • hf auth logout
    — 登出指定令牌对应的账号。
  • hf auth switch
    — 在多个访问令牌之间切换。
  • hf auth whoami
    — 查看当前登录的huggingface.co账号信息。

hf buckets
— Commands to interact with buckets.

hf buckets
— 与存储桶交互的相关命令。

  • hf buckets cp SRC
    — Copy a single file to or from a bucket.
  • hf buckets create BUCKET_ID
    — Create a new bucket.
  • hf buckets delete BUCKET_ID
    — Delete a bucket.
  • hf buckets info BUCKET_ID
    — Get info about a bucket.
  • hf buckets list
    — List buckets or files in a bucket.
  • hf buckets move FROM_ID TO_ID
    — Move (rename) a bucket to a new name or namespace.
  • hf buckets remove ARGUMENT
    — Remove files from a bucket.
  • hf buckets sync
    — Sync files between local directory and a bucket.
  • hf buckets cp SRC
    — 向存储桶复制文件或从存储桶复制单个文件。
  • hf buckets create BUCKET_ID
    — 创建新的存储桶。
  • hf buckets delete BUCKET_ID
    — 删除存储桶。
  • hf buckets info BUCKET_ID
    — 获取存储桶的相关信息。
  • hf buckets list
    — 列出存储桶或存储桶中的文件。
  • hf buckets move FROM_ID TO_ID
    — 移动(重命名)存储桶到新名称或命名空间。
  • hf buckets remove ARGUMENT
    — 从存储桶中删除文件。
  • hf buckets sync
    — 同步本地目录与存储桶之间的文件。

hf cache
— Manage local cache directory.

hf cache
— 管理本地缓存目录。

  • hf cache ls
    — List cached repositories or revisions.
  • hf cache prune
    — Remove detached revisions from the cache.
  • hf cache rm TARGETS
    — Remove cached repositories or revisions.
  • hf cache verify REPO_ID
    — Verify checksums for a single repo revision from cache or a local directory.
  • hf cache ls
    — 列出已缓存的仓库或版本。
  • hf cache prune
    — 从缓存中移除无关联的版本。
  • hf cache rm TARGETS
    — 移除已缓存的仓库或版本。
  • hf cache verify REPO_ID
    — 验证缓存或本地目录中单个仓库版本的校验和。

hf collections
— Interact with collections on the Hub.

hf collections
— 与Hub上的收藏集交互。

  • hf collections add-item COLLECTION_SLUG ITEM_ID ITEM_TYPE
    — Add an item to a collection.
  • hf collections create TITLE
    — Create a new collection on the Hub.
  • hf collections delete COLLECTION_SLUG
    — Delete a collection from the Hub.
  • hf collections delete-item COLLECTION_SLUG ITEM_OBJECT_ID
    — Delete an item from a collection.
  • hf collections info COLLECTION_SLUG
    — Get info about a collection on the Hub.
  • hf collections ls
    — List collections on the Hub.
  • hf collections update COLLECTION_SLUG
    — Update a collection's metadata on the Hub.
  • hf collections update-item COLLECTION_SLUG ITEM_OBJECT_ID
    — Update an item in a collection.
  • hf collections add-item COLLECTION_SLUG ITEM_ID ITEM_TYPE
    — 向收藏集添加条目。
  • hf collections create TITLE
    — 在Hub上创建新的收藏集。
  • hf collections delete COLLECTION_SLUG
    — 从Hub删除收藏集。
  • hf collections delete-item COLLECTION_SLUG ITEM_OBJECT_ID
    — 从收藏集删除条目。
  • hf collections info COLLECTION_SLUG
    — 获取Hub上某收藏集的相关信息。
  • hf collections ls
    — 列出Hub上的收藏集。
  • hf collections update COLLECTION_SLUG
    — 更新Hub上收藏集的元数据。
  • hf collections update-item COLLECTION_SLUG ITEM_OBJECT_ID
    — 更新收藏集中的条目。

hf datasets
— Interact with datasets on the Hub.

hf datasets
— 与Hub上的数据集交互。

  • hf datasets info DATASET_ID
    — Get info about a dataset on the Hub.
  • hf datasets ls
    — List datasets on the Hub.
  • hf datasets parquet DATASET_ID
    — List parquet file URLs available for a dataset.
  • hf datasets sql SQL
    — Execute a raw SQL query with DuckDB against dataset parquet URLs.
  • hf datasets info DATASET_ID
    — 获取Hub上某数据集的相关信息。
  • hf datasets ls
    — 列出Hub上的数据集。
  • hf datasets parquet DATASET_ID
    — 列出数据集可用的parquet文件URL。
  • hf datasets sql SQL
    — 基于数据集的parquet文件URL,通过DuckDB执行原生SQL查询。

hf discussions
— Manage discussions and pull requests on the Hub.

hf discussions
— 管理Hub上的讨论和拉取请求。

  • hf discussions close REPO_ID NUM
    — Close a discussion or pull request.
  • hf discussions comment REPO_ID NUM
    — Comment on a discussion or pull request.
  • hf discussions create REPO_ID title
    — Create a new discussion or pull request on a repo.
  • hf discussions diff REPO_ID NUM
    — Show the diff of a pull request.
  • hf discussions info REPO_ID NUM
    — Get info about a discussion or pull request.
  • hf discussions list REPO_ID
    — List discussions and pull requests on a repo.
  • hf discussions merge REPO_ID NUM
    — Merge a pull request.
  • hf discussions rename REPO_ID NUM NEW_TITLE
    — Rename a discussion or pull request.
  • hf discussions reopen REPO_ID NUM
    — Reopen a closed discussion or pull request.
  • hf discussions close REPO_ID NUM
    — 关闭讨论或拉取请求。
  • hf discussions comment REPO_ID NUM
    — 在讨论或拉取请求下评论。
  • hf discussions create REPO_ID title
    — 在仓库下创建新的讨论或拉取请求。
  • hf discussions diff REPO_ID NUM
    — 展示拉取请求的差异。
  • hf discussions info REPO_ID NUM
    — 获取讨论或拉取请求的相关信息。
  • hf discussions list REPO_ID
    — 列出仓库下的讨论和拉取请求。
  • hf discussions merge REPO_ID NUM
    — 合并拉取请求。
  • hf discussions rename REPO_ID NUM NEW_TITLE
    — 重命名讨论或拉取请求。
  • hf discussions reopen REPO_ID NUM
    — 重新打开已关闭的讨论或拉取请求。

hf endpoints
— Manage Hugging Face Inference Endpoints.

hf endpoints
— 管理Hugging Face Inference Endpoints。

  • hf endpoints catalog
    — Interact with the Inference Endpoints catalog.
  • hf endpoints delete NAME
    — Delete an Inference Endpoint permanently.
  • hf endpoints deploy NAME repo framework accelerator instance_size instance_type region vendor
    — Deploy an Inference Endpoint from a Hub repository.
  • hf endpoints describe NAME
    — Get information about an existing endpoint.
  • hf endpoints ls
    — Lists all Inference Endpoints for the given namespace.
  • hf endpoints pause NAME
    — Pause an Inference Endpoint.
  • hf endpoints resume NAME
    — Resume an Inference Endpoint.
  • hf endpoints scale-to-zero NAME
    — Scale an Inference Endpoint to zero.
  • hf endpoints update NAME
    — Update an existing endpoint.
  • hf endpoints catalog
    — 与推理端点目录交互。
  • hf endpoints delete NAME
    — 永久删除推理端点。
  • hf endpoints deploy NAME repo framework accelerator instance_size instance_type region vendor
    — 从Hub仓库部署推理端点。
  • hf endpoints describe NAME
    — 获取现有端点的相关信息。
  • hf endpoints ls
    — 列出指定命名空间下的所有推理端点。
  • hf endpoints pause NAME
    — 暂停推理端点。
  • hf endpoints resume NAME
    — 恢复推理端点。
  • hf endpoints scale-to-zero NAME
    — 将推理端点缩容到0实例。
  • hf endpoints update NAME
    — 更新现有端点。

hf extensions
— Manage hf CLI extensions.

hf extensions
— 管理hf CLI扩展。

  • hf extensions exec NAME
    — Execute an installed extension.
  • hf extensions install REPO_ID
    — Install an extension from a public GitHub repository.
  • hf extensions list
    — List installed extension commands.
  • hf extensions remove NAME
    — Remove an installed extension.
  • hf extensions exec NAME
    — 执行已安装的扩展。
  • hf extensions install REPO_ID
    — 从公开GitHub仓库安装扩展。
  • hf extensions list
    — 列出已安装的扩展命令。
  • hf extensions remove NAME
    — 移除已安装的扩展。

hf jobs
— Run and manage Jobs on the Hub.

hf jobs
— 运行和管理Hub上的任务。

  • hf jobs cancel JOB_ID
    — Cancel a Job
  • hf jobs hardware
    — List available hardware options for Jobs
  • hf jobs inspect JOB_IDS
    — Display detailed information on one or more Jobs
  • hf jobs logs JOB_ID
    — Fetch the logs of a Job.
  • hf jobs ps
    — List Jobs.
  • hf jobs run IMAGE COMMAND
    — Run a Job.
  • hf jobs scheduled
    — Create and manage scheduled Jobs on the Hub.
  • hf jobs stats
    — Fetch the resource usage statistics and metrics of Jobs
  • hf jobs uv
    — Run UV scripts (Python with inline dependencies) on HF infrastructure.
  • hf jobs cancel JOB_ID
    — 取消任务
  • hf jobs hardware
    — 列出任务可用的硬件选项
  • hf jobs inspect JOB_IDS
    — 展示一个或多个任务的详细信息
  • hf jobs logs JOB_ID
    — 获取任务的日志。
  • hf jobs ps
    — 列出任务。
  • hf jobs run IMAGE COMMAND
    — 运行任务。
  • hf jobs scheduled
    — 创建和管理Hub上的定时任务。
  • hf jobs stats
    — 获取任务的资源使用统计数据和指标
  • hf jobs uv
    — 在HF基础设施上运行UV脚本(带内联依赖的Python)。

hf models
— Interact with models on the Hub.

hf models
— 与Hub上的模型交互。

  • hf models info MODEL_ID
    — Get info about a model on the Hub.
  • hf models ls
    — List models on the Hub.
  • hf models info MODEL_ID
    — 获取Hub上某模型的相关信息。
  • hf models ls
    — 列出Hub上的模型。

hf papers
— Interact with papers on the Hub.

hf papers
— 与Hub上的论文交互。

  • hf papers ls
    — List daily papers on the Hub.
  • hf papers ls
    — 列出Hub上的每日论文。

hf repos
— Manage repos on the Hub.

hf repos
— 管理Hub上的仓库。

  • hf repos branch
    — Manage branches for a repo on the Hub.
  • hf repos create REPO_ID
    — Create a new repo on the Hub.
  • hf repos delete REPO_ID
    — Delete a repo from the Hub. This is an irreversible operation.
  • hf repos delete-files REPO_ID PATTERNS
    — Delete files from a repo on the Hub.
  • hf repos duplicate FROM_ID
    — Duplicate a repo on the Hub (model, dataset, or Space).
  • hf repos move FROM_ID TO_ID
    — Move a repository from a namespace to another namespace.
  • hf repos settings REPO_ID
    — Update the settings of a repository.
  • hf repos tag
    — Manage tags for a repo on the Hub.
  • hf repos branch
    — 管理Hub上仓库的分支。
  • hf repos create REPO_ID
    — 在Hub上创建新仓库。
  • hf repos delete REPO_ID
    — 从Hub删除仓库,该操作不可撤销。
  • hf repos delete-files REPO_ID PATTERNS
    — 从Hub上的仓库删除文件。
  • hf repos duplicate FROM_ID
    — 复制Hub上的仓库(模型、数据集或Space)。
  • hf repos move FROM_ID TO_ID
    — 将仓库从一个命名空间移动到另一个命名空间。
  • hf repos settings REPO_ID
    — 更新仓库的设置。
  • hf repos tag
    — 管理Hub上仓库的标签。

hf skills
— Manage skills for AI assistants.

hf skills
— 管理AI助手的技能。

  • hf skills add
    — Download a skill and install it for an AI assistant.
  • hf skills preview
    — Print the generated SKILL.md to stdout.
  • hf skills add
    — 下载技能并为AI助手安装。
  • hf skills preview
    — 将生成的SKILL.md打印到标准输出。

hf spaces
— Interact with spaces on the Hub.

hf spaces
— 与Hub上的Spaces交互。

  • hf spaces dev-mode SPACE_ID
    — Enable or disable dev mode on a Space.
  • hf spaces hot-reload SPACE_ID
    — Hot-reload any Python file of a Space without a full rebuild + restart.
  • hf spaces info SPACE_ID
    — Get info about a space on the Hub.
  • hf spaces ls
    — List spaces on the Hub.
  • hf spaces dev-mode SPACE_ID
    — 开启或关闭Space的开发者模式。
  • hf spaces hot-reload SPACE_ID
    — 热重载Space的任意Python文件,无需完整重建+重启。
  • hf spaces info SPACE_ID
    — 获取Hub上某Space的相关信息。
  • hf spaces ls
    — 列出Hub上的Spaces。

hf webhooks
— Manage webhooks on the Hub.

hf webhooks
— 管理Hub上的webhooks。

  • hf webhooks create watch
    — Create a new webhook.
  • hf webhooks delete WEBHOOK_ID
    — Delete a webhook permanently.
  • hf webhooks disable WEBHOOK_ID
    — Disable an active webhook.
  • hf webhooks enable WEBHOOK_ID
    — Enable a disabled webhook.
  • hf webhooks info WEBHOOK_ID
    — Show full details for a single webhook as JSON.
  • hf webhooks list
    — List all webhooks for the current user.
  • hf webhooks update WEBHOOK_ID
    — Update an existing webhook. Only provided options are changed.
  • hf webhooks create watch
    — 创建新的webhook。
  • hf webhooks delete WEBHOOK_ID
    — 永久删除webhook。
  • hf webhooks disable WEBHOOK_ID
    — 禁用活跃的webhook。
  • hf webhooks enable WEBHOOK_ID
    — 启用已禁用的webhook。
  • hf webhooks info WEBHOOK_ID
    — 以JSON格式展示单个webhook的完整详情。
  • hf webhooks list
    — 列出当前用户的所有webhooks。
  • hf webhooks update WEBHOOK_ID
    — 更新现有webhook,仅修改指定的选项。

Tips

提示

  • Use
    hf <command> --help
    for full options, usage, and real-world examples
  • Use
    --format json
    for machine-readable output on list commands
  • Use
    -q
    /
    --quiet
    to print only IDs
  • Authenticate with
    HF_TOKEN
    env var (recommended) or with
    --token
  • 执行
    hf <command> --help
    查看完整的选项、用法和实际案例
  • 列表类命令可使用
    --format json
    获取机器可读的输出
  • 使用
    -q
    /
    --quiet
    仅打印ID
  • 推荐通过
    HF_TOKEN
    环境变量进行身份验证,也可使用
    --token
    参数