What is ~/.cache/huggingface on Mac? Is it safe to delete?
You can delete the Hugging Face cache without breaking anything. The cost is that any model or dataset your code asks for is downloaded again, and those downloads are often very large.
Where it is
~/.cache/huggingfaceWhat it is
Libraries such as transformers, diffusers and datasets download models and datasets from the Hugging Face Hub the first time you use them. They are saved under ~/.cache/huggingface so later runs can load them from disk.
Inside, the hub folder contains one folder per repository, with names that start with models-- or datasets-- followed by the owner and name. That makes it easy to see what each one is.
It grows because trying a model once is enough to keep its full weights on disk indefinitely. Different revisions of the same model can also be stored side by side.
How big it gets
Anywhere from a few GB to well over a hundred GB, depending on which models and datasets you have tried.
How to clear it by hand
- Run the command below to list each cached repository with its size. It only reads, it deletes nothing.
- In Finder, choose Go > Go to Folder and enter ~/.cache/huggingface/hub.
- Move the model and dataset folders you no longer use to the Trash, then empty it.
- Leave the token file in ~/.cache/huggingface alone if you are logged in to the Hub, or you will need to log in again.
du -sh ~/.cache/huggingface/hub/*What happens afterwards
Code that loads a deleted model downloads it again on the next run, which needs a connection and can take a long time. Models you fine-tuned and saved elsewhere are not affected.
How Diskzy handles it
Diskzy lists the Hugging Face cache in the Clean up tab but leaves it unticked, because the models would download again.
Related guides
- Ollama models~/.ollama/models
- pip cache~/Library/Caches/pip
- Docker.raw~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
See where your Mac's space went
Diskzy maps your disk, explains System Data and clears what's safe. Free for 72 hours, then $9 once for 2 Macs.
Try Diskzy for free