huggingface
config_error
ai_generated
true
ValueError: The task `text-generation` is not supported by the pipeline for this model. Supported tasks are: ['feature-extraction', 'fill-mask', 'sentence-similarity', 'text-classification'].
ID: huggingface/pipeline-task-unavailable
95%Fix Rate
90%Confidence
1Evidence
2023-11-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| transformers 4.36.0 | active | — | — | — |
| huggingface-hub 0.20.0 | active | — | — | — |
| Python 3.11 | active | — | — | — |
Root Cause
The pipeline is configured with a task that the model's architecture cannot perform, often because the model is an encoder-only type (e.g., BERT) but the task is decoder-only (e.g., text generation).
generic中文
pipeline配置的任务是模型架构无法执行的,通常因为模型是仅编码器类型(如BERT),但任务是仅解码器类型(如文本生成)。
Official Documentation
https://huggingface.co/docs/transformers/main_classes/pipelinesWorkarounds
-
95% success Use a model that supports the desired task. For text generation, use a decoder-only model like GPT-2: `pipeline('text-generation', model='gpt2')`. Check the model card on Hugging Face Hub for supported tasks.
Use a model that supports the desired task. For text generation, use a decoder-only model like GPT-2: `pipeline('text-generation', model='gpt2')`. Check the model card on Hugging Face Hub for supported tasks. -
90% success If you must use the current model, choose a supported task. For example, for BERT: `pipeline('text-classification', model='bert-base-uncased')`.
If you must use the current model, choose a supported task. For example, for BERT: `pipeline('text-classification', model='bert-base-uncased')`.
中文步骤
使用支持所需任务的模型。对于文本生成,使用仅解码器模型如GPT-2:`pipeline('text-generation', model='gpt2')`。在Hugging Face Hub上查看模型卡片以了解支持的任务。如果必须使用当前模型,选择支持的任务。例如,对于BERT:`pipeline('text-classification', model='bert-base-uncased')`。
Dead Ends
Common approaches that don't work:
-
95% fail
BERT is an encoder-only model; it lacks a language modeling head for generation, so forcing the task will cause runtime errors or produce gibberish.
-
70% fail
The error is about model-task compatibility, not library version; a newer version won't make BERT generate text.