Lion Cipher Lab
Pin a Hugging Face model to a commit and verify its file hashes before use
- AI Security
- Beginner
- ~35 min
- Free · no account required
Why it matters
Teams pull models by name the way they used to pull libraries by name, and the name can point at different files tomorrow: the owner can push a new commit, or someone who gains access to the repository can. Pinning to a full commit hash and checking file hashes is the same discipline as a lockfile for code. It does not make a model trustworthy, but it makes a change visible, so that the question has this changed? has a definite answer.
What you'll learn
- explaining why a model name alone does not identify one fixed set of files
- resolving a repository to its full commit hash with the huggingface_hub library
- downloading a file at a pinned revision and finding it in the local cache
- comparing a file's SHA-256 with the hash the Hub reports
- writing a pin file and a check that fails closed
Steps in this lab
- A name is not a version
- Set up and resolve the repository to a commit
- Download one file at exactly that commit
- Check the file against the hash the Hub reports
- Prove the check can fail
- Decide when to bump the pin
- What this does and does not prove
- Clean up
Open the full interactive lab →