# Modify HF model for training

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodify-hf-model-for-training%2F66729%3E%5C
**Category:** Intermediate\
**Created:** [December 22, 2023, 11:02am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodify-hf-model-for-training%2F66729 "2023-12-22T11:02:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![IanBestFellow](https://avatars.discourse-cdn.com/v4/letter/i/ecccb3/32.png) [@IanBestFellow](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FIanBestFellow)%5C
**Post date:** [December 22, 2023, 11:02am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodify-hf-model-for-training%2F66729%2F1 "2023-12-22T11:02:17Z")

</div>

Hello!  
As a beginner,I have a question.  
I want to modify the forward part of T5ForConditionalGeneration for my research.  
However, I don’t know how to modified it and Trainer for training.  
Can you please guide me on how to modify Seq2SeqTrainer and T5ForConditionalGeneration for training?  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![msthil2](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@msthil2](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmsthil2)%5C
**Post date:** [December 22, 2023, 6:11pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodify-hf-model-for-training%2F66729%2F2 "2023-12-22T18:11:11Z")

</div>

So as far as I know, you can change the T5ForConditionalGeneration class attributes if that does the job for you. Otherwise, you might have to bite the bullet and maybe create your own class. I guess it depends on what you want to change in the forward pass. If it’s involved, probably have to create your own class I think though.

For reference, this is the source code of the T5ForConditionalGeneration:

> <https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/modeling_t5.py>
