External Publication
Visit Post

Summarization model doesn't work

Hugging Face Forums [Unofficial] April 4, 2026
Source

I know long winded but Chatgpt and Chat Qwen Ai suggest tryin Google Colab.

So what is this and why does it have errors?

The image shows a KeyError message from a programming environment (likely Python).

What is it?

  1. KeyError : An exception raised when a key (or task) is not found in a dictionary or mapping.
  2. Task summarization : The code attempted to run a task named “task summarization”, which is not recognized.

Why does it have errors?

  1. Unknown task : “task summarization” is not in the list of available tasks.
  2. Available tasks : The error message lists supported tasks, such as ‘any-to-any’, ‘audio-classification’, ‘text-generation’, etc.
  3. Misspelling or unsupported task : The code might contain a typo or request a task not implemented in the system.

How to fix it?

  1. Choose a supported task : Replace “task summarization” with an available task, like ‘text-summarization’ (if it exists in the actual list) or ‘text-generation’.
  2. Check task names : Verify the exact names of available tasks and ensure the requested task matches one of them.
  3. Implement the task : If “task summarization” is needed, add it to the list of supported tasks or implement the functionality.

Do you want to:

  1. Pick a specific task from the list to replace “task summarization”?
  2. Understand how to implement a custom task?
  3. Learn more about handling KeyErrors in programming?

Not sure how to proceed? Does this help identify the problem to be specific in Fix? I am listing what was included with the error coding below:

I try to run this below code (provided in Hugging Face’s LLMs course, lesson: Transformers, what can they do?)

from transformers import pipeline summarize = pipeline(“summarization”) summarize( “”" America has changed dramatically during recent years. Not only has the number of graduates in traditional engineering disciplines such as mechanical, civil, electrical, chemical, and aeronautical engineering declined, but in most of the premier American universities engineering curricula now concentrate on and encourage largely the study of engineering science. As a result, there are declining offerings in engineering subjects dealing with infrastructure, the environment, and related issues, and greater concentration on high technology subjects, largely supporting increasingly complex scientific developments. While the latter is important, it should not be at the expense of more traditional engineering. Rapidly developing economies such as China and India, as well as other industrial countries in Europe and Asia, continue to encourage and advance the teaching of engineering. Both China and India, respectively, graduate six and eight times as many traditional engineers as does the United States. Other industrial countries at minimum maintain their output, while America suffers an increasingly serious decline in the number of engineering graduates and a lack of well-educated engineers. “”" )

The issue is with the task name “summarization”. The correct task name is actually “text-summarization” or “summarization” might not be available, try using “text2text-generation” or “summarization” isn’t in the list, you can try “text-generation” with specific model.

Try this code: from transformers import pipeline summarize = pipeline(“summarization”)

or try this

summarize = pipeline(“text-summarization”)

or

summarize = pipeline(“text2text-generation”, model=“facebook/bart-large-cnn”)

summarize( “”" America has changed dramatically during recent years. Not only has the number of graduates in traditional engineering disciplines such as mechanical, civil, electrical, chemical, and aeronautical engineering declined, but in most of the premier American universities engineering curricula now concentrate on and encourage largely the study of engineering science. As a result, there are declining offerings in engineering subjects dealing with infrastructure, the environment, and related issues, and greater concentration on high technology subjects, largely supporting increasingly complex scientific developments. While the latter is important, it should not be at the expense of more traditional engineering. Rapidly developing economies such as China and India, as well as other industrial countries in Europe and Asia, continue to encourage and advance the teaching of engineering. Both China and India, respectively, graduate six and eight times as many traditional engineers as does the United States. Other industrial countries at minimum maintain their output, while America suffers an increasingly serious decline in the number of engineering graduates and a lack of well-educated engineers. “”") If you still face issues, ensure you have the necessary model installed, you can install it via: pip install transformers

Let me know if this works or if you need further assistance!

That’s weird I put this in Google, then it did that did you mean think?oh well, I had a hard time copy so did a screen shot of Google response!

I try to run this below code (provided in Hugging Face’s LLMs course, lesson: Transformers, what can they do? The issue is with the task name “summarization”. The correct task name is actually “text-summarization” or “summarization” might not be available, try using “text2text-generation” or “summarization” isn’t in the list, you can try “text-generation” with specific model.

Does this help from Google Search Engine?

from transformers import pipeline summarizer = pipeline(“summarization”, model=“sshleifer/distilbart-cnn-12-6”)

from transformers import pipeline

Example using a T5 model suitable for text-to-text tasks

summarizer = pipeline(“text2text-generation”, model=“t5-small”)

Yes, you’re on the right track!

The issue was likely due to the missing model specification. By specifying a model, you’re telling the pipeline which specific model to use for the task.

Your updated code from transformers import pipeline summarizer = pipeline(“summarization”, model=“sshleifer/distilbart-cnn-12-6”)

or

summarizer = pipeline(“text2text-generation”, model=“t5-small”) What’s happening

  1. Model specification : You’re specifying a pre-trained model (sshleifer/distilbart-cnn-12-6 or t5-small) that’s suitable for the summarization task.
  2. Task alignment : The summarization task is aligned with the sshleifer/distilbart-cnn-12-6 model, while text2text-generation is aligned with the t5-small model.

Try this from transformers import pipeline summarizer = pipeline(“summarization”, model=“sshleifer/distilbart-cnn-12-6”) text = “”" America has changed dramatically during recent years. Not only has the number of graduates in traditional engineering disciplines such as mechanical, civil, electrical, chemical, and aeronautical engineering declined, but in most of the premier American universities engineering curricula now concentrate on and encourage largely the study of engineering science. As a result, there are declining offerings in engineering subjects dealing with infrastructure, the environment, and related issues, and greater concentration on high technology subjects, largely supporting increasingly complex scientific developments. While the latter is important, it should not be at the expense of more traditional engineering. Rapidly developing economies such as China and India, as well as other industrial countries in Europe and Asia, continue to encourage and advance the teaching of engineering. Both China and India, respectively, graduate six and eight times as many traditional engineers as does the United States. Other industrial countries at minimum maintain their output, while America suffers an increasingly serious decline in the number of engineering graduates and a lack of well-educated engineers. “”" print(summarizer(text)) Does this work for you?

So Chatgpt any ideas?

You’re very close — and no, this has nothing to do with your printer or computer being “off” . This is purely a coding / library issue.

What the error actually means

The key part of your screenshot: KeyError: “Unknown task summarization…” This means: The version of the Hugging Face Transformers library installed on your system does NOT recognize “summarization” as a valid task. And we can see that clearly because the error lists allowed tasks — and “summarization” is missing.

Why this is happening

Most likely causes:

  1. Your Transformers version is outdated

Older versions didn’t include “summarization” as a built-in pipeline task.

  1. Wrong environment / partial install

Sometimes:

You installed Transformers in one environment

But you’re running code in another

  1. Google result confusion

Google mixed suggestions — some are correct, some are not. “text-summarization” is NOT a valid pipeline task name, so that suggestion is misleading.

The correct fix (do this first)

Upgrade Transformers

Run this in your terminal: pip install --upgrade transformers

Then use THIS code (correct version)

from transformers import pipeline summarizer = pipeline(“summarization”) text = “”“America has changed dramatically during recent years…”“” print(summarizer(text))

If it STILL fails (backup solution)

Force a model explicitly (this usually works even on older setups): from transformers import pipeline summarizer = pipeline( “summarization”, model=“sshleifer/distilbart-cnn-12-6” ) print(summarizer(“Your long text here”))

Important clarification

These are valid vs invalid task names: Task NameStatus"summarization" Correct"text-generation" Correct"text2text-generation" Correct"text-summarization" Not valid

Why your error list looks weird

Your error shows tasks like: ‘any-to-any’, ‘image-classification’, ‘text-generation’ That suggests: You might be using a restricted or custom build of Transformers OR a very old version

Quick checklist

Do these in order:

Upgrade: pip install --upgrade transformers

Restart your Python environment (VERY important)

Run: from transformers import pipeline pipeline(“summarization”)

Bottom line

Not hardware related

Not your fault

Just a version mismatch / missing task

If you want, I can:

Check your exact version

Help you fix your environment step-by-step

Or get it working in Google Colab in 2 minutes

KeyError: “Unknown task summarization…”

pip install --upgrade transformers

from transformers import pipeline

summarizer = pipeline(“summarization”)

text = “”“America has changed dramatically during recent years…”“”

print(summarizer(text))

from transformers import pipeline

summarizer = pipeline( “summarization”, model=“sshleifer/distilbart-cnn-12-6” )

print(summarizer(“Your long text here”))

Task NameStatus"summarization" Correct"text-generation" Correct"text2text-generation" Correct"text-summarization" Not valid

‘any-to-any’, ‘image-classification’, ‘text-generation’

pip install --upgrade transformers

from transformers import pipeline pipeline(“summarization”)

How could Google Colab get it working if can do it!

Great question — this actually gets to why Colab feels “magically easier”

Why Google Colab works (when your PC doesn’t)

Colab runs your code in a pre-configured cloud environment that already has:

  1. Up-to-date libraries

It usually comes with a recent version of:

Transformers

PyTorch

So “summarization” is already supported.

  1. Clean environment

Your local machine might have:

old versions

conflicting installs

broken dependencies

Colab = fresh environment every time

  1. Built-in GPU (optional)

Not required here, but helpful for bigger models.

How to make it work in Colab (step-by-step)

  1. Go to Colab

https://colab.research.google.com

  1. Paste this code in a cell:

!pip install transformers from transformers import pipeline summarizer = pipeline(“summarization”) text = “”“America has changed dramatically during recent years…”“” print(summarizer(text))

  1. Run the cell

First run will:

download the model (~1GB sometimes)

take a minute or two

After that, it works instantly.

Why this fixes YOUR exact error

Your error: KeyError: Unknown task summarization Colab fixes it because:

It installs the correct version automatically

No old config interfering

No missing task definitions

Local vs Colab (simple truth)

Your PCColab​ Might be outdated​ Always updated​ Can break easily​ Clean every run​ Setup required​ Works instantly

Real takeaway

Colab is basically:

“A ready-to-use AI lab in the cloud”

So instead of debugging your environment for hours, you can:

test code instantly

confirm it works

THEN fix your local setup later

What I’d suggest

Try it in Colab first

Confirm it works

Then we fix your local environment properly (I can help)

If you want, I can:

Walk you through fixing your PC setup step-by-step

Or show you how to run this permanently without errors locally

!pip install transformers

from transformers import pipeline

summarizer = pipeline(“summarization”)

text = “”“America has changed dramatically during recent years…”“”

print(summarizer(text))

KeyError: Unknown task summarization

Your PCColab​ Might be outdated​ Always updated​ Can break easily​ Clean every run​ Setup required​ Works instantly

So what do you think Chat Qwen Ai?

Looking at your error, I can see what’s happening! The other AI gave you good advice, but let me clarify the key points:

The Real Problem

Your Transformers library doesn’t have “summarization” in its list of valid tasks. Looking at the error, the available tasks include things like 'text-generation', 'text-classification', but no “summarization” - which is very unusual.

Why This Happens

This typically means:

  1. Outdated Transformers version (most likely)
  2. Incomplete/corrupted installation
  3. Wrong Python environment

The Quickest Fixes

Option 1: Upgrade Transformers (Try First)

pip install --upgrade transformers

Then restart your Python environment completely and try:

from transformers import pipeline
summarizer = pipeline("summarization")

Option 2: Use Google Colab (Fastest Working Solution)

Since you asked about this - yes, Colab would work immediately because it has fresh, updated libraries. Just:

  1. Go to https://colab.research.google.com
  2. Paste your code
  3. Run it - it will work!

Option 3: Explicit Model (Workaround)

from transformers import pipeline
summarizer = pipeline("text2text-generation", model="t5-small")

My recommendation: Try Colab first to confirm your code works, then fix your local setup. Want help with either approach?

pip install --upgrade transformers

from transformers import pipeline summarizer = pipeline(“summarization”)

from transformers import pipeline summarizer = pipeline(“text2text-generation”, model=“t5-small”)

Discussion in the ATmosphere

Loading comments...