# ValueError: repetition_penalty and no_repeat_ngram_size cannot be set simultaneously as they may conflict

- **ID:** `huggingface/generation-repetition-penalty-conflict`
- **Domain:** huggingface
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Both `repetition_penalty` and `no_repeat_ngram_size` are set in the generation config, but their combined effect can produce contradictory constraints on token selection.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| transformers>=4.35.0 | active | — | — |

## Workarounds

1. **Remove one of the conflicting parameters: `model.generate(input_ids, repetition_penalty=1.2)  # no no_repeat_ngram_size` or `model.generate(input_ids, no_repeat_ngram_size=3)  # no repetition_penalty`** (95% success)
   ```
   Remove one of the conflicting parameters: `model.generate(input_ids, repetition_penalty=1.2)  # no no_repeat_ngram_size` or `model.generate(input_ids, no_repeat_ngram_size=3)  # no repetition_penalty`
   ```
2. **Set the removed parameter to its default value explicitly: `model.generate(input_ids, repetition_penalty=1.0, no_repeat_ngram_size=0)`** (90% success)
   ```
   Set the removed parameter to its default value explicitly: `model.generate(input_ids, repetition_penalty=1.0, no_repeat_ngram_size=0)`
   ```
3. **Use a custom generation config that overrides the conflict check: `from transformers import GenerationConfig; config = GenerationConfig.from_pretrained('model-name', repetition_penalty=1.2, no_repeat_ngram_size=3, _from_model_config=True)` but this may cause undefined behavior.** (60% success)
   ```
   Use a custom generation config that overrides the conflict check: `from transformers import GenerationConfig; config = GenerationConfig.from_pretrained('model-name', repetition_penalty=1.2, no_repeat_ngram_size=3, _from_model_config=True)` but this may cause undefined behavior.
   ```

## Dead Ends

- **Setting both parameters to very low values (e.g., 0.1 and 1)** — The conflict check is boolean; any non-default values for both triggers the error, regardless of magnitude. (95% fail)
- **Ignoring the warning and proceeding with generation** — This is a ValueError, not a warning; it halts execution entirely. (100% fail)
- **Upgrading transformers to 4.40.0** — The conflict detection was introduced in 4.35.0; newer versions still enforce the rule. (80% fail)
