Hugging Face CLI Usage
Hugging Face CLI Usage
This page describes commands for downloading models, datasets, and repository revisions after creating and configuring a Hugging Face proxy repository in Nexus Repository.
Download a Model
Use the following command to download a model repository:
hf download <REPOSITORY_ID> --local-dir <LOCAL_DIRECTORY>
Where,
<REPOSITORY_ID>- Hugging Face model identifier. The value can usenamespace/nameformat or a non-namespaced repository name.<LOCAL_DIRECTORY>— Local directory where the client stores the downloaded files.
Example:
hf download bert-base-uncased --local-dir ./bert-base-uncased
Download a Repository with Python
Use snapshot_download() to download a complete model repository:
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="<REPOSITORY_ID>",
repo_type="<REPOSITORY_TYPE>",
local_dir="<LOCAL_DIRECTORY>",
)
Where,
<REPOSITORY_ID>- Hugging Face repository identifier<REPOSITORY_TYPE>- Repository type, such asmodel<LOCAL_DIRECTORY>- Local directory where the client stores the downloaded files
Example:
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="bert-base-uncased",
repo_type="model",
local_dir="./bert-base-uncased",
)
Download a Specific Revision
Hugging Face identifies repository revisions by Git commit hash. Use the revision argument to download a specific revision:
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="<REPOSITORY_ID>",
revision="<GIT_COMMIT_HASH>",
local_dir="<LOCAL_DIRECTORY>",
)
Where,
<REPOSITORY_ID>- Hugging Face repository identifier<GIT_COMMIT_HASH>- Git commit hash for the required revision<LOCAL_DIRECTORY>- Local directory where the client stores the downloaded files
Example:
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="keras-io/deeplabv3p-resnet50",
revision="9de024eda886161906e18b30cf84d8bcd8a0664c",
local_dir="./deeplabv3p-resnet50",
)
Nexus Repository retains the Hugging Face commit hash for each cached revision and stores all files associated with that revision.
Note
Nexus Repository stores all files for each version, as it does not determine file-level changes between versions.