# Generation utils for pytorch transformers

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgeneration-utils-for-pytorch-transformers%2F33676%3E%5C
**Category:** 🤗Transformers\
**Created:** [March 13, 2023, 7:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgeneration-utils-for-pytorch-transformers%2F33676 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsachin)%5C
**Post date:** [March 13, 2023, 7:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgeneration-utils-for-pytorch-transformers%2F33676%2F1 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdnathani)%5C
**Post date:** [April 1, 2023, 6:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgeneration-utils-for-pytorch-transformers%2F33676%2F2 "2023-04-01T06:39:49Z")

</div>

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

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