Safeguard
Security Guides•

How do you retire a model dependency cleanly?

Removing a model from code leaves copies in caches, images and stores. A checklist for retiring a model so old files and old risk do not linger.

Safeguard Security Team
3 min read

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

LocationWhy it persists
Developer cachesThe Hugging Face cache keeps blobs and snapshots under HF_HOME until cleaned
CI cachesCache steps restore old folders between runs
Container imagesModels baked into images stay in every old tag
Artifact storesApproved copies remain after the project ends
Notebooks and scriptsDownload calls sit in files nobody opens
BackupsSnapshots 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

  1. Confirm the decision. The model owner approves retirement and records the reason.
  2. 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.
  3. Remove the code and the pin. Do it in a pull request so the change is reviewed.
  4. 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.
  5. Clear CI caches. Change the cache key, or purge the stored cache, so a restore does not bring the files back.
  6. Rebuild images. Rebuild without the model and retire old tags per your image retention policy.
  7. Remove stored copies. Delete from artifact stores after the retention period you set for rollback.
  8. Update the inventory. Mark the model retired with a date, the owner and the reason. Keep the record, delete the files.
  9. Revoke access. Remove tokens or permissions that existed only for that model.
  10. 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.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.