Generate: ignore warning when generation_config.max_length is set to None (#26147)

This commit is contained in:
Joao Gante 2023-09-13 16:50:58 +01:00 committed by GitHub
parent a6ae2bd059
commit 86ffef87b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -389,7 +389,7 @@ class FlaxGenerationMixin:
UserWarning,
)
elif generation_config.max_new_tokens is not None:
if not has_default_max_length:
if not has_default_max_length and generation_config.max_length is not None:
logger.warning(
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(="
f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "

View File

@ -841,7 +841,7 @@ class TFGenerationMixin:
UserWarning,
)
elif generation_config.max_new_tokens is not None:
if not has_default_max_length:
if not has_default_max_length and generation_config.max_length is not None:
logger.warning(
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(="
f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "

View File

@ -1517,7 +1517,7 @@ class GenerationMixin:
input_ids_length = input_ids.shape[-1]
has_default_max_length = kwargs.get("max_length") is None and generation_config.max_length is not None
if generation_config.max_new_tokens is not None:
if not has_default_max_length:
if not has_default_max_length and generation_config.max_length is not None:
logger.warning(
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(="
f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "