{
  "id": "huggingface/generate-max-new-tokens-overlap",
  "signature": "ValueError: The combination of parameters `max_new_tokens` and `max_length` is ambiguous. Please set only one of them.",
  "signature_zh": "ValueError：参数 `max_new_tokens` 和 `max_length` 的组合不明确。请仅设置其中一个。",
  "regex": "The combination of parameters `max_new_tokens` and `max_length` is ambiguous",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Both `max_new_tokens` and `max_length` were provided to `model.generate()`, creating conflicting constraints on the output length.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 `model.generate()` 中同时提供了 `max_new_tokens` 和 `max_length`，对输出长度产生了冲突的约束。",
  "versions": [
    {
      "version": "transformers>=4.25.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is about having both parameters set at all, not about their values. The validation checks for the presence of both, regardless of equality.",
      "fail_rate": 0.99,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "`max_time` is a separate constraint and does not resolve the conflict between `max_new_tokens` and `max_length`. The validation error still occurs.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove one of the conflicting parameters. If you want to limit total sequence length, use `max_length=512`. If you want to limit only new tokens generated, use `max_new_tokens=128`. Example: `model.generate(inputs, max_new_tokens=128)`",
      "success_rate": 0.95,
      "how": "Remove one of the conflicting parameters. If you want to limit total sequence length, use `max_length=512`. If you want to limit only new tokens generated, use `max_new_tokens=128`. Example: `model.generate(inputs, max_new_tokens=128)`",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a pipeline, pass only one of the parameters in `pipeline(text, max_new_tokens=128)` and ensure `max_length` is not set in `model.config` or generation config.",
      "success_rate": 0.9,
      "how": "If using a pipeline, pass only one of the parameters in `pipeline(text, max_new_tokens=128)` and ensure `max_length` is not set in `model.config` or generation config.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "移除其中一个冲突的参数。如果要限制总序列长度，使用 `max_length=512`。如果只想限制新生成的 token 数量，使用 `max_new_tokens=128`。示例：`model.generate(inputs, max_new_tokens=128)`",
    "如果使用 pipeline，在 `pipeline(text, max_new_tokens=128)` 中仅传递其中一个参数，并确保 `model.config` 或 generation config 中没有设置 `max_length`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/transformers/v4.35.0/en/main_classes/text_generation#transformers.GenerationConfig.max_new_tokens",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}