# Pipeline max\_length

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipeline-max-length%2F74470%3E%5C
**Category:** 🤗Transformers\
**Created:** [February 23, 2024, 9:20am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipeline-max-length%2F74470 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fharshit-ranjan)%5C
**Post date:** [February 23, 2024, 9:20am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipeline-max-length%2F74470%2F1 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdgunzy)%5C
**Post date:** [February 23, 2024, 1:09pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipeline-max-length%2F74470%2F2 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRaushanTurganbay)%5C
**Post date:** [February 23, 2024, 8:30pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpipeline-max-length%2F74470%2F3 "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.
