# ValueError: `early_stopping` is set to True but `num_beams` is 1. Early stopping has no effect without beam search.

- **ID:** `huggingface/generation-early-stopping-conflict`
- **Domain:** huggingface
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| transformers>=4.28.0 | active | — | — |
| torch>=1.12.0 | active | — | — |

## Workarounds

1. **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)`.** (95% success)
   ```
   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)`.
   ```
2. **Remove `early_stopping` from the generation config if greedy decoding is intended. Use `do_sample=False` (default) instead.** (90% success)
   ```
   Remove `early_stopping` from the generation config if greedy decoding is intended. Use `do_sample=False` (default) instead.
   ```

## Dead Ends

- **** — Setting `num_beams=1` and `early_stopping=False` silences the error but removes the benefit of early stopping when beam search is intended. (30% fail)
- **** — Setting `early_stopping='never'` (a string value) is deprecated and may cause a different error in newer versions. (60% fail)
