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.
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
- Open the model page and copy the
org/nameid exactly as shown. - Match casing and the org prefix in your
from_pretrainedcall. - Re-run once the id is correct to confirm it resolves.
from transformers import AutoModel
AutoModel.from_pretrained("bert-base-uncased") # exact id from the model pagePass a token for a private model
Expose a read token as HF_TOKEN in the job so transformers authenticates and the private repo resolves.
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}How to prevent it
- Copy repo ids from the model page rather than typing them.
- Set
HF_TOKENfor any private or gated model in CI. - Fail early with a check that the token is present before downloads.