huggingface-cli
Manage and interact with Hugging Face Hub
TLDR
Login to Hugging Face Hub
Display the name of the logged in user
Log out
Print information about the environment
Download files from an repository and print out the path (omit filenames to download entire repository)
Upload an entire folder or a file to Hugging Face
Scan cache to see downloaded repositories and their disk usage
Delete the cache interactively
SYNOPSIS
huggingface-cli <subcommand> [ <options> ] [ <arguments> ]
Common subcommands include login, logout, whoami, env, repo, download, and cache.
PARAMETERS
login
Log in to the Hugging Face Hub. Prompts for a token or uses an environment variable.
logout
Log out from the Hugging Face Hub. Clears the local token.
whoami
Display the currently authenticated user information.
env
Show environment details relevant to Hugging Face Hub operations, including cache paths and library versions.
repo
Manage repositories on the Hugging Face Hub. Used for creating, deleting, or cloning repositories.
download
Download files from a model, dataset, or Space repository on the Hub. Supports specific patterns or full downloads.
upload
Upload files to a model, dataset, or Space repository on the Hub. Used for pushing local changes.
cache
Manage the local cache used by Hugging Face libraries. Allows clearing or listing cached files.
refresh-token
Refresh your Hugging Face authentication token.
lfs-enable-largefiles
Enable Git LFS for handling large files in local repositories, essential for models and datasets.
scan-for-patterns
Scan local repositories for common security issues like hardcoded tokens.
convert
Convert models to different formats (e.g., from `tensorflow` to `pytorch`).
DESCRIPTION
The huggingface-cli is the command-line interface tool for interacting with the Hugging Face Hub. It provides a convenient way for machine learning engineers and developers to manage models, datasets, and Spaces directly from their terminal. This includes authentication, uploading and downloading files, managing repositories, viewing environment information, and configuring local cache settings. It simplifies workflows involving large models and datasets by integrating with the underlying huggingface_hub Python library, making it an essential tool for anyone deeply involved with the Hugging Face ecosystem.
CAVEATS
Requires the Python huggingface_hub library to be installed.
Network connectivity is essential for most operations, especially login, download, and upload.
Authentication tokens should be managed securely to prevent unauthorized access to your Hub resources.
Rate limiting may apply for extensive download/upload operations.
CONFIGURATION FILES
The CLI often uses configuration stored in ~/.cache/huggingface/token or environment variables like HF_HOME and HF_TOKEN for authentication and cache location.
ENVIRONMENT VARIABLES
HF_HOME: Specifies the directory for caching models, datasets, and other Hugging Face assets.
HF_TOKEN: Directly provides the authentication token, useful for CI/CD environments.
INTERACTIVE LOGIN
The huggingface-cli login command provides an interactive prompt for entering your Hugging Face token, which is then securely stored locally.
HISTORY
The huggingface-cli tool emerged as a natural extension of the Hugging Face ecosystem, growing alongside the Hugging Face Hub itself. It provides a convenient command-line interface to the functionalities offered by the huggingface_hub Python library. Its development has focused on streamlining common developer workflows, such as authentication, model/dataset sharing, and cache management, making the Hub more accessible and integrated into developer tooling.