Saving-Loading Model in Colab and Making Predictions

This may work I think:

After training I saved

trainer.save_model ("gdrive/My Drive/LOCATION")

Then, you can start a new session and running all previous code prior to the training, then running this:

model = AutoModelForSequenceClassification.from_pretrained("gdrive/My Drive/LOCATION", local_files_only=True)
trainer = Trainer(model=model)
trainer.model = model.cuda()
y = trainer.predict(small_eval_dataset)
3 Likes