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

[run_clm] clarify why we get the tokenizer warning on long input #11145

Merged
merged 4 commits into from
Apr 8, 2021
Merged
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion examples/language-modeling/run_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
default_data_collator,
set_seed,
)
from transformers.testing_utils import CaptureLogger
from transformers.trainer_utils import get_last_checkpoint, is_main_process
from transformers.utils import check_min_version

Expand Down Expand Up @@ -317,7 +318,13 @@ def main():
text_column_name = "text" if "text" in column_names else column_names[0]

def tokenize_function(examples):
return tokenizer(examples[text_column_name])
tok_logger = transformers.utils.logging.get_logger("transformers.tokenization_utils_base")
with CaptureLogger(tok_logger) as cl:
output = tokenizer(examples[text_column_name])
# clm input could be much much longer than block_size
if "Token indices sequence length is longer than the" in cl.out:
tok_logger.warning("^^^^^^^^^^^^^^^^ Please ignore the warning above - it's just a long input")
stas00 marked this conversation as resolved.
Show resolved Hide resolved
return output

tokenized_datasets = datasets.map(
tokenize_function,
Expand Down