Skip to content

Commit

Permalink
fix max_pos_embeddings error (huggingface#1478)
Browse files Browse the repository at this point in the history
* fix max_pos_embeddings error

* fix lint

---------

Co-authored-by: Adam Louly <[email protected]@orttrainingdev9.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net>
  • Loading branch information
AdamLouly and Adam Louly committed Oct 24, 2023
1 parent 15b8d1e commit 0b22218
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions examples/onnxruntime/training/language-modeling/run_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,20 @@ def tokenize_function(examples):
remove_columns=column_names,
)

if hasattr(config, "max_position_embeddings"):
max_pos_embeddings = config.max_position_embeddings
else:
# Define a default value if the attribute is missing in the config.
max_pos_embeddings = 1024

if data_args.block_size is None:
block_size = tokenizer.model_max_length
if block_size > config.max_position_embeddings:
if block_size > max_pos_embeddings:
logger.warning(
f"The tokenizer picked seems to have a very large `model_max_length` ({tokenizer.model_max_length}). "
f"Using block_size={min(1024, config.max_position_embeddings)} instead. You can change that default value by passing --block_size xxx."
f"Using block_size={min(1024, max_pos_embeddings)} instead. You can change that default value by passing --block_size xxx."
)
block_size = min(1024, config.max_position_embeddings)
block_size = min(1024, max_pos_embeddings)
else:
if data_args.block_size > tokenizer.model_max_length:
logger.warning(
Expand Down

0 comments on commit 0b22218

Please sign in to comment.