I could not able to use save_pretrained on my T5 Model
I have fine tuned T5 model on a task and i am trying to save the model usingsave_pretrainedmethod available for huggingface Model  but i could not able to do so .image789×323 18.2 KBcan some say what is the error ?
2021-10-24T11:27:44Z
What isT5Finetuner? That is not a Transformers model.
2021-10-25T03:09:44Z
its just a class in pytorch.BramVanroy:What isT5Finetuner? That is not a Transformers model.class T5FineTuner(nn.Module):
    def __init__(self,model,tokenizer):
        super(T5FineTuner, self).__init__()
        self.t5 = model
        self.tokenizer = tokenizer
        
    def forward(self,input_ids, attention_mask=None, decoder_input_ids=None, decoder_attention_mask=None, lm_labels=None):
        outputs = self.t5(
            input_ids=input_ids,
            attention_mask=attention_mask,
            decoder_input_ids = decoder_input_ids,
            decoder_attention_mask=decoder_attention_mask,
            labels=lm_labels,
        )
        return outputsModel is created using this class!
2021-10-25T10:20:23Z
The class seems pointless because it doesn’t add functionality on top of T5 as currently written. You could have just used T5 as-is.save_pretrainedis part of HF subclassed models, not of PyTorch’s nn.Module’s.Either don’t use this class and just finetune the given T5 model. Or instead of subclassing nn.Module, subclasstransformers.PreTrainedModel.