{
  "id": "huggingface/transformers-generation-config-repeat-penalty-conflict",
  "signature": "ValueError: repetition_penalty and no_repeat_ngram_size cannot be set simultaneously as they may conflict.",
  "signature_zh": "ValueError: repetition_penalty 和 no_repeat_ngram_size 不能同时设置，因为它们可能会冲突。",
  "regex": "repetition_penalty and no_repeat_ngram_size cannot be set simultaneously",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Both repetition_penalty and no_repeat_ngram_size are set in generation config or passed to model.generate(), but they can produce contradictory effects on token selection.",
  "root_cause_type": "generic",
  "root_cause_zh": "在生成配置或 model.generate() 中同时设置了 repetition_penalty 和 no_repeat_ngram_size，但它们可能对 token 选择产生矛盾的效果。",
  "versions": [
    {
      "version": "transformers>=4.25.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Setting no_repeat_ngram_size=0 is valid but still triggers the conflict check; setting repetition_penalty=0.0 is invalid (must be >=1.0) and raises a different error.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error is raised before generation; silent catch will cause the generation to proceed with default values, potentially producing unwanted repetition.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The GenerationConfig itself raises this error during validation, so it will fail before any generation occurs.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove one of the parameters: use only `repetition_penalty=1.2` (typical range 1.0-2.0) to discourage repetition, or `no_repeat_ngram_size=3` to block n-gram repeats. Example: `model.generate(inputs, repetition_penalty=1.2)` or `model.generate(inputs, no_repeat_ngram_size=3)`",
      "success_rate": 0.95,
      "how": "Remove one of the parameters: use only `repetition_penalty=1.2` (typical range 1.0-2.0) to discourage repetition, or `no_repeat_ngram_size=3` to block n-gram repeats. Example: `model.generate(inputs, repetition_penalty=1.2)` or `model.generate(inputs, no_repeat_ngram_size=3)`",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need both effects, implement a custom repetition penalty that combines both strategies manually in a logits processor, then pass it via `model.generate(logits_processor=[...])`.",
      "success_rate": 0.8,
      "how": "If you need both effects, implement a custom repetition penalty that combines both strategies manually in a logits processor, then pass it via `model.generate(logits_processor=[...])`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check the generation config before calling: `if hasattr(model.generation_config, 'repetition_penalty') and model.generation_config.repetition_penalty is not None: model.generation_config.no_repeat_ngram_size = None`",
      "success_rate": 0.85,
      "how": "Check the generation config before calling: `if hasattr(model.generation_config, 'repetition_penalty') and model.generation_config.repetition_penalty is not None: model.generation_config.no_repeat_ngram_size = None`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Remove one of the parameters: use only `repetition_penalty=1.2` (typical range 1.0-2.0) to discourage repetition, or `no_repeat_ngram_size=3` to block n-gram repeats. Example: `model.generate(inputs, repetition_penalty=1.2)` or `model.generate(inputs, no_repeat_ngram_size=3)`",
    "If you need both effects, implement a custom repetition penalty that combines both strategies manually in a logits processor, then pass it via `model.generate(logits_processor=[...])`.",
    "Check the generation config before calling: `if hasattr(model.generation_config, 'repetition_penalty') and model.generation_config.repetition_penalty is not None: model.generation_config.no_repeat_ngram_size = None`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/transformers/en/main_classes/text_generation#transformers.GenerationConfig",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-07-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}