Saving a model and loading it

So I am using this to get the model
model = T5ForConditionalGeneration.from_pretrained(“t5-small”)

then I try to save the model using
model.save_pretrained(“/home/myname/Desktop/”, from_pt=True)

And I get the these files: config.json, pytorch_model.bin

next i try to load the model using
model = T5ForConditionalGeneration.from_pretrained(“config.json”)

and i get the error:
OSError: Unable to load weights from pytorch checkpoint file for ‘config.json’ at ‘config.json’. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

What am I doing wrong? Am i supposed to do something with the pytorch_model.bin file ?

Hi Samuel, you need to pass the folder with all the exported files to load the model. For example:

from transformers import T5ForConditionalGeneration

model = T5ForConditionalGeneration.from_pretrained("t5-small")

model.save_pretrained("/home/my_name/Desktop/t5small", from_pt=True) 

And then, you can load the model:

model = T5ForConditionalGeneration.from_pretrained("/home/my_name/Desktop/t5small")

Thank you so much!! This caused me so much frustration! haha