huggingface runtime_error ai_generated true

ValueError:此任务不支持分块推理。设置 `chunked_inference=False` 或使用兼容的任务,如 'text-generation'。

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

其他格式: JSON · Markdown 中文 · English
90%修复率
82%置信度
1证据数
2024-06-01首次发现

版本兼容性

版本状态引入弃用备注
transformers 4.45.0 active

根因分析

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

English

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

官方文档

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

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 100% 失败

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

  2. 20% 失败

    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.