Skip to cookie settings

Hugging Face cache filled your disk: find and clean it

The cache never deletes old revisions on its own. Use the hf command to list what is in it, preview a deletion, and remove only what you can download again.

Part of: Local AI models on Mac: where Ollama, LM Studio and Hugging Face store them (AI models)

The Hugging Face cache is safe to delete, because everything in it was downloaded and can be downloaded again. It fills up because nothing cleans it for you. The hf command can list what is there, show what a deletion would free, and remove only what you choose.

Where the cache is

The huggingface_hub documentation (“Understand caching”) says the default cache directory is ~/.cache/huggingface/hub, and that you can change it with the HF_HOME or HF_HUB_CACHE environment variable. Libraries that use the Hub, such as the Python tools many AI projects rely on, share this one cache.

Inside, each repository gets its own folder, for example models--bert-base-cased or datasets--glue. The actual files sit in a blobs folder, and snapshots holds symlinks pointing to them. So the cache holds datasets as well as models.

Why it keeps growing

The same documentation says that cached files are never deleted on their own: when you download a new revision of a branch, the previous files are kept in case you need them again. If you tried ten models and updated a few, all of it stays.

Interrupted downloads leave partial files too. The docs call them .incomplete files and say hf cache prune is the command that removes them.

Find the big ones

The hf command is part of the huggingface_hub Python package. To list your cache by repository:

hf cache ls

I ran this against a test cache with huggingface_hub 2.1.1 and it printed one row per repository, with its size, when it was last accessed, and its refs. The docs show how to narrow it, for example with a size filter such as size>1GB or an age filter such as accessed>30d, and how to sort by size. If your hf command has no cache option, your huggingface_hub version is older than the docs I read, so update it first. hf version shows what you have.

To measure the whole folder without the tool, du -sh ~/.cache/huggingface/hub works as well.

Preview before you delete

hf cache rm takes one or more repository identifiers, as hf cache ls prints them, and a --dry-run option that shows what would be deleted without deleting it. The docs explain that --dry-run previews the effect and --yes skips the confirmation prompt, which you should not use for your first run. I ran the preview like this on a test cache:

hf cache rm model/<publisher>/<name> --dry-run

It listed the repository and its total size and reported that nothing was deleted. Running the same command without --dry-run deletes the repository permanently, and asks for confirmation first. I did not run the real deletion while writing this.

For a single large file, such as one quantization of a model, the docs describe removing one file with an hf:// file path. A removed file is downloaded again the next time it is needed.

Clean up leftovers

hf cache prune removes garbage: revisions no branch or tag refers to any more, unfinished downloads and shared files nothing uses. It also supports --dry-run. I ran it with --dry-run on a fresh test cache and it reported that there was nothing to prune. The docs show it freeing a few gigabytes on a real cache, so your result will differ.

The xet folder, by default ~/.cache/huggingface/xet (a sibling of the hub folder, not inside it), holds upload helper data. The docs say that if you need that space, the folder can be removed entirely. It is not needed for downloads.

Safe, risky, never

Item Verdict What breaks Cost to recreate
Revisions that no branch refers to, and unfinished downloads Safe Nothing Nothing, they are not in use
A model you tried once and dropped Safe Code that loads it downloads it again The model’s size, shown by hf cache ls
A model a project loads on every run Risky The next run waits for a full re-download The model’s size; offline use fails until then
The xet folder Safe Per the docs, only upload optimisation None for downloads
Files inside blobs or snapshots removed by hand Never The symlinks break, and the tool may find a half-cache Use hf cache rm instead

What to remember

  • The numbers in hf cache ls are what you will download again. Check them before you confirm.
  • Different tools can use the same cache, so a model you think is yours may be used by another project.
  • Offline work needs the cache. If you travel with a model, keep it.

For the other tools, see the overview of where local AI models are stored, removing Ollama models and models stored twice.

How DiskJoy fits in

DiskJoy is our product. It is pre-alpha: it scans and shows reclaimable space, so a large cache folder would show up in the results. Cleanup is not built yet, so it does not remove anything. The download page shows the current status of the scan.

Frequently asked questions

Is it safe to delete the Hugging Face cache?

Yes, in the sense that everything in it was downloaded and can be downloaded again. The cost is the re-download time and size, and any code that loads a model will fetch it again.

Where is the Hugging Face cache on a Mac?

By default at ~/.cache/huggingface/hub. The HF_HOME or HF_HUB_CACHE environment variables change it.

Why did the Hugging Face cache fill my disk?

Cached files are never deleted automatically. The huggingface_hub docs say that when you download a new revision, the previous files are kept in case you need them again.

How do I delete only some cached models?

List the cache with hf cache ls, then remove chosen repositories or revisions with hf cache rm. Add the dry-run option first to preview what would be freed.

Tags:Hugging Facehuggingface_hubCache

See what’s taking up space on your Mac

DiskJoy explains every item and removes nothing until you review it.
Download for Mac

Cookies on diskjoy.com

Your browser sends a Global Privacy Control signal. We honoured it: analytics and marketing cookies are off.

Necessary cookies run this site. Analytics shows us how it is used: if you accept it, Google receives data about your visit. Change this anytime in Cookie Settings. How Google uses data Cookie Policy Privacy policy

Customize

Purpose
Needed for the site to work and to remember your cookie choice.

Cookies

  • sy_consent - Stores your cookie choice (Retention: 12 months)

Other browser storage

  • sy_consent_pending (localStorage) - Queues your choice until it reaches our server (Retention: until deleted)
Purpose
Show us which pages are visited and how the site is used, so we can improve it. Provider: Google Ireland Ltd (Google Analytics 4).

Cookies

  • _ga - Distinguishes visitors to count them (Retention: 400 days)
  • _ga_TP2XMLG27P - Keeps the state of your current visit (Retention: 400 days)

Recipients

Data controller

Sylentis Group sp. z o.o.. Contact: support@diskjoy.com. Privacy policy

Google may process data outside the European Economic Area (EEA). Safeguards: EU-US Data Privacy Framework, standard contractual clauses.

Right to withdraw

You can withdraw consent at any time, as easily as you gave it. Withdrawal does not affect the lawfulness of processing before it.