# How to separately use T5 decoder

**URL:** <https://discuss.huggingface.co/t/how-to-separately-use-t5-decoder/13536>\
**Category:** Models\
**Created:** [January 10, 2022, 10:24am UTC](https://discuss.huggingface.co/t/how-to-separately-use-t5-decoder/13536 "2022-01-10T10:24:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KKSAVETHEWORLD](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@KKSAVETHEWORLD](https://discuss.huggingface.co/u/KKSAVETHEWORLD)\
**Post date:** [January 10, 2022, 10:24am UTC](https://discuss.huggingface.co/t/how-to-separately-use-t5-decoder/13536/1 "2022-01-10T10:24:11Z")

</div>

I am working on a task in which I should modify the encoding results.  
what I would like to do is generally like this:

input\_ids = tokenizer(“i am trying hard!”, return\_tensors=‘pt’).input\_ids  
last\_hidden\_state=model.encoder(input\_ids=input\_ids).last\_hidden\_state  
modified\_last\_hidden\_state = modify(last\_hidden\_state)  
outputs = model.decoder(modified\_last\_hidden\_state)  
output\_sequence = tokenizer.decode(outputs)

I think this model.decoder() actually doesn’t work as I want.

---

<div class="post-metadata">

**Author:** ![KKSAVETHEWORLD](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@KKSAVETHEWORLD](https://discuss.huggingface.co/u/KKSAVETHEWORLD)\
**Post date:** [January 10, 2022, 11:31am UTC](https://discuss.huggingface.co/t/how-to-separately-use-t5-decoder/13536/2 "2022-01-10T11:31:12Z")

</div>

reply myself:  
I think this is a good try since the loss and hidden states are totally the same as the standard training process, and I will test the training process later.  
the separate process:

 ![Screenshot from 2022-01-10 12-27-07](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/d5785cd8711d066ac9e00e1fe612c3961317e44a.png)

---

<div class="post-metadata">

**Author:** ![nvishi7](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@nvishi7](https://discuss.huggingface.co/u/nvishi7)\
**Post date:** [April 5, 2023, 10:30am UTC](https://discuss.huggingface.co/t/how-to-separately-use-t5-decoder/13536/3 "2023-04-05T10:30:51Z")

</div>

Have you found something in this???  
Even I want to use an encoder and decoder separately.  
My task involves passing the tokenized input ids to the encoder and get the last\_hidden\_layer and then passing those embeddings to the decoder to get the tokens further decoding those tokens.

---

<div class="post-metadata">

**Author:** ![UserDAN](https://avatars.discourse-cdn.com/v4/letter/u/9fc29f/32.png) [@UserDAN](https://discuss.huggingface.co/u/UserDAN)\
**Post date:** [December 23, 2023, 7:47am UTC](https://discuss.huggingface.co/t/how-to-separately-use-t5-decoder/13536/4 "2023-12-23T07:47:42Z")

</div>

thank you for sharing

any update on this I mean dose it work like the standard way of fine tuning ?

---

<div class="post-metadata">

**Author:** ![daidv1112](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@daidv1112](https://discuss.huggingface.co/u/daidv1112)\
**Post date:** [July 7, 2024, 5:40am UTC](https://discuss.huggingface.co/t/how-to-separately-use-t5-decoder/13536/5 "2024-07-07T05:40:07Z")

</div>

Hi, is there any update on this?
