Supress long sequence tokenization warning
## ❓ Questions & Help

<!-- A clear and concise description of the question. -->

While tokenizing some sequences longer than 512 i get this error. I am aware that bert can't handle sequences longer than 512 so i split it later.

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

Is there a way to supress this warning?
This is simply a warning, it won't change your results. I think it's important we keep it for people that are unaware that sequences have a max length of 512, so there's currently no option to suppress that warning.<|||||>Just a note: if you want to avoid displaying the warning, you can raise the level of the logger with `logging.getLogger("pytorch_pretrained_bert.tokenization").setLevel(logging.ERROR)`.

We did that in the  Transfer Learning tutorial code (see [here](https://github.com/huggingface/naacl_transfer_learning_tutorial/blob/master/utils.py#L134))

This will avoid display all the logging message under the error level though, so use it with care ;-)<|||||>> Just a note: if you want to avoid displaying the warning, you can raise the level of the logger with `logging.getLogger("pytorch_pretrained_bert.tokenization").setLevel(logging.ERROR)`.
> 
> We did that in the Transfer Learning tutorial code (see [here](https://github.com/huggingface/naacl_transfer_learning_tutorial/blob/master/utils.py#L134))
> 
> This will avoid display all the logging message under the error level though, so use it with care ;-)

Just a small fix. Because the names have changed, use this instead:
`logging.getLogger("pytorch_transformers.tokenization_utils").setLevel(logging.ERROR)`<|||||>I encountered this problem too. As of Oct. 16, 2019, the correct way to suppress warning is:
`logging.getLogger("transformers.tokenization_utils").setLevel(logging.ERROR)`<|||||>I'm not sure from which version, but the above doesn't work anymore.
If any one stumbles on the same problem, try this:
`logging.getLogger("transformers.tokenization_utils_base").setLevel(logging.ERROR)`<|||||>See the global solution here: https://github.com/huggingface/transformers/issues/3050#issuecomment-682167272<|||||>from transformers.utils import logging
logging.set_verbosity(40)

This will set your logger to only display Errors (no warnings).

See more here -> https://huggingface.co/docs/transformers/main_classes/logging