{
  "id": "huggingface/generation-early-stopping-conflict",
  "signature": "ValueError: `early_stopping` is set to True but `num_beams` is 1. Early stopping has no effect without beam search.",
  "signature_zh": "ValueError: `early_stopping` 设置为 True，但 `num_beams` 为 1。没有 beam search 时，early stopping 无效。",
  "regex": "ValueError: `early_stopping` is set to True but `num_beams` is \\d+\\. Early stopping has no effect without beam search\\.",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The parameter `early_stopping` in Hugging Face's `generate()` method only applies when using beam search (num_beams > 1). Setting it with greedy or multinomial sampling has no effect and raises a ValueError to prevent silent misconfiguration.",
  "root_cause_type": "generic",
  "root_cause_zh": "Hugging Face 的 `generate()` 方法中的 `early_stopping` 参数仅在 beam search（num_beams > 1）时生效。在贪心或多模态采样中设置它无效，会引发 ValueError 以防止静默配置错误。",
  "versions": [
    {
      "version": "transformers>=4.28.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "torch>=1.12.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Setting `num_beams=1` and `early_stopping=False` silences the error but removes the benefit of early stopping when beam search is intended.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Setting `early_stopping='never'` (a string value) is deprecated and may cause a different error in newer versions.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set `num_beams` to a value greater than 1 to enable beam search and make `early_stopping` effective. For example: `model.generate(input_ids, num_beams=4, early_stopping=True)`.",
      "success_rate": 0.95,
      "how": "Set `num_beams` to a value greater than 1 to enable beam search and make `early_stopping` effective. For example: `model.generate(input_ids, num_beams=4, early_stopping=True)`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Remove `early_stopping` from the generation config if greedy decoding is intended. Use `do_sample=False` (default) instead.",
      "success_rate": 0.9,
      "how": "Remove `early_stopping` from the generation config if greedy decoding is intended. Use `do_sample=False` (default) instead.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Set `num_beams` to a value greater than 1 to enable beam search and make `early_stopping` effective. For example: `model.generate(input_ids, num_beams=4, early_stopping=True)`.",
    "Remove `early_stopping` from the generation config if greedy decoding is intended. Use `do_sample=False` (default) instead."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/transformers/main_classes/text_generation#transformers.GenerationConfig.early_stopping",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-07-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}