Skip to content

Commit

Permalink
fix: crash when output directory doesn't exist
Browse files Browse the repository at this point in the history
Signed-off-by: Harikrishnan Balagopal <[email protected]>
Signed-off-by: Mehant Kammakomati <[email protected]>
  • Loading branch information
HarikrishnanBalagopal authored and kmehant committed Oct 3, 2024
1 parent c59da48 commit 2e10f28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions tuning/sft_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ def main():
combined_tracker_configs.file_logger_config = file_logger_config
combined_tracker_configs.aim_config = aim_config

if model_args.output_dir:
os.makedirs(model_args.output_dir, exist_ok=True)
logger.info("using the output directory at %s", model_args.output_dir)
try:
trainer, additional_train_info = train(
model_args=model_args,
Expand Down
6 changes: 3 additions & 3 deletions tuning/utils/preprocessing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_data_collator(
max_seq_length: int,
tokens_field: str = True,
instruction_template: Optional[str] = None,
padding_free: str = None,
padding_free: Any = None,
) -> Callable:
"""Create and return the the appropriate collator type based on the configuration for packing,
response_template, and dataset_text_field.
Expand All @@ -187,7 +187,7 @@ def get_data_collator(
feature having tokens
instruction_template: Optional[str]
start of user answer.
padding_free: str
padding_free: Any
padding free method
Returns:
Expand Down Expand Up @@ -243,7 +243,7 @@ def get_data_collator(
return DataCollatorForSeq2Seq(
tokenizer=tokenizer, padding=True, max_length=max_seq_length
)
if padding_free:
if padding_free is not None and padding_free.method:
# when packing is false but padding_free is used and no response template is used
# then its a pretrained scenario.
return DataCollatorForSeq2Seq(
Expand Down

0 comments on commit 2e10f28

Please sign in to comment.