Getting warning message on creation of WeightedLossTrainer object

I am getting a warning when I create a WeightedLossTrainer object as follows:

/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/accelerate/accelerator.py:432: FutureWarning: Passing the following arguments to Accelerator is deprecated and will be removed in version 1.0 of Accelerate: dict_keys([‘dispatch_batches’, ‘split_batches’, ‘even_batches’, ‘use_seedable_sampler’]). Please pass an accelerate.DataLoaderConfiguration instead:
dataloader_config = DataLoaderConfiguration(dispatch_batches=None, split_batches=False, even_batches=True, use_seedable_sampler=True)
warnings.warn(

Here is the code for creating the WeightedLossTrainer class:
“”"
class WeightedLossTrainer(Trainer):
def compute_loss(self, model, inputs, return_outputs=False):
#feed inputs to model and extract outputs
outputs = model(**inputs)
#extract logits
logits = outputs.get(“logits”)
#extract labels
labels = inputs.get(“labels”)
#define loss function with class weights
loss_func = nn.CrossEntropyLoss(weight=class_weights)
#compute loss
loss = loss_func(logits, labels)

return (loss, outputs) if return_outputs else loss

“”"

I get the warning message on creation of the object with the below code:
“”"
trainer = WeightedLossTrainer(model=model,
args=training_args,
compute_metrics=compute_metrics,
train_dataset=tokenized_medication_datasets[‘train’],
eval_dataset=tokenized_medication_datasets[‘validation’],
data_collator=data_collator,
tokenizer=tokenizer)
“”"

I am not using Accelerator object anywhere in the existing code for a TextClassification traning.

4 Likes

feels like it some legacy code inside trainer itself. I have the same error message with DPOTrainer, though I am not using accelerator directly within my code.