Skip to content
Latchkey

Hugging Face "does not appear to have a file named config.json" in CI

from_pretrained needs a config.json to build the model, and the repo or path you pointed at does not contain one at the requested revision. Often the id points at a dataset, a partial upload, or a local directory missing the config.

What this error means

The load fails with "OSError: <repo> does not appear to have a file named config.json. Checkout 'https://huggingface.co/<repo>/main' for available files."

transformers
OSError: org/model-repo does not appear to have a file named config.json.
Checkout 'https://huggingface.co/org/model-repo/main' for available files.

Common causes

The repo or path has no config.json at that revision

A partial upload, a wrong revision, or a local checkpoint dir that never wrote the config leaves nothing for from_pretrained to read.

The id points at the wrong resource

Pointing a model loader at a dataset repo or a subfolder without a config produces this error.

How to fix it

Point at a path that contains config.json

  1. Open the repo files at the target revision and confirm config.json is present.
  2. For a local checkpoint, ensure the directory has the config alongside weights.
  3. Pass the correct subfolder or revision if the config lives elsewhere.
python
from transformers import AutoModel
AutoModel.from_pretrained("org/model-repo", revision="main", subfolder="checkpoint-500")

Save a full model before reloading

If you trained and reloaded, make sure the save wrote the config, not only weights.

python
model.save_pretrained("out/")  # writes config.json + weights
AutoModel.from_pretrained("out/")

How to prevent it

  • Confirm config.json exists at the target revision before loading.
  • Use save_pretrained so configs and weights stay together.
  • Match the loader class to the resource kind.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →