How to Delete a Model from Your Hugging Face Cache with hf cache rm
Models downloaded from the Hugging Face Hub stay on your disk until you delete them, and a few large ones can fill it up. hf cache rm deletes a model from the cache safely: it shows what it will delete and asks first. This guide removes one model with huggingface_hub 2.5.0.
Syntax
hf cache rm <repo-type>/<repo-id> [--dry-run] [-y]
| Part | What it means |
|---|---|
<repo-type>/<repo-id> | What to delete, written as hf cache ls shows it, such as model/openai-community/gpt2. You can list several |
--dry-run | Shows what would be deleted and deletes nothing |
-y | Deletes without asking. Leave it out to be asked first |
The command's help text describes it: "Remove cached repositories, revisions or files." A target can also be a single revision, by its commit hash.
The Example
A small project downloads one file from each of two models, then deletes one of them from the cache.
Prerequisites
- uv. This guide uses uv 0.13.10 with Python 3.15.2.
Step 1: Create a Project and Fill the Cache
uv init --python 3.15 cache-cleanup
cd cache-cleanup
uv add huggingface_hub
uv run hf download openai-community/gpt2 config.json
uv run hf download google-t5/t5-small config.json
uv add huggingface_hub installed version 2.5.0 with its hf command, and the two downloads each saved a config.json in the cache.
Step 2: See What's in the Cache
uv run hf cache ls
ID SIZE LAST_ACCESSED LAST_MODIFIED REFS
--------------------------- ----- ----------------- ----------------- ----
model/google-t5/t5-small 1.2K a few seconds ago a few seconds ago main
model/openai-community/gpt2 665.0 a few seconds ago a few seconds ago main
Found 2 repo(s) for a total of 2 revision(s) and 1.9K on disk.

The ID column is exactly what hf cache rm expects.
Step 3: Preview the Deletion
uv run hf cache rm model/openai-community/gpt2 --dry-run
About to delete 1 repo(s) totalling 665.0.
- model/openai-community/gpt2 (entire repo)
✓ Dry run: no files were deleted.
dry_run: True
repos: 1
revisions: 1
size: 665.0

Nothing was deleted. The preview shows the whole gpt2 repository would go, and how much space that frees.
Step 4: Delete It
Run the same command without --dry-run. It asks for confirmation; type y and press Enter:
uv run hf cache rm model/openai-community/gpt2
About to delete 1 repo(s) totalling 665.0.
- model/openai-community/gpt2 (entire repo)
Proceed with deletion? [y/N]: y
✓ Deleted 1 repo(s) and 1 revision(s); freed 665.0.
repos_deleted: 1
revisions_deleted: 1
freed: 665.0
![The terminal after uv run hf cache rm model/openai-community/gpt2: the list of what will be deleted, the question Proceed with deletion? [y/N] answered with y, then Deleted 1 repo(s) and 1 revision(s); freed 665.0.](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/ai/hugging-face/hub/2026/hf-cache-rm-03-rm.webp)
The [y/N] means No is the answer if you just press Enter, so nothing is deleted by accident.
Step 5: Check the Cache Again
uv run hf cache ls
ID SIZE LAST_ACCESSED LAST_MODIFIED REFS
------------------------ ---- ----------------- ----------------- ----
model/google-t5/t5-small 1.2K a few seconds ago a few seconds ago main
Found 1 repo(s) for a total of 1 revision(s) and 1.2K on disk.

Only t5-small is left. If a program needs gpt2 again, it downloads it again. The commands work unchanged in PowerShell.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Leaving out the repository type: hf cache rm openai-community/gpt2 | The target doesn't match how the cache names it | Copy the ID from hf cache ls, with its model/ prefix |
Adding -y while you're still unsure | It deletes at once, without the question | Run --dry-run first |
| Deleting a model a running program is using | The program may fail, or download it again | Stop the program first |
FAQ
Can I delete everything at once?
hf cache ls -q prints only the IDs, and the command-line guide shows them passed to hf cache rm in one go. List first, so you know what you're about to remove.
Does deleting from the cache delete the model from the Hub?
No. It only deletes your local copy. The model stays on the Hub, and you can download it again at any time.
Conclusion
hf cache rm model/openai-community/gpt2 showed what it would delete, asked before deleting, and freed the space. --dry-run previewed it first, and hf cache ls confirmed only t5-small was left.
Additional Resources
- hf cache rm — the command and its options.
- Clean your cache — more ways to manage the cache from Python.
