Trainer.save_pretrained(modeldir) AttributeError: 'Trainer' object has no attribute 'save_pretrained'

I am trying to save a model during finetuning but I get this error ?

trainer, outdir = prepare_fine_tuning(PRE_TRAINED_MODEL_NAME, train_dataset, val_dataset, tokenizer, sigle, train_name, elt_train.name)

trainer.train()
trainer.evaluate()						
						
#trainer.save_model(modeldir)
trainer.save_pretrained(modeldir)
tokenizer.save_pretrained(modeldir)
					
 trainer.save_pretrained(modeldir)
AttributeError: 'Trainer' object has no attribute 'save_pretrained'

Transformers version 4.8.0

I don’t knoe where you read that code, but Trainer does not have a save_pretrained method. Checkout the documentaiton for a list of its methods!

1 Like