Cache path utilities for HuggingFace Hub snapshots.
Mirrors the Python huggingface_hub.snapshot_download cache layout so that
cached files produced by either library are interoperable.
Cache layout
$HF_HOME/hub/
models--gpt2/
refs/
main
blobs/
<sha256>
snapshots/
<commit_sha>/
config.json -> ../../blobs/<sha256>
Summary
Functions
Returns the default root cache directory for Hub snapshots.
Returns the folder name for a given repo_id and repo_type.
Returns the full on-disk path for a cached repo's snapshot root.
Returns the path for a specific snapshot revision of a repo.
Types
Functions
@spec default_cache_dir() :: String.t()
Returns the default root cache directory for Hub snapshots.
Equivalent to $HF_HUB_CACHE, defaulting to ~/.cache/huggingface/hub.
Returns the folder name for a given repo_id and repo_type.
Replaces / with -- in the repo ID, matching the Python implementation.
Examples
iex> HuggingfaceClient.Hub.Snapshots.repo_folder_name("gpt2", :model)
"models--gpt2"
iex> HuggingfaceClient.Hub.Snapshots.repo_folder_name("meta-llama/Llama-3.1-8B-Instruct", :model)
"models--meta-llama--Llama-3.1-8B-Instruct"
iex> HuggingfaceClient.Hub.Snapshots.repo_folder_name("rajpurkar/squad", :dataset)
"datasets--rajpurkar--squad"
Returns the full on-disk path for a cached repo's snapshot root.
~/.cache/huggingface/hub/models--gpt2/snapshots
Returns the path for a specific snapshot revision of a repo.
~/.cache/huggingface/hub/models--gpt2/snapshots/<revision>