# Generation utils for pytorch transformers

**URL:** <https://discuss.huggingface.co/t/generation-utils-for-pytorch-transformers/33676>\
**Category:** 🤗Transformers\
**Created:** [March 13, 2023, 7:38am UTC](https://discuss.huggingface.co/t/generation-utils-for-pytorch-transformers/33676 "2023-03-13T07:38:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sachin/32/26534_2.png) [@sachin](https://discuss.huggingface.co/u/sachin)\
**Post date:** [March 13, 2023, 7:38am UTC](https://discuss.huggingface.co/t/generation-utils-for-pytorch-transformers/33676/1 "2023-03-13T07:38:28Z")

</div>

Hello,  
I have a encoder-decoder transformer model using normal pytorch functions (`nn.TransformerEncoder, nn.TransformerDecoder`) which I have managed to train. I am hoping to using huggingface’s implementation of beam search with this model.

So the question is, is there a way to add the generation utilities mentioned here: [Generation](https://huggingface.co/docs/transformers/v4.26.1/en/main_classes/text_generation). If not, is what is the equivalent of using Huggingface’s `nn.TransformerEncoder, nn.TransformerEncoderLayer, nn.TransformerDecoder, nn.TransformerDecoderLayer` **so that I can use the generate function** via huggingface transformers instead.

---

<div class="post-metadata">

**Author:** ![dnathani](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dnathani](https://discuss.huggingface.co/u/dnathani)\
**Post date:** [April 1, 2023, 6:39am UTC](https://discuss.huggingface.co/t/generation-utils-for-pytorch-transformers/33676/2 "2023-04-01T06:39:49Z")

</div>

> [@sachin](#):
>
> TransformerDecoder

I am looking for something similar. Were you able to find a solution for this?
