Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning situation: UserWarning: max_length is ignored when padding=True" #13829

Merged
merged 4 commits into from Oct 1, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/transformers/tokenization_utils_base.py
Expand Up @@ -2223,8 +2223,10 @@ def _get_padding_truncation_strategies(
elif padding is not False:
if padding is True:
if verbose:
if max_length is not None:
warnings.warn("`max_length` is ignored when `padding`=`True`.")
if max_length is not None and (truncation is False or truncation == "do_not_truncate"):
warnings.warn(
"`max_length` is ignored when `padding`=`True` and `truncation` is False or `do_not_truncate`."
shirayu marked this conversation as resolved.
Show resolved Hide resolved
)
if old_pad_to_max_length is not False:
warnings.warn("Though `pad_to_max_length` = `True`, it is ignored because `padding`=`True`.")
padding_strategy = PaddingStrategy.LONGEST # Default to pad to the longest sequence in the batch
Expand Down