Unverified Commit 86ffef87 authored by Joao Gante's avatar Joao Gante Committed by GitHub
Browse files

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

parent a6ae2bd0
...@@ -389,7 +389,7 @@ class FlaxGenerationMixin: ...@@ -389,7 +389,7 @@ class FlaxGenerationMixin:
UserWarning, UserWarning,
) )
elif generation_config.max_new_tokens is not None: 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( logger.warning(
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(=" 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. " f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "
......
...@@ -841,7 +841,7 @@ class TFGenerationMixin: ...@@ -841,7 +841,7 @@ class TFGenerationMixin:
UserWarning, UserWarning,
) )
elif generation_config.max_new_tokens is not None: 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( logger.warning(
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(=" 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. " f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "
......
...@@ -1517,7 +1517,7 @@ class GenerationMixin: ...@@ -1517,7 +1517,7 @@ class GenerationMixin:
input_ids_length = input_ids.shape[-1] 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 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 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( logger.warning(
f"Both `max_new_tokens` (={generation_config.max_new_tokens}) and `max_length`(=" 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. " f"{generation_config.max_length}) seem to have been set. `max_new_tokens` will take precedence. "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment