Managing Hugging Face Models#
Treat models exactly like large datasets:
Pin your versions: Models update; always link a specific revision/commit.
Control your cache: Point downloads to fast local storage, not network drives.
Separate adapters: Save tiny LoRA weights, not entire base models.
Never just write: “We used Llama-3.”
Use the exact repository ID:
meta-llama/Meta-Llama-3-8BAlways specify the
revision(commit SHA or tag).
Downloading and Storing Snapshots#
Control download location:
from huggingface_hub import snapshot_download
# Download exactly what you need to a specific folder
path = snapshot_download(
repo_id="mistralai/Mistral-7B-v0.1",
revision="26bca36b...",
local_dir="data/raw/models/mistral"
)
Do not duplicate base models!
Fine-tuning a 15GB model creates another 15GB model.
With PEFT / LoRA save only the adapter weights (~50MB).
Track these small adapters with standard Git or DVC.
Cluster Tip:
Set the HF_HOME environment variable to point to $SCRATCH or $TMPDIR to avoid crashing shared network drives!
Just be aware that the data will be purged!