# Issue with max\_length

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-max-length%2F1265%3E%5C
**Category:** 🤗Transformers\
**Created:** [September 26, 2020, 10:04pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-max-length%2F1265 "2020-09-26T22:04:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![polakowo](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@polakowo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fpolakowo)%5C
**Post date:** [September 26, 2020, 10:04pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-max-length%2F1265%2F1 "2020-09-26T22:04:06Z")

</div>

I’m using a text generation pipeline to generate text after some prompt. My chatbot requires me to have a prompt of say 64 tokens and to generate a maximum length of 32 tokens. If I set `max_length=32` it tells me “The context has 64 number of tokens, but `max_length` is only 32.” If I set `max_length=32+64`, it generates 96 tokens on top of my context, so in total 64+96=160 tokens. How can I generate only 32 tokens on top of my prompt?

---

<div class="post-metadata">

**Author:** ![zanderbush](https://avatars.discourse-cdn.com/v4/letter/z/13edae/32.png) [@zanderbush](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fzanderbush)%5C
**Post date:** [September 27, 2020, 4:12am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-max-length%2F1265%2F2 "2020-09-27T04:12:18Z")

</div>

length = len(prompt)  
max\_length = 32 + length
