# ValueError: The combination of parameters `max_new_tokens` and `max_length` is ambiguous. Please set only one of them.

- **ID:** `huggingface/generate-max-new-tokens-overlap`
- **Domain:** huggingface
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

Both `max_new_tokens` and `max_length` were provided to `model.generate()`, creating conflicting constraints on the output length.

## Version Compatibility

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

## Workarounds

1. **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)`** (95% success)
   ```
   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)`
   ```
2. **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.** (90% success)
   ```
   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.
   ```

## Dead Ends

- **** — 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. (99% fail)
- **** — `max_time` is a separate constraint and does not resolve the conflict between `max_new_tokens` and `max_length`. The validation error still occurs. (95% fail)
