Fixed: return_all_scores=True Returns Only One Label in Transformers 5
A model card's example passes return_all_scores=True to a Hugging Face text-classification pipeline and shows a score for every label. In Transformers 5 the same code printed only the top label, with no error and no warning, because the argument no longer exists. top_k=None is its replacement, and it returned all six labels.
What I Was Doing
I was trying bhadresh-savani/distilbert-base-uncased-emotion, a model that classifies English text into six emotions, with the example in the "How to Use the model" section of its card on the Hugging Face Hub:

I copied the example as it is, in a project with Transformers 5.26.0 on Python 3.14:
from transformers import pipeline
classifier = pipeline("text-classification",model='bhadresh-savani/distilbert-base-uncased-emotion', return_all_scores=True)
prediction = classifier("I love using transformers. The best part is wide range of support and its easy to use", )
print(prediction)
uv run python card_snippet.py
What I Expected
What the card's Output block shows: all six emotions, each with its score, joy at 0.9959 and the other five far below it.
What I Got
Loading weights: 100%|█████████████████████████████████████████| 104/104 [00:00<00:00, 11900.68it/s]
[{'label': 'joy', 'score': 0.9959298968315125}]

One label instead of six. The top label and its score match the card, so the model works; the other five scores are missing, and nothing says why.
What I Checked
Whether the argument still exists. Transformers' pull request huggingface/transformers#43195, "Remove more deprecated objects/args", merged in January 2026 for Transformers 5, removed return_all_scores. The text-classification pipeline's settings in 5.26.0 are function_to_apply and top_k; every other keyword argument goes to the tokenizer:
def _sanitize_parameters(self, function_to_apply=None, top_k="", **tokenizer_kwargs):
# Using "" as default argument because we're going to use `top_k=None` in user code to declare
# "No top_k"
preprocess_params = tokenizer_kwargs
So return_all_scores=True is handed to the tokenizer, which doesn't use it, and the pipeline returns its default: the top label.
Whether it's known. An issue on Transformers, huggingface/transformers#43901, "TextClassificationPipeline docs still mention return_all_scores, but behavior differs", shows the same result: "users may expect return_all_scores=True to return all label scores, but it currently returns only the top label." It was closed by a fix to the documentation, #43903.
What replaces it. Before the argument was removed, using it printed a deprecation warning that named its replacement. The code that #43195 removed said:
"`return_all_scores` is now deprecated, if want a similar functionality use `top_k=None` instead of"
" `return_all_scores=True` or `top_k=1` instead of `return_all_scores=False`.",
The pipeline's documentation describes top_k as "How many results to return", and top_k=None means no limit: every label.
Why It Happens
The card was written for an older Transformers, where return_all_scores=True returned every label. Transformers 5 removed the argument, but the pipeline accepts unknown keyword arguments and passes them to the tokenizer, so the old argument is silently ignored instead of raising an error.
The Fix
Pass top_k=None when you call the pipeline. This version also pins the model to a commit, so it doesn't change under the code:
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="bhadresh-savani/distilbert-base-uncased-emotion",
revision="98864ce5bb9cb58a41e882e62f1d8e55173b5ac6",
)
prediction = classifier(
"I love using transformers. The best part is wide range of support and its easy to use",
top_k=None,
)
print(prediction)

After the Fix
uv run python card_fixed.py
Loading weights: 100%|██████████████████████████████████████████| 104/104 [00:00<00:00, 9092.39it/s]
[{'label': 'joy', 'score': 0.9959298968315125}, {'label': 'anger', 'score': 0.0018055237596854568}, {'label': 'love', 'score': 0.0009452462545596063}, {'label': 'sadness', 'score': 0.000679271062836051}, {'label': 'fear', 'score': 0.0004111042362637818}, {'label': 'surprise', 'score': 0.00022885717044118792}]

All six labels, with the same scores as the card's output to six or more decimal places. Two things differ from the card: the list is sorted from the highest score down, and it's one flat list instead of a list inside a list. The commands work unchanged in PowerShell.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Reading the first result as the model's first label | With top_k=None, results are sorted by score, so the first is the top label | Look labels up by their label, not their position |
Passing top_k=None to pipeline(...) instead of the call | One text then returns a list inside a list, and code that loops over it fails | Pass it when you call the pipeline, as above |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
TypeError: list indices must be integers or slices, not str after switching to top_k=None | top_k=None was given to pipeline(...), so a single text returns a nested list | Fixed: TypeError: list indices must be integers or slices, not str with a Hugging Face Pipeline's top_k |
| Only some of the labels come back | top_k set to a number | top_k=None returns them all |
FAQ
Do the scores add up to 1?
For this model, yes. The pipeline's documentation says that when a model has two labels or more, "the pipeline will run a softmax over the results", which shares 1 between the labels. Adding up the six scores for another sentence gave 1.000000001717126: 1, apart from the rounding of decimal numbers.
Is the card wrong?
It was right for the Transformers version it was written with. The card's code is the model author's to update.
Conclusion
return_all_scores=True printed one label in Transformers 5 because the argument was removed, and the pipeline passes unknown arguments to the tokenizer instead of rejecting them. Calling the pipeline with top_k=None returned all six emotions with the card's scores, sorted from highest to lowest.
Additional Resources
- TextClassificationPipeline —
top_kandfunction_to_apply. - huggingface/transformers#43901 — the issue that reported this behaviour.
- bhadresh-savani/distilbert-base-uncased-emotion — the model's card.
