# How do I setup a TextClassificationPipeline that truncates token sequences

**URL:** <https://discuss.huggingface.co/t/how-do-i-setup-a-textclassificationpipeline-that-truncates-token-sequences/10401>\
**Category:** Beginners\
**Created:** [September 29, 2021, 9:50pm UTC](https://discuss.huggingface.co/t/how-do-i-setup-a-textclassificationpipeline-that-truncates-token-sequences/10401 "2021-09-29T21:50:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drevicko](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@drevicko](https://discuss.huggingface.co/u/drevicko)\
**Post date:** [September 29, 2021, 9:50pm UTC](https://discuss.huggingface.co/t/how-do-i-setup-a-textclassificationpipeline-that-truncates-token-sequences/10401/1 "2021-09-29T21:50:40Z")

</div>

I’m using a TextClassificationPipeline from a pretrained model (“bhadresh-savani/roberta-base-emotion”), and I would like it to truncate inputs to the maximum token sequence length. This is not happening by default.

My code to set up the pipeline looks like this:

```
tokenizer = AutoTokenizer.from_pretrained("bhadresh-savani/roberta-base-emotion") # , inputs=
model = AutoModelForSequenceClassification.from_pretrained("bhadresh-savani/roberta-base-emotion")
classifier = TextClassificationPipeline(model=model, return_all_scores=True, tokenizer=tokenizer, device=0)
```
