# Changing Tokenizer's max\_length gets weird result

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchanging-tokenizers-max-length-gets-weird-result%2F18029%3E%5C
**Category:** Beginners\
**Created:** [May 17, 2022, 4:33am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchanging-tokenizers-max-length-gets-weird-result%2F18029 "2022-05-17T04:33:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mapraw](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Mapraw](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMapraw)%5C
**Post date:** [May 17, 2022, 4:33am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchanging-tokenizers-max-length-gets-weird-result%2F18029%2F1 "2022-05-17T04:33:06Z")

</div>

Hello, I try to tokenize the sentence with “bert-base-uncased” with 3 max\_length with these sentences " [‘I love it’, “You done”],[“Mary do”, “Dog eats paper”]" and it returns a lot of sentence with more max\_length than I set. Please, describe this phenomenon.

 ![not work](https://us1.discourse-cdn.com/hellohellohello/original/2X/7/74f0bc6ff3967322792485b8e85ae28b2c99103f.png)  
Please.

---

<div class="post-metadata">

**Author:** ![cog](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cog](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcog)%5C
**Post date:** [May 17, 2022, 6:45am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchanging-tokenizers-max-length-gets-weird-result%2F18029%2F3 "2022-05-17T06:45:12Z")

</div>

hi.  
if you use it without ‘return\_overflowing\_token’, return successfully truncated token.

Also, i tried your same code. if ‘return\_overflowing\_token = True’ exist, return Error code.  
Huggingface document say that

- **return\_overflowing\_tokens** ( `bool` , _optional_ , defaults to `False` ) — Whether or not to return overflowing token sequences. If a pair of sequences of input ids (or a batch of pairs) is provided with `truncation_strategy = longest_first` or `True` , an error is raised instead of returning overflowing tokens.

---

<div class="post-metadata">

**Author:** ![cog](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cog](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcog)%5C
**Post date:** [May 17, 2022, 6:45am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchanging-tokenizers-max-length-gets-weird-result%2F18029%2F4 "2022-05-17T06:45:41Z")

</div>

![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/1/18eece79b01d7bcff507a83ef51c2fe07c9a4777.png)
