# Issue with max\_length

**URL:** <https://discuss.huggingface.co/t/issue-with-max-length/1265>\
**Category:** 🤗Transformers\
**Created:** [September 26, 2020, 10:04pm UTC](https://discuss.huggingface.co/t/issue-with-max-length/1265 "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](https://discuss.huggingface.co/u/polakowo)\
**Post date:** [September 26, 2020, 10:04pm UTC](https://discuss.huggingface.co/t/issue-with-max-length/1265/1 "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](https://discuss.huggingface.co/u/zanderbush)\
**Post date:** [September 27, 2020, 4:12am UTC](https://discuss.huggingface.co/t/issue-with-max-length/1265/2 "2020-09-27T04:12:18Z")

</div>

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