skip to content

Upgrading to Transformers v5, a job calling pipeline('summarization') and pipeline('question-answering') fails; why, and what replaces those tasks?

level: seniorimportance: nice to knowfreq 7%

answer

  1. the task registry got shorter
  2. an unknown-task KeyError at construction
  3. Hub tags outlive library tasks
  4. a chat model behind text-generation
  5. images go inside the chat content

basics

~10 s

Transformers v5 removed the question-answering, summarization, translation and text2text-generation pipelines, plus image-to-text, visual-question-answering and image-to-image, so pipeline() raises an unknown-task KeyError. The replacement is text-generation with a chat model, or image-text-to-text for images.

solid answer

~40 s

Transformers v5 deleted those pipelines: `question-answering`, and `text2text-generation` with its `summarization` and `translation` variants, plus `image-to-text`, `visual-question-answering` and `image-to-image`. `pipeline()` checks the string against `TASK_ALIASES` and `SUPPORTED_TASKS`, so a removed name now raises `KeyError: Unknown task ...`, and so does `pipeline(model=...)` without a task when the repo's `pipeline_tag` is one of them. The migration guide's replacement is `pipeline("text-generation")` with a chat model: put the instruction and the text in a messages list and read the reply from `out[0]["generated_text"][-1]["content"]`. Captioning and visual QA move to `image-text-to-text`, with the image inside the chat content. A seq2seq checkpoint you must keep runs through `AutoModelForSeq2SeqLM` and `model.generate`. `table-question-answering` and `document-question-answering` still exist.

code

python · 11 lines
python
from transformers import pipeline

# v4: pipeline("summarization") -> v5: KeyError: Unknown task summarization
summarizer = pipeline("text-generation", model="Qwen/Qwen3-4B-Instruct-2507")

article = open("report.txt").read()
messages = [
    {"role": "user", "content": "Summarize the following text:\n\n" + article},
]
out = summarizer(messages, max_new_tokens=200, do_sample=False)
summary = out[0]["generated_text"][-1]["content"]

go deeper

for a junior

Recall that Transformers v5 removed several older pipeline tasks such as summarization and translation, and that a chat model with text-generation is the suggested replacement.

for a middle

Explain how the failure appears: the task string misses TASK_ALIASES and SUPPORTED_TASKS and raises a KeyError, including when the task was inferred from a repo's pipeline_tag.

for a senior

Plan the migration: list affected calls, move text tasks to a chat prompt and vision tasks to image-text-to-text, re-check cost and decoding defaults, and keep seq2seq checkpoints on AutoModelForSeq2SeqLM.

for a principal

Weigh rewriting extractive or seq2seq workloads onto a larger chat model against keeping the old checkpoint on lower-level calls, considering cost, output guarantees and future upgrades.

## What Transformers v5 removed Transformers v5 deleted several pipeline tasks outright. Its migration guide (`MIGRATION_GUIDE_V5.md`, section "Pipelines") removes these task strings: | Removed task string | Replacement the guide recommends | |---|---| | `question-answering` (extractive) | `text-generation` with a chat model | | `text2text-generation` | `text-generation` with a chat model | | `summarization` | `text-generation` with a chat model | | `translation` | `text-generation` with a chat model | | `image-to-text` | `image-text-to-text` with a vision-language chat model | | `visual-question-answering` | `image-text-to-text` with a vision-language chat model | | `image-to-image` | the separate Diffusers library | The stated reason: pipelines are meant as a beginner-friendly API, and for almost all text-to-text or question-answering work a modern chat model gives much higher-quality output, so offering the older pipelines was misleading. ## How the failure shows up `pipeline()` normalises the task string through `TASK_ALIASES` (`sentiment-analysis`, `ner`, `text-to-speech`) and then looks it up in `SUPPORTED_TASKS`. A removed name is in neither, so the call raises: - `KeyError: Unknown task summarization, available tasks are [...]` for an explicit task string; - the same `KeyError` for `pipeline(model="your-org/your-summarizer")` with no task, because the task is read from the repo's Hub `pipeline_tag`, and Hub repos keep tags such as `summarization` and `translation` even though Transformers no longer has pipelines for them. The failure is immediate at construction, which is the good case: it appears on the first run after the upgrade instead of as wrong output weeks later. Note what survived. **`table-question-answering`** and **`document-question-answering`** are still registered, as are `zero-shot-classification`, `fill-mask`, `token-classification` and `feature-extraction`. The words "question answering" in a name are not the test; the registry in `src/transformers/pipelines/__init__.py` is. Some prose docs shipped with the release still show a `visual-question-answering` example, which is one more reason to trust the registry over a tutorial. ## Migrating a text task The replacement is a chat prompt: 1. Choose an instruction-tuned chat checkpoint; the guide uses `Qwen/Qwen3-4B-Instruct-2507` and says any chat model works. 2. Build a messages list such as `[{"role": "user", "content": "Summarize the following text:\n\n" + text}]`. Translation and question answering are the same call with a different instruction. 3. Call `pipeline("text-generation", model=...)` on that list; the pipeline applies the model's chat template for you. 4. Read the reply. With chat input, `generated_text` is the whole conversation with the assistant's reply appended, so the answer is `out[0]["generated_text"][-1]["content"]`. What changes along with it: - **Cost.** A chat LLM is usually larger than the dedicated seq2seq checkpoint it replaces, so memory, latency and the device and dtype choices need revisiting. - **Output control.** The text-generation pipeline has its own generation defaults, sampling included, unless the model's `generation_config.json` sets them; pass `max_new_tokens` and `do_sample` explicitly in a batch job. - **Output contract.** Extractive QA returned an answer span located in the source text, with a confidence score; a chat model returns free text with no position. Code that relied on spans must be rebuilt. ## Vision tasks `image-to-text` and `visual-question-answering` move to **`image-text-to-text`**. In v5 that pipeline no longer accepts images as a separate argument alongside a chat: the image goes inside the message's `content` list as `{"type": "image", "image": ...}` next to `{"type": "text", "text": ...}`. ## Keeping an existing seq2seq checkpoint If you must keep a fine-tuned encoder-decoder summarizer, do not route it through `text-generation`: that pipeline is built for causal-LM architectures and logs an error for anything else. Load it with `AutoTokenizer` and **`AutoModelForSeq2SeqLM`**, tokenize, call **`model.generate(...)`** with `max_new_tokens`, and decode the output yourself, which is the work the removed pipeline used to do. `AutoModelWithLMHead`, which some old scripts used for this, was also removed in v5 in favour of the specific Auto classes. ## A migration checklist 1. Search the code base for every removed task string, and for `pipeline(model=...)` calls that omit the task and so depend on a Hub tag. 2. Compare each remaining task against `get_supported_tasks()` for the installed release, which returns the registered task names and aliases. 3. For each text task, choose a chat model, write the instruction into the prompt, and pin `model=` and `revision=` as for any production pipeline. 4. Set decoding explicitly (`max_new_tokens`, `do_sample`) rather than inheriting the text-generation defaults. 5. Rewrite result parsing: the reply now lives in the last message of `generated_text`, not in a task-specific field. 6. Construct every pipeline once in CI on the new version, so any remaining `KeyError` fails the build instead of the nightly job.

  • How do you find every place a v5 upgrade will break pipeline construction before you deploy?
    Search the code for the removed task strings and for `pipeline(model=...)` calls without a task, then check each of those repos' `pipeline_tag`. Compare against `get_supported_tasks()`, which lists the installed release's task names and aliases. Building each pipeline once in CI against the new version surfaces the `KeyError` at once, because the failure happens at construction rather than at inference.
  • Why is a chat model behind text-generation not a drop-in replacement for an extractive QA pipeline?
    Extractive QA selected a span of the supplied context and reported where it was, so the answer was always text from the source. A chat model generates free text: it can paraphrase or answer from outside the context, and it reports no position. If downstream code relied on verbatim spans or offsets, add that check yourself or keep a span-extraction model and run it without a pipeline.

  • Every pipeline task with question-answering in its name was removed in v5.
  • pipeline('summarization') still works in v5, only with a deprecation warning.
  • Any summarization checkpoint can simply be loaded with pipeline('text-generation').
  • A repo whose Hub pipeline_tag is translation must be broken or mislabelled.
  • The v5 image-text-to-text pipeline takes the image as a separate argument next to the chat.

Assumes Transformers v5: the question-answering, text2text-generation, summarization, translation, image-to-text, visual-question-answering and image-to-image pipelines were removed.