How to Delete a Hugging Face Model from Cache (hf CLI)

Delete Hugging Face models safely with the current hf CLI. List cached models, preview removals, delete repositories, and prune unused files.

How to Delete a Hugging Face Model from Cache (hf CLI)

If your Hugging Face cache is consuming too much disk space, remove models with the current hf command-line tool. Recent versions of huggingface_hub replaced the deprecated huggingface-cli workflow.

Quick answer: list cached models with hf cache ls, preview a removal with hf cache rm model/OWNER/MODEL --dry-run, and then run the same command without --dry-run when the target is correct.

1. Install or update the Hugging Face CLI

Install the latest huggingface_hub package so the hf command and current cache tools are available.

python -m pip install -U huggingface_hub

Confirm that the command works:

hf --help

2. Inspect the cache

List cached repositories before deleting anything:

hf cache ls

To surface the largest entries first, sort by size:

hf cache ls --sort size

If you use a non-default location, add --cache-dir PATH.

3. Preview the model removal

Use a dry run to check exactly what the command would remove. Replace OWNER/MODEL with the repository ID shown by hf cache ls.

hf cache rm model/OWNER/MODEL --dry-run

The preview reports the repository, revisions, and estimated disk space without deleting files.

4. Delete the selected cached model

After the dry-run output is correct, remove the model:

hf cache rm model/OWNER/MODEL

The CLI asks for confirmation. For an intentional automated workflow, --yes skips that prompt:

hf cache rm model/OWNER/MODEL --yes

You can also remove one revision by passing its revision hash instead of the entire repository.

5. Remove unused revisions and incomplete downloads

hf cache prune removes detached revisions and incomplete downloads. Preview it first:

hf cache prune --dry-run

Then run the cleanup when the preview is safe:

hf cache prune

What happened to huggingface-cli delete-cache?

The old huggingface-cli command was deprecated and removed in the Hugging Face Hub v1.0 migration. The current replacements are hf cache ls, hf cache rm, and hf cache prune.

Frequently asked questions

Can I delete the entire Hugging Face cache?

You can, but targeted removal is safer because the cache uses shared blobs and snapshots. Current hf cache rm understands that structure and helps avoid unnecessary redownloads.

Will deleting a cached model delete it from Hugging Face?

No. This removes only the local cached copy on your computer. The remote repository remains unchanged, and the model can be downloaded again later.

How do I check another cache directory?

Add --cache-dir PATH to hf cache ls, hf cache rm, or hf cache prune.

Official references: Hugging Face CLI reference and Hugging Face Hub v1.0 migration guide.

Want more practical AI and automation guides? Subscribe to AI Rabbit free.

Data Privacy | Imprint