{
  "id": "huggingface/pipeline-batch-size-mismatch",
  "signature": "ValueError: The batch size of the pipeline (8) does not match the batch size of the dataset (32). Please set batch_size=None or ensure they match.",
  "signature_zh": "ValueError：管道的批次大小(8)与数据集的批次大小(32)不匹配。请设置batch_size=None或确保它们匹配。",
  "regex": "ValueError: The batch size of the pipeline \\(\\d+\\) does not match the batch size of the dataset \\(\\d+\\). Please set batch_size=None or ensure they match.",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "When using pipeline with a dataset that has a predefined batch size (e.g., from map with batched=True), the pipeline's batch_size parameter conflicts with the dataset's batching.",
  "root_cause_type": "generic",
  "root_cause_zh": "当使用管道配合具有预定义批次大小的数据集（例如来自map with batched=True）时，管道的batch_size参数与数据集的批处理冲突。",
  "versions": [
    {
      "version": "transformers>=4.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "datasets>=2.14.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Manually setting pipeline batch_size to match dataset batch size (e.g., pipeline(..., batch_size=32))",
      "why_fails": "The pipeline may not support that batch size due to memory constraints, or the dataset's batching is internal and cannot be overridden, leading to the same error.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing batch_size from dataset.map() call",
      "why_fails": "If the dataset was loaded with batched=True, removing batch_size may break the dataset's structure or cause performance degradation, but the error might persist if the dataset object retains internal batching.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set pipeline batch_size to None to let the pipeline handle batching automatically: pipe = pipeline('text-classification', model=model, batch_size=None). This disables the conflicting parameter.",
      "success_rate": 0.95,
      "how": "Set pipeline batch_size to None to let the pipeline handle batching automatically: pipe = pipeline('text-classification', model=model, batch_size=None). This disables the conflicting parameter.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need a specific batch size, create a new dataset without batching: dataset = dataset.map(preprocess, batched=False) and then use pipeline with desired batch_size.",
      "success_rate": 0.85,
      "how": "If you need a specific batch size, create a new dataset without batching: dataset = dataset.map(preprocess, batched=False) and then use pipeline with desired batch_size.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Set pipeline batch_size to None to let the pipeline handle batching automatically: pipe = pipeline('text-classification', model=model, batch_size=None). This disables the conflicting parameter.",
    "If you need a specific batch size, create a new dataset without batching: dataset = dataset.map(preprocess, batched=False) and then use pipeline with desired batch_size."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/transformers/main_classes/pipelines#pipeline-batching",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}