Safeguard
Supply Chain•

How do you find every model your code loads before building an inventory?

Search code, configs, notebooks and containers for model loading calls and hub identifiers to build a first model inventory. Steps, patterns and gaps.

Safeguard Security Team
4 min read

Search your repositories for the calls that load models and the identifiers they pass, then check configs, notebooks, container files and scripts. A first pass with plain text search finds most of them. Record each hit with its source, revision and owner, and mark the ones you could not resolve.

Why start with discovery

You cannot write an AI bill of materials for models you do not know you use. Models enter through many doors: a data scientist's notebook, a default inside a library, an environment variable in a deploy file. An inventory built from memory misses these.

Where models hide

PlaceWhat to look for
Source codeCalls such as from_pretrained, torch.load, load_model, pickle.load, joblib.load
Config filesModel names in YAML, JSON or environment files
NotebooksThe same calls, often with a hard coded repo id
Dockerfiles and scriptsDownloads with the hub CLI, curl or wget of weight files
CI and deploy filesCache keys and mount paths that mention model folders
Requirements filesML libraries, and libraries that download models on first use

The Transformers docs show that from_pretrained takes a hub identifier or a local directory, so a string argument is your clue. Local paths need one more step: find where the folder is filled.

Steps

  1. Run a text search across all repos for the call names above.
grep -rnE "from_pretrained|torch\.load|load_model|pickle\.load|joblib\.load|snapshot_download|hf_hub_download" --include="*.py" --include="*.ipynb" .
  1. Search config and deploy files for known hub identifiers and for the words model, checkpoint and weights.
  2. List files with weight extensions that are checked in or mounted: .safetensors, .bin, .pt, .pth, .h5, .onnx.
  3. Check library defaults. Some libraries download a default model on first run, so read their docs for your version.
  4. Ask each team: what do you run in production, what do you use in notebooks, what does the pipeline pull?
  5. Write one row per model: identifier, revision or digest, format, license, owner, where it runs, and how you found it.
  6. Mark unknowns. A row that says "revision unknown" is a task, not a failure.

What this will miss

Text search cannot see models chosen at run time from user input, loaded through a remote service, or pulled by a vendor tool you do not control. For hosted models called by API, record the provider, the model name and the version you pin if one exists. That is a different kind of entry, but it belongs in the same list.

Keep the search script in version control and run it on a schedule, so new models show up as changes instead of surprises.

Try it yourself

Click through it at your own pace, or open it full screen.

Open the inventory and see how libraries are listed with versions. Your model list should read the same way.

Quick check

Do I need to inventory models I only call through an API?

Yes, as a separate kind of entry: provider, model name, pinned version where offered, and the terms you accepted. You cannot inspect the weights, but you can record what you depend on.

How often should I rerun the search?

On every pull request if you can, or at least weekly. Models are added casually, so catch them early.

Safeguard scans repositories for dependencies and generates SBOMs, which covers the libraries that load models. Try a free scan at gold.safeguard.sh/scan.

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.