Skip to content

Backwards compatability support for passing in transformers.TrainingArguments to SFTTrainer args #1711

Description

@anhuong

Due to the change that added in SFTConfig, for the parameter in SFTTrainer.args, this broke previous behavior that allowed passing transformers.TrainingArguments into SFTTrainer.args. This was tried to be fixed by this commit a few hours ago, however the full set of TrainingArguments has many more parameters than SFTConfig. Thus converting TrainingArguments to a dictionary is insufficient.

Currently this is resulting in error: TypeError: SFTConfig.__init__() got an unexpected keyword argument 'cache_dir' because TrainingArguments has a field for cache_dir but SFTConfig does not.

Previously I ran with:

trainer = SFTTrainer(
         model=model,
         tokenizer=tokenizer,
         train_dataset=formatted_train_dataset,
         eval_dataset=formatted_validation_dataset,
         packing=packing,
         data_collator=data_collator,
         dataset_text_field=data_args.dataset_text_field,
         args=transformers.TrainingArguments,
         max_seq_length=max_seq_length,
         callbacks=trainer_callbacks,
         peft_config=peft_config,
     )

Since SFTTrainer is built from/inherits transformers.Trainer, these training argument configurations are important and used. Perhaps SFTConfig should also inherit from transformers.TrainingArguments?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions