# I could not able to use save\_pretrained on my T5 Model

**URL:** <https://discuss.huggingface.co/t/i-could-not-able-to-use-save-pretrained-on-my-t5-model/11022>\
**Category:** 🤗Transformers\
**Created:** [October 23, 2021, 6:16pm UTC](https://discuss.huggingface.co/t/i-could-not-able-to-use-save-pretrained-on-my-t5-model/11022 "2021-10-23T18:16:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vpkprasanna](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/vpkprasanna/32/26436_2.png) [@vpkprasanna](https://discuss.huggingface.co/u/vpkprasanna)\
**Post date:** [October 23, 2021, 6:16pm UTC](https://discuss.huggingface.co/t/i-could-not-able-to-use-save-pretrained-on-my-t5-model/11022/1 "2021-10-23T18:16:15Z")

</div>

I have fine tuned T5 model on a task and i am trying to save the model using **save\_pretrained** method available for huggingface Model but i could not able to do so .

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/1/1b12a6e4b301beb04b563c7d6ae53b62ada2edfb.png)  
can some say what is the error ?

---

<div class="post-metadata">

**Author:** ![BramVanroy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bramvanroy/32/47360_2.png) [@BramVanroy](https://discuss.huggingface.co/u/BramVanroy)\
**Post date:** [October 24, 2021, 11:27am UTC](https://discuss.huggingface.co/t/i-could-not-able-to-use-save-pretrained-on-my-t5-model/11022/2 "2021-10-24T11:27:44Z")

</div>

What is `T5Finetuner`? That is not a Transformers model.

---

<div class="post-metadata">

**Author:** ![vpkprasanna](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/vpkprasanna/32/26436_2.png) [@vpkprasanna](https://discuss.huggingface.co/u/vpkprasanna)\
**Post date:** [October 25, 2021, 3:09am UTC](https://discuss.huggingface.co/t/i-could-not-able-to-use-save-pretrained-on-my-t5-model/11022/3 "2021-10-25T03:09:44Z")

</div>

its just a class in pytorch.

> [@BramVanroy](#):
>
> What is `T5Finetuner`? That is not a Transformers model.

```auto
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 outputs

```

Model is created using this class!

---

<div class="post-metadata">

**Author:** ![BramVanroy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bramvanroy/32/47360_2.png) [@BramVanroy](https://discuss.huggingface.co/u/BramVanroy)\
**Post date:** [October 25, 2021, 10:20am UTC](https://discuss.huggingface.co/t/i-could-not-able-to-use-save-pretrained-on-my-t5-model/11022/4 "2021-10-25T10:20:23Z")

</div>

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_pretrained` is 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, subclass `transformers.PreTrainedModel`.
