Deleting the line of code that loads a model does not retire it. Copies remain in local caches, CI caches, container images, artifact stores and notebooks. Retire a model by finding every copy, removing it, updating the inventory and confirming nothing still loads it.
Where copies hide
| Location | Why it persists |
|---|---|
| Developer caches | The Hugging Face cache keeps blobs and snapshots under HF_HOME until cleaned |
| CI caches | Cache steps restore old folders between runs |
| Container images | Models baked into images stay in every old tag |
| Artifact stores | Approved copies remain after the project ends |
| Notebooks and scripts | Download calls sit in files nobody opens |
| Backups | Snapshots of volumes keep the files |
The cache documentation describes blobs, snapshots and refs folders, with one snapshot folder per known revision. That means a model you moved through three revisions may have three snapshots on disk.
Retirement steps
- Confirm the decision. The model owner approves retirement and records the reason.
- Search for loaders. Search code, config and notebooks for the repo name and for the commit hash. If you have no inventory, see how to find every model your code loads.
- Remove the code and the pin. Do it in a pull request so the change is reviewed.
- Clean caches. The huggingface_hub documentation describes hf cache rm and hf cache prune commands, plus helpers to delete revisions programmatically. Run them on shared build hosts and document how developers do it locally.
- Clear CI caches. Change the cache key, or purge the stored cache, so a restore does not bring the files back.
- Rebuild images. Rebuild without the model and retire old tags per your image retention policy.
- Remove stored copies. Delete from artifact stores after the retention period you set for rollback.
- Update the inventory. Mark the model retired with a date, the owner and the reason. Keep the record, delete the files.
- Revoke access. Remove tokens or permissions that existed only for that model.
- Verify. Run a search and a scan to confirm nothing references it, and watch logs for download attempts for a few weeks.
Keep one decision record
A model you retire for a security reason may come back under another name. A short note with the owner, repo, hash and reason lets the next person recognize it. Keep the note even if the files are gone.
Retirement as a routine
Make it a quarterly job: list models with no activity for ninety days and ask owners to confirm or retire. Unused models are pure risk, since they get no attention and no updates.
Try it yourself
Click through it at your own pace, or open it full screen. See how an inventory makes it possible to ask what still uses a component.
Safeguard's asset discovery and SBOM can show what software is still present, and policies can flag components marked for removal. A free scan gives a starting list.
Quick check
Is removing the code enough to retire a model?
No. Caches, images, stores and backups can still hold the files.
Should I delete the inventory record too?
No. Keep the record as retired, with date and reason, and delete the files.
Sources
Last reviewed: 19 October 2026.