Skip to main content

Fixed: "No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english"

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A Hugging Face sentiment-analysis pipeline worked, but first printed No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision 714eb0f. and Using a pipeline without specifying a model name and revision in production is not recommended. Naming the model and its revision in the code makes the warning go away, and makes the code safe to run in production.

What I Was Doing​

I checked a new Transformers 5.24.1 installation, on Python 3.14, the way the Transformers installation guide does it: a sentiment-analysis pipeline with only the task name.

check.py
from transformers import pipeline

classifier = pipeline("sentiment-analysis")
print(classifier("I love this library!"))
Terminal
uv run python check.py

What I Expected​

The model's answer, a label and a score:

Expected output
[{'label': 'POSITIVE', 'score': ...}]

What I Got​

The answer came, but after a warning:

Output
W1201 05:01:31.184000 48530 .venv/lib/python3.14/site-packages/torch/distributed/elastic/multiprocessing/redirects.py:35] NOTE: Redirects are currently not supported in MacOs.
[transformers] No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision 714eb0f.
Using a pipeline without specifying a model name and revision in production is not recommended.
Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
config.json: 100%|█████████████████████████████████████████████████| 629/629 [00:00<00:00, 4.76MB/s]
model.safetensors: downloading bytes: ██████████████████████████████████████████| 250MB, 8.89MB/s
model.safetensors: reconstructing file: 100%|██████████████████████████| 268MB / 268MB, 17.4MB/s
Loading weights: 100%|██████████████████████████████████████████| 104/104 [00:00<00:00, 6299.94it/s]
tokenizer_config.json: 100%|██████████████████████████████████████| 48.0/48.0 [00:00<00:00, 245kB/s]
vocab.txt: 100%|█████████████████████████████████████████████████| 232k/232k [00:00<00:00, 2.85MB/s]
[{'label': 'POSITIVE', 'score': 0.9998852014541626}]

The terminal after uv run python check.py: a macOS note from PyTorch, then [transformers] No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision 714eb0f, the line Using a pipeline without specifying a model name and revision in production is not recommended, the model files downloading, and the result POSITIVE.

The [transformers] line is the warning this post is about. The other two lines at the top are separate notices: the macOS note comes from PyTorch, and the Hub's warning means the download ran without an account.

What I Checked​

The warning names a model I never asked for, so I looked in the Transformers source for where it comes from. In transformers/pipelines/__init__.py, each task has a default model. For text classification:

transformers/pipelines/__init__.py (excerpt, 5.24.1)
"default": {"model": ("distilbert/distilbert-base-uncased-finetuned-sst-2-english", "714eb0f")},

And when no model is given, pipeline() takes that default and logs the warning:

transformers/pipelines/__init__.py (excerpt, 5.24.1)
logger.warning(
f"No model was supplied, defaulted to {model} and revision {revision}.\n"
"Using a pipeline without specifying a model name and revision in production is not recommended."
)

Why It Happens​

pipeline("sentiment-analysis") names a task, not a model. To work anyway, Transformers uses a default model for each task, pinned to a commit. The pipeline tutorial says: "Each task is configured to use a default pretrained model and preprocessor, but this can be overridden with the model parameter if you want to use a different model."

The warning is a reminder that a library's default is not a choice you made: a later Transformers version can change which model, or which commit, a task uses, and your results with it.

The Fix​

Name the model, and pin it to a commit with revision. These are the same model and commit the default used, with the commit written in full:

check.py
from transformers import pipeline

classifier = pipeline(
"sentiment-analysis",
model="distilbert/distilbert-base-uncased-finetuned-sst-2-english",
revision="714eb0fa89d2f80546fda750413ed43d93601a13",
)
print(classifier("I love this library!"))

The fixed check.py in a macOS-style code window: the sentiment-analysis pipeline with model set to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision set to the full commit hash 714eb0fa89d2f80546fda750413ed43d93601a13.

hf models info <model> --expand sha prints a model's current full commit hash. For your own projects, choose the model whose labels and language fit your task, check its license, then pin it the same way.

After the Fix​

Terminal
uv run python check.py
Output
W1201 05:02:08.289000 49904 .venv/lib/python3.14/site-packages/torch/distributed/elastic/multiprocessing/redirects.py:35] NOTE: Redirects are currently not supported in MacOs.
Loading weights: 100%|█████████████████████████████████████████| 104/104 [00:00<00:00, 13272.31it/s]
[{'label': 'POSITIVE', 'score': 0.9998852014541626}]

The terminal after the fix: the macOS note, the weights loading, and the result POSITIVE with a score of 0.9998852014541626, with no No model was supplied warning.

The No model was supplied warning is gone, the score is identical, and nothing was downloaded, because it's the same model and commit as before. The commands work unchanged in PowerShell.

Common Mistakes​

MistakeWhat happensDo this instead
Naming the model without a revisionThe warning goes away, but the code follows the model's newest commit, which can changeAdd revision with a full commit hash
Silencing the warning with logging settingsThe code still depends on a default that can changeName the model and revision

Troubleshooting​

SymptomLikely causeFix
No model was supplied, defaulted to facebook/bart-large-mnli and revision d7645e1The same, for a zero-shot-classification pipelinePass model="facebook/bart-large-mnli" and its full commit hash, or a model you chose
The warning names a model for another taskEvery task has its own defaultName a model for each pipeline you create

FAQ​

Is the default model bad?​

No. It's a reasonable model for the task. The point is to choose and pin a model on purpose.

Does naming the model download anything new?​

Not if you name the same model and commit: the files are already in the cache.

Conclusion​

No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision 714eb0f appeared because the pipeline was given only a task. Passing model and a full revision removed the warning and fixed the model's version in the code.

Additional Resources​