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
2021-12-20T13:54:54Z
I don’t knoe where you read that code, butTrainerdoes not have asave_pretrainedmethod. Checkout thedocumentaitonfor a list of its methods!
2023-01-05T05:48:05Z
I got it in transformer/train.py too.Have you solved this problem?
2023-03-21T16:55:10Z
You can usetrainer.save_model("path_to_store_model_tokenizer")Load for later use:from transformers import AutoModelForTokenClassification

model = AutoModelForTokenClassification.from_pretrained("path_to_store_model_tokenizer")