huggingface runtime_error ai_generated true

ValueError: The pipeline does not support chunked inference for this task. Set `chunked_inference=False` or use a compatible task like 'text-generation'.

ID: huggingface/pipeline-task-chunked-inference-error

Also available as: JSON · Markdown · 中文
90%Fix Rate
82%Confidence
1Evidence
2024-06-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
transformers 4.45.0 active

Root Cause

User attempted to enable `chunked_inference=True` on a pipeline task (e.g., 'text-classification') that does not support chunked processing, because the task expects non-overlapping outputs per chunk.

generic

中文

用户尝试在不受支持的分块推理任务(如 'text-classification')上启用 `chunked_inference=True`,因为该任务期望每个分块输出不重叠。

Official Documentation

https://huggingface.co/docs/transformers/en/main_classes/pipelines#chunked-inference

Workarounds

  1. 95% success Set `chunked_inference=False` explicitly: `pipe = pipeline('text-classification', model='model-name', chunked_inference=False)`.
    Set `chunked_inference=False` explicitly: `pipe = pipeline('text-classification', model='model-name', chunked_inference=False)`.
  2. 85% success Manually implement chunking by splitting input text into batches and calling the pipeline in a loop without the `chunked_inference` parameter.
    Manually implement chunking by splitting input text into batches and calling the pipeline in a loop without the `chunked_inference` parameter.

中文步骤

  1. Set `chunked_inference=False` explicitly: `pipe = pipeline('text-classification', model='model-name', chunked_inference=False)`.
  2. Manually implement chunking by splitting input text into batches and calling the pipeline in a loop without the `chunked_inference` parameter.

Dead Ends

Common approaches that don't work:

  1. 100% fail

    The error is raised before any inference; try-except cannot bypass the validation check.

  2. 20% fail

    This is actually a valid workaround but not a direct fix for the parameter; the user might think setting `chunked_inference=True` is equivalent, but it's not.