Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the Default Cache Path for All HuggingFace Data

The default cache path of huggingface is in ~/.cache/huggingface, and in that folder, there are multiple cache files like models, and hub.

The huggingface documents indicates that the default dataset cache location can be modified by setting the shell environment variable, HF_DATASETS_CACHE to a different directory as shown below:

$ export HF_DATASETS_CACHE="/path/to/another/directory"

However, my objective is to alter the default cache directory for all HuggingFace data and not solely the dataset. I am facing difficulties in finding the respective shell environment variable in the HuggingFace documentation to accomplish this. Any help would be appreciated.

like image 780
Peyman Avatar asked Oct 27 '25 09:10

Peyman


1 Answers

It seems that the variable is HF_HOME as this document indicates. So probably this terminal code should be the solution:

export HF_HOME="/path/.cache/huggingface"
export HF_DATASETS_CACHE="/path/.cache/huggingface/datasets"
export TRANSFORMERS_CACHE="/path/.cache/huggingface/models"

p.s. If you want to make your change permanent, you should write these lines in your .bashrc(Can do with .bash_profile too) file using nano ~/.bashrc

like image 151
Peyman Avatar answered Oct 28 '25 22:10

Peyman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!