Skip to content
Latchkey

Hugging Face "is not a local folder and is not a valid model identifier" in CI

transformers looked for the name as a local directory, found none, then queried huggingface.co and got nothing it can use. Either the repo id is mistyped, or the model is private and CI sent no token so the Hub returns it as if it does not exist.

What this error means

from_pretrained fails with "OSError: <repo> is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'". It works locally where you are logged in but fails on a fresh runner.

transformers
OSError: org/private-model is not a local folder and is not a valid model identifier
listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this
repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`.

Common causes

The repo id is mistyped or missing the org prefix

A model id is org/name; dropping the org, a typo, or a wrong casing means the Hub has no such public repo and reports the identifier as invalid.

The model is private and CI sent no token

To an unauthenticated request the Hub hides private repos, so the same error appears even though the repo exists and you can see it while logged in locally.

How to fix it

Verify the exact repo id

  1. Open the model page and copy the org/name id exactly as shown.
  2. Match casing and the org prefix in your from_pretrained call.
  3. Re-run once the id is correct to confirm it resolves.
python
from transformers import AutoModel
AutoModel.from_pretrained("bert-base-uncased")  # exact id from the model page

Pass a token for a private model

Expose a read token as HF_TOKEN in the job so transformers authenticates and the private repo resolves.

.github/workflows/ci.yml
env:
  HF_TOKEN: ${{ secrets.HF_TOKEN }}

How to prevent it

  • Copy repo ids from the model page rather than typing them.
  • Set HF_TOKEN for any private or gated model in CI.
  • Fail early with a check that the token is present before downloads.

Frequently asked questions

What causes ""not a valid model identifier""?
A model id is org/name; dropping the org, a typo, or a wrong casing means the Hub has no such public repo and reports the identifier as invalid.
How do I fix "not a valid model identifier"?
Verify the exact repo id

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card