TRANSFORMERS_CACHE is removed from transformers.utils, and the doc says using HF_HOME instead. But in some environment the HF_HOME is not set. How can i get TRANSFORMERS_CACHE (default cache dir) from code? I don’t quite understand the motivation for this change.
Hey ![]()
TRANSFORMERS_CACHE was removed because the cache is now treated as a Hugging Face Hub concern (shared across transformers, diffusers, datasets, etc.), so the “source of truth” moved to huggingface_hub and the HF_HOME / HF_HUB_CACHE env vars.
Even if HF_HOME isn’t set, there’s still a default cache dir. You can get it directly from code like this:
from huggingface_hub.constants import HF_HUB_CACHE
print(HF_HUB_CACHE)
That will resolve to the default (typically ~/.cache/huggingface/hub) unless the user overrides it via HF_HUB_CACHE or HF_HOME.
Motivation-wise:
it avoids having multiple libraries each inventing their own cache variables/paths and makes tooling/cleanup/offline behavior consistent across the whole HF ecosystem. Hope this helps ![]()