Chapter 1 questions

Oh. Um, the word “pipeline” is used quite broadly, so it can be a little confusing, but roughly speaking:


If by “pipeline” you mean the pipeline() function introduced in Chapter 1, then it is not really pipeline versus Diffusers.

The pipeline() used in the course is a high-level function provided by the Transformers library:

from transformers import pipeline

classifier = pipeline("sentiment-analysis")

It combines the model with the preprocessing and postprocessing needed for a task. This is the meaning used in the course’s Working with pipelines section.

Diffusers is a different library, mainly designed for diffusion models. However, Diffusers also calls its high-level interfaces “pipelines”:

from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("organization/model-name")

See the Diffusers pipeline documentation for examples.

So a more useful distinction is:

Example import Recommended loading route
from transformers import pipeline Transformers
from transformers import AutoModel... Transformers, without necessarily using the high-level pipeline() function
from diffusers import DiffusionPipeline Diffusers
An import from another library Follow that library’s instructions

For a beginner, the safest default route is:

  1. Open the model’s page on the Hub.
  2. Check Use this model and the example code in the model card.
  3. Look at the import statement.
  4. Use the library and loader shown in that example.

For example, if the model card shows:

from transformers import pipeline

then use the Transformers route.

If it shows:

from diffusers import StableDiffusionPipeline

or:

from diffusers import DiffusionPipeline

then use the Diffusers route.

The task shown on the model page can be a useful clue, but it is not a complete rule. For example, text-to-image often points toward Diffusers, while text-generation often points toward Transformers, but the Hub can also contain models intended for other libraries or runtimes. The course itself notes that the Hub is not limited to Transformer models.

One additional source of confusion is .safetensors. That extension only identifies a format for storing tensors; it does not by itself tell you whether the model should be loaded with Transformers, Diffusers, or something else.

Diffusers can load some compatible single-file diffusion checkpoints with methods such as from_single_file(), but that depends on the model architecture and configuration. The Diffusers model-format documentation explains the distinction between a normal Diffusers repository layout and a single-file checkpoint.

In short:

  • pipeline() in this chapter means the Transformers API.
  • Diffusers is another library, and it has pipelines of its own.
  • A model is not identified as a Diffusers model merely because it has a .safetensors file.
  • The model card and its loading example are normally the best guide.
  • If the page provides several loading options, there may be several valid ways to run the same model.

When running the chapter 1.3 notebook in Google Colab I see the following error.

KeyError: "Unknown task question-answering, available tasks are ['any-to-any', 'audio-classification', 'automatic-speech-recognition', 'depth-estimation', 'document-question-answering', 'feature-extraction', 'fill-mask', 'image-classification', 'image-feature-extraction', 'image-segmentation', 'image-text-to-text', 'keypoint-matching', 'mask-generation', 'ner', 'object-detection', 'sentiment-analysis', 'table-question-answering', 'text-classification', 'text-generation', 'text-to-audio', 'text-to-speech', 'token-classification', 'video-classification', 'zero-shot-audio-classification', 'zero-shot-classification', 'zero-shot-image-classification', 'zero-shot-object-detection']"

Does the notebook need to be updated? If so, I’m happy to open an issue/PR or whatever the process is.

Put simply, I think you’re right that this is a compatibility issue, but it looks like one of those cases where the workaround is easy and the proper fix is awkward​:scream::


Yes, the notebook appears to need either a version constraint or a code/content update. The error is raised while pipeline() is validating the task name, before it gets as far as loading a question-answering model, so this does not look like a model download problem or a mistake in your question/context inputs.

The first useful check is the actual Transformers version and task registry:

import transformers
from transformers.pipelines import get_supported_tasks

print("Transformers version:", transformers.__version__)
print("Imported from:", transformers.__file__)
print(
    "question-answering registered:",
    "question-answering" in get_supported_tasks(),
)

The same Course example was reported in huggingface/course#1211 with Transformers 5.3.0. The v5.2.0 registry still contained question-answering, while the v5.3.0 registry no longer does. The current pipeline API’s accepted-task list also does not include the plain text question-answering pipeline.

Practical default: pin v4 if the goal is to finish this notebook as written

For a learner following the existing Chapter 1.3 notebook, I think the least surprising workaround is to use a fresh runtime and pin the notebook to the final v4 series:

# Run this before importing transformers.
!pip install -q "transformers[sentencepiece]==4.57.6" datasets evaluate

Then restart the Colab runtime once and run the notebook again from the top.

A looser constraint such as this expresses the same compatibility boundary:

!pip install -q "transformers[sentencepiece]<5" datasets evaluate

I would prefer the exact version in a teaching notebook because it is more reproducible. This is a compatibility workaround, not a claim that v4 is generally preferable for new projects.

Pinning only to transformers==5.2.0 is a useful QA-only diagnostic, because that version still registered the old QA pipeline. It is not as good a default for the complete notebook: the same notebook also uses the older summarization and translation pipelines, which are part of the broader v5 pipeline migration.

About opening an issue or PR

There are already two relevant Course issues:

So I would probably reference those rather than open an unrelated duplicate.

One slightly confusing detail is that #1211 was closed through Transformers PR #44787. That PR updated several language versions of the Transformers question-answering task guide to use AutoTokenizer and AutoModelForQuestionAnswering directly. It did not update the Chapter 1.3 Course page or its Colab notebook, and both currently still show the old pipeline call:

That is why the closed issue and the still-broken notebook can coexist.

Why this is more than a one-line pipeline rename

The version history is a little confusing

The Transformers v5 migration guide groups the following removals together:

  • question-answering
  • Text2TextGenerationPipeline
  • SummarizationPipeline
  • TranslationPipeline

It recommends using a chat model through TextGenerationPipeline for many of those use cases.

However, the tagged source shows that the removals did not all appear at exactly the same minor-version boundary:

Version/source Plain question-answering pipeline
Transformers v4.57.6 Registered
Transformers v5.2.0 Still registered
Transformers v5.3.0 No longer registered
Current pipeline documentation Not in the accepted-task list

So I would distinguish two statements:

  1. Migration policy: the task-specific QA pipeline is part of the v5 removals.
  2. Observed implementation boundary: the QA registration remained through 5.2 and disappeared in 5.3.

Since your screenshot does not display transformers.__version__, I would describe the error as consistent with current Transformers releases rather than assume one exact version.

There are also a few residual references to question answering on the current general pipeline documentation page even though it is absent from the accepted-task list. That looks like documentation migration lag rather than evidence that pipeline("question-answering") is still supported.

Extractive QA still exists; the convenience pipeline is what disappeared

This distinction matters because “the QA pipeline was removed” does not mean that Transformers can no longer run extractive question-answering models.

The current question-answering task guide still documents:

from transformers import AutoTokenizer, AutoModelForQuestionAnswering

and shows inference using a model’s start and end logits.

That route preserves the type of task demonstrated by Chapter 1.3: extractive question answering, where the answer is selected from a span in the supplied context.

The Course itself explicitly says:

this pipeline works by extracting information from the provided context; it does not generate the answer

That is different from asking a general chat model to generate an answer.

Why the direct-model rewrite is not fully equivalent to changing one line

A minimal direct-model example can tokenize the question/context, run AutoModelForQuestionAnswering, choose start/end positions, and decode the resulting token span. That is enough to demonstrate the basic model contract.

The old pipeline did more than that, however. Its implementation also handled parts of the preprocessing and post-processing contract, including such things as:

  • selecting answer spans only from the context rather than the question or special tokens;
  • rejecting spans where the end precedes the start;
  • limiting the maximum answer length;
  • scoring combinations of start and end positions;
  • mapping token positions back to character offsets in the original context;
  • splitting long contexts into overlapping chunks;
  • comparing candidates produced from different chunks;
  • returning answer, score, start, and end;
  • optional top-k and impossible-answer handling.

The archived v4 implementation is visible in question_answering.py.

For that reason, the small inference example in the current task guide is a useful educational replacement, but I would not describe it as a drop-in implementation of every behavior of the former pipeline.

Why replacing it with text-generation changes the lesson

The migration guide’s chat-model recommendation may be a reasonable modernization route, but it changes what this particular Course example demonstrates.

Extractive QA model Chat/text-generation model
Selects a span from the supplied context Generates new output tokens
Can return source character offsets Normally has no equivalent start/end contract
Answer is constrained to the source span by the model structure and decoding May paraphrase, combine information, or produce unsupported text
Usually uses an encoder model with a QA head Usually uses a generative decoder or encoder-decoder model
Demonstrates span classification Demonstrates prompted generation

The current QA guide also explicitly separates:

  • extractive QA: extract an answer from the context;
  • abstractive QA: generate an answer based on the context.

Therefore, changing the notebook to something like this:

pipeline("text-generation", model="<some-chat-model>")

would not merely rename an API. It would change the task, output contract, model family, likely runtime requirements, and some of the failure modes being taught.

There are at least two defensible modernization choices:

Route A: preserve the original lesson

Keep the example as extractive QA and replace the removed pipeline with an explicit tokenizer/model/span-decoding example based on:

This preserves the distinction between extracting and generating an answer, but it requires more code and explanation than the old one-call pipeline.

Route B: redesign the overview for current chat models

Replace the example with prompted text-generation, but rewrite the surrounding explanation so it is presented as generative or abstractive QA rather than as a direct replacement for extractive span selection.

This may align more closely with the general v5 migration recommendation, but it is a content/design change rather than a compatibility-only patch.

Why a complete Course fix spans more than this cell

The current Colab setup installs an unconstrained latest Transformers release:

!pip install datasets evaluate transformers[sentencepiece]

The notebook then uses all three of these older task-specific calls:

pipeline("question-answering")
pipeline("summarization")
pipeline("translation", ...)

In addition, the rendered Course lesson and the runnable Colab notebook live in separate repositories:

Material Repository
Course prose and displayed code huggingface/course
Runnable Chapter 1 notebook huggingface/notebooks

Updating only the MDX would leave the Colab button opening an outdated notebook. Updating only the notebook would leave the displayed Course example outdated.

A durable fix therefore needs an editorial choice as well as a code change:

  1. Pin Chapter 1 to the legacy API intentionally.
  2. Rewrite all affected examples for current APIs.
  3. Preserve the original task taxonomy with lower-level model APIs.
  4. Redesign the section around current generative models.
  5. Possibly provide a short legacy note while introducing the current route.

That is the “proper fix is awkward” part: it is not difficult because the error is mysterious; it is awkward because a small beginner-facing API was carrying quite a lot of educational structure.

Possible contribution scopes

There are several reasonable contribution sizes, depending on what the maintainers prefer.

Small compatibility patch

  • Pin the notebook to a known v4 release.
  • Add a short note explaining that the chapter demonstrates the v4 pipeline API.
  • Make the Course page and Colab notebook use the same constraint.

This is the smallest change and restores the lesson quickly, but it deliberately teaches an older API.

Focused QA modernization

  • Keep the example extractive.
  • Replace pipeline("question-answering") with an explicit tokenizer/model example.
  • Preserve the explanation that the answer is extracted rather than generated.
  • Update both the Course MDX and the notebook.

This is conceptually clean, but a little longer than the original beginner example.

Chapter 1.3 v5 migration

Audit the whole section rather than only QA:

  • NER arguments;
  • question answering;
  • summarization;
  • translation;
  • corresponding prose and expected outputs;
  • notebook dependencies;
  • Course and notebook synchronization.

#1197 is probably the most relevant place to connect a broader change like this.

A small review-friendly validation matrix

A PR would be easier to evaluate if it states which goal it is pursuing and records a few simple checks:

Check What it establishes
Print transformers.__version__ The result is tied to a known environment
Test a fresh Colab runtime Rules out state left by an earlier import/install
Run the old notebook under v4.57.6 Confirms the compatibility workaround
Check v5.2 versus v5.3 for QA only Confirms the observed registry boundary
Run the proposed current-version example Confirms the replacement actually works
Verify both MDX and notebook Prevents the rendered lesson and Colab from drifting apart
Preserve or explicitly change the task description Makes the extractive/generative design decision visible

This need not become a large test suite; even a short note in the PR description would make the intended compatibility boundary much clearer to future readers.

So my answer to “Does the notebook need to be updated?” would be yes:

  • For continuing the lesson now: pin Transformers to v4 in a fresh runtime.
  • For fixing the course: connect the change to the existing issues and decide explicitly whether the example should remain extractive QA or be redesigned as generative QA.
  • For a QA-only sanity check: comparing 5.2 with 5.3 is useful, but it does not solve the other old pipelines later in the same notebook.

A new issue may not be necessary, but an update or PR that references #1197, #1211, and the separate Course/Notebook sources would still be useful because the runnable material currently retains the old calls.