# Truncating sequence -- within a pipeline

**URL:** <https://discuss.huggingface.co/t/truncating-sequence-within-a-pipeline/336>\
**Category:** Beginners\
**Created:** [July 16, 2020, 11:25pm UTC](https://discuss.huggingface.co/t/truncating-sequence-within-a-pipeline/336 "2020-07-16T23:25:18Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![AlanFeder](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@AlanFeder](https://discuss.huggingface.co/u/AlanFeder)\
**Post date:** [July 16, 2020, 11:25pm UTC](https://discuss.huggingface.co/t/truncating-sequence-within-a-pipeline/336/1 "2020-07-16T23:25:18Z")

</div>

Hi all,

Thanks for making this forum!

I have a list of tests, one of which apparently happens to be 516 tokens long. I have been using the feature-extraction pipeline to process the texts, just using the simple function:

```python
nlp = pipeline('feature-extraction')

```

When it gets up to the long text, I get an error:

```auto
Token indices sequence length is longer than the specified maximum sequence length for this model (516 > 512). Running this sequence through the model will result in indexing errors

```

Alternately, if I do the sentiment-analysis pipeline (created by `nlp2 = pipeline('sentiment-analysis')`, I did not get the error.

Is there a way for me put an argument in the `pipeline` function to make it truncate at the max model input length? I tried reading [this](https://huggingface.co/transformers/preprocessing.html#everything-you-always-wanted-to-know-about-padding-and-truncation), but I was not sure how to make everything else in `pipeline` the same/default, except for this truncation.

---

_[View the full topic](https://discuss.huggingface.co/t/truncating-sequence-within-a-pipeline/336)._
