Fixed: "KeyError: The task summarization has been removed from transformers"
pipeline("summarization") stopped with KeyError: 'The task summarization has been removed from transformers. Use the text-generation pipeline with a chat model instead.' Transformers 5 removed the summarization pipeline on purpose. A small chat model in a text-generation pipeline summarizes the same text, and the prompt says how short the summary should be.
What I Was Doing
I was checking which of the classic text pipelines still work in Transformers 5.26.0, on Python 3.14. A summarization pipeline takes a text and returns a shorter version of it:
from transformers import pipeline
summarizer = pipeline("summarization")
text = "The Eiffel Tower was finished in 1889 for the World's Fair in Paris."
print(summarizer(text))
uv run python summarize.py
What I Expected
A summary, as older Transformers versions return it:
[{'summary_text': '...'}]
What I Got
Traceback (most recent call last):
File "/Users/you/source/summarization-removed/summarize.py", line 3, in <module>
summarizer = pipeline("summarization")
File "/Users/you/source/summarization-removed/.venv/lib/python3.14/site-packages/transformers/pipelines/__init__.py", line 1071, in pipeline
task = _resolve_deprecated_task(task)
File "/Users/you/source/summarization-removed/.venv/lib/python3.14/site-packages/transformers/pipelines/__init__.py", line 378, in _resolve_deprecated_task
raise KeyError(
...<2 lines>...
)
KeyError: 'The task summarization has been removed from transformers. Use the `text-generation` pipeline with a chat model instead. See the migration guide for more details: https://github.com/huggingface/transformers/blob/main/MIGRATION_GUIDE_V5.md#pipelines'

The error came as soon as the pipeline was created, before any model was downloaded.
What I Checked
The message links to the Transformers v5 migration guide. Its section "Text pipelines that should just be LLMs" says the summarization, translation and question-answering pipelines "were deprecated and will now be removed", because "for almost all text-to-text or question-answering tasks a modern chat model and TextGenerationPipeline will provide much higher quality output." Its replacement example is exactly this task:
summarizer = pipeline("text-generation", model="Qwen/Qwen3-4B-Instruct-2507")
message_history = [
{
"role": "user",
"content": "Summarize the following text:\n\n[TEXT_TO_SUMMARIZE]"
}
]
print(summarizer(message_history)[0]["generated_text"][-1]["content"])
In the source, transformers/pipelines/__init__.py lists summarization among its REMOVED_TASKS and raises this KeyError for it.
Why It Happens
The summarization pipeline was removed in Transformers 5. Code and tutorials written for Transformers 4 still create it, and they fail on that line.
The Fix
Follow the guide's example with a smaller chat model. Qwen/Qwen3-4B-Instruct-2507 has 4 billion parameters, about 8 GB to download, and the guide notes that "Any other chat model will also work - if you're low on memory you can use a smaller one". This fix uses Qwen/Qwen2.5-0.5B-Instruct (988 MB, Apache-2.0), and a longer text so there's something to summarize:
from transformers import pipeline
summarizer = pipeline(
"text-generation",
model="Qwen/Qwen2.5-0.5B-Instruct",
revision="7ae557604adf67be50417f59c2c2f167def9a775",
)
text = (
"The Eiffel Tower was finished in 1889 for the World's Fair in Paris. "
"Many artists called it ugly at first, but it became the symbol of the city "
"and is now one of the most visited monuments in the world."
)
messages = [
{"role": "user", "content": f"Summarize this text in one sentence:\n\n{text}"},
]
print(summarizer(messages)[0]["generated_text"][-1]["content"])

The prompt asks for "one sentence". With the guide's wording alone, "Summarize the following text:", this model's first summary came out longer than the text itself, with praise for the tower that the text never gave. Saying how long the summary should be keeps it short.
After the Fix
uv run python summarize.py
Loading weights: 100%|██████████████████████████████████████████| 290/290 [00:00<00:00, 6085.30it/s]
The Eiffel Tower, completed in 1889, was initially seen as an unsightly structure before becoming a beloved symbol of Paris and one of the most popular tourist attractions globally.

One sentence with the three facts of the text: finished in 1889, called ugly at first, now a symbol and a top sight. The model was already downloaded; on a first run, its files download before this line. The commands work unchanged in PowerShell.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Not saying how long the summary should be | A small model can write more than it was given | Ask for a length: "in one sentence", "in 20 words" |
| Trusting every detail of the summary | Chat models can add things the text never said | Read summaries of important texts before you rely on them |
| Pasting a very long text into one message | It can exceed what the model reads at once, or slow it down a lot | Split long texts and summarize the parts |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
KeyError: 'The task question-answering has been removed from transformers. | Question answering was removed too | Fixed: KeyError: The task question-answering has been removed from transformers |
The same KeyError for translation or text2text-generation | Also removed in Transformers 5 | A chat model with a prompt that asks for it |
| The summary changes between runs | The model picks its words with some randomness | That's normal for chat models; ask for a fixed format if you compare outputs |
FAQ
Can I still use BART or T5 summarization models?
Not through pipeline("summarization") in Transformers 5. The migration guide recommends chat models for this task.
Is a 0.5-billion-parameter model good enough?
For short, simple texts, as here, yes. For long or technical texts, a larger chat model writes better summaries, if your computer has the memory for it.
Conclusion
pipeline("summarization") raised KeyError: 'The task summarization has been removed from transformers.' because Transformers 5 removed that pipeline. A text-generation pipeline with Qwen/Qwen2.5-0.5B-Instruct and the prompt "Summarize this text in one sentence" turned three sentences into one.
Additional Resources
- Migration guide: Text pipelines that should just be LLMs — why the pipelines were removed, with this example.
- Chat basics — using chat models with Transformers.
- Qwen/Qwen2.5-0.5B-Instruct — the model's card.
