# Pipeline max\_length

**URL:** <https://discuss.huggingface.co/t/pipeline-max-length/74470>\
**Category:** 🤗Transformers\
**Created:** [February 23, 2024, 9:20am UTC](https://discuss.huggingface.co/t/pipeline-max-length/74470 "2024-02-23T09:20:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harshit-ranjan](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@harshit-ranjan](https://discuss.huggingface.co/u/harshit-ranjan)\
**Post date:** [February 23, 2024, 9:20am UTC](https://discuss.huggingface.co/t/pipeline-max-length/74470/1 "2024-02-23T09:20:45Z")

</div>

What does the max\_length argument in the pipeline function do?

```
    pipe = pipeline('text2text-generation', model=self.model, tokenizer=self.tokenizer)
    output = []

    for ele in dataset:
        pred = pipe(ele, max_length=1024)
        output.append({'input' : ele ,'output': pred[0]['generated_text']})

```

---

<div class="post-metadata">

**Author:** ![dgunzy](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@dgunzy](https://discuss.huggingface.co/u/dgunzy)\
**Post date:** [February 23, 2024, 1:09pm UTC](https://discuss.huggingface.co/t/pipeline-max-length/74470/2 "2024-02-23T13:09:36Z")

</div>

I think thats the max length in tokens the model can accept, could be wrong though.

---

<div class="post-metadata">

**Author:** ![RaushanTurganbay](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@RaushanTurganbay](https://discuss.huggingface.co/u/RaushanTurganbay)\
**Post date:** [February 23, 2024, 8:30pm UTC](https://discuss.huggingface.co/t/pipeline-max-length/74470/3 "2024-02-23T20:30:04Z")

</div>

Hi! The `max_length` here controls for maximum tokens that can be generated. The generation stops when we reach the maximum. Note that the model might generate incomplete sentences, if you specify `max_length` too short, by default it is 20 tokens.
