# How to use the generation\_utils.generate?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-use-the-generation-utils-generate%2F17277%3E%5C
**Category:** 🤗Transformers\
**Created:** [April 28, 2022, 9:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-use-the-generation-utils-generate%2F17277 "2022-04-28T09:16:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbietuan](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@newbietuan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnewbietuan)%5C
**Post date:** [April 28, 2022, 9:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-use-the-generation-utils-generate%2F17277%2F1 "2022-04-28T09:16:39Z")

</div>

i am doing image caption generation task，there are various implementation in different communities，which have their own improvements，i want to write a code that use the standard transformer structure，and i referenced the code in [The Annotated Transformer](http://nlp.seas.harvard.edu/2018/04/03/attention.html) ，  
now i should implement the beam\_search code for sequence generation，i noticed the transformer library has a implementation in the generation\_utils.generate, and there’s a lot document about text generation，but they are all pre-trained models and directly use the model.generate to generate sequence, but how should i use the generation\_utils.generate to generate caption on my own datasets based on the standard transformer structure? Is there any examples or tutorials that I can refer to？  
thanks a lot.
