3.0.1 BertTokenizer batch_encode_plus() shows warnings "Truncation was not explicitely activated but `max_length` is provided a specific value"
Author: githubrandomuser2017
Pull request: no

# 🐛 Bug

## Information


Model I am using (Bert, XLNet ...): I'm using Transformers 3.0.1 and the BERT model to do two-sentence NLI-style classification.

Language I am using the model on (English, Chinese ...): English

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [x] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)


I have a question and two issues:

1. What happened to the `BertTokenizer.encode_plus()` and `BertTokenizer.batch_encode_plus()` methods? I see there must have been a change somewhere to remove them in Transformers 3.0.0, but I cannot find any online change log or other description of what the replacement methods are.

2. This issue I am getting is that there are a lot of repeated messages stating
> Truncation was not explicitely activated but `max_length` is provided a specific value, please use `truncation=True` to explicitely truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to `truncation`.

This issue is apparently the same as the closed issue #5377. However, that one was with respect to `encode_plus ()`, **but my issue is with `batch_encode_plus()`**.

3. Please fix the typo: `Truncation was not explicitely ...` to be `Truncation was not explicitly ...`.


## To reproduce

Steps to reproduce the behavior for `batch_encode_plus()`:

I adapted the code from #5377:

```python
import transformers
print(transformers.__version__)
# 3.0.1

from transformers import BertTokenizer
max_len = 50
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')


# This example works fine with encode_plus().
text = 'Transformers are more than meets the eye'
encoded_dict = tokenizer.encode_plus(text,
                                     text_pair=None,
                                     add_special_tokens=True,
                                     max_length=max_len,
                                     pad_to_max_length=False,
                                     truncation='longest_first')

# This call to batch_encode_plus() shows warnings.
list_of_pair_of_string = []
list_of_pair_of_string.append( ('Transformers are', 'more than meets the eye') )
encoded_dict = tokenizer.batch_encode_plus(batch_text_or_text_pairs=list_of_pair_of_string,
                                           add_special_tokens=True,
                                           max_length=max_len,
                                           pad_to_max_length=False,
                                           truncation='longest_first'
                                           #truncation=True
                                           )
```

Note that for my call to `batch_encode_plus()`, I tried both `truncation='longest_first'` and also `truncation=True`.

However, the call always shows: 

> Truncation was not explicitely activated but `max_length` is provided a specific value, please use `truncation=True` to explicitely truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to `truncation`. 

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior
<!-- A clear and concise description of what you would expect to happen. -->

The call to `batch_encode_plus()` should not show any warning because I specifically provided the `truncation=` parameter.

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
     
- `transformers` version: 3.0.1
- Platform: Google Colab
- Python version: 3.6.9 (default, Apr 18 2020, 01:56:04) 
- PyTorch version (GPU?): 1.5.1+cu101
- Tensorflow version (GPU?):
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No


Comments:
same problem here

same problem here

I bumped the same problem. After a plenty of warning messages my colab stuck and web-page didn't answer. As a temporary solution I installed previous version of transformers library ```!pip install transformers==3.0.0``` and evething with ```BertTokenizer.batch_encode_plus()``` is okay.

The massive amount of generated warnings is crashing the Google Colab session in my Chrome browser. The only temporary fix I can find is to turn off all warning messages.

```python
import logging
logging.basicConfig(level=logging.ERROR)
```

same even when the `batch_encode_plus` method is not called (directly calling `tokenizer()` with a list of string)

Ok indeed, we are on it and will release a fix soon. Sorry for that.

Tested in 3.0.2 - warning persists.

Can you post the command line  (tokenizer call) you are running?

Same here, have tried myriad combinations to try to eliminate the warning.

```
model = Seq2SeqModel(
    encoder_type,
    "roberta-base",
    "bert-base-cased",
    args=model_args,
    truncation=True,
    use_cuda=cuda_available
)
```

> WARNING:transformers.tokenization_utils_base:Truncation was not explicitely activated but `max_length` is provided a specific value, please use `truncation=True` to explicitely truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to `truncation`.
> WARNING:transformers.tokenization_utils_base:Truncation was not explicitely activated but `max_length` is provided a specific value, please use `truncation=True` to explicitely truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to `truncation`.
> WARNING:transformers.tokenization_utils_base:Truncation was not explicitely activated but `max_length` is provided a specific value, please use `truncation=True` to explicitely truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to `truncation`.
> WARNING:transformers.tokenization_utils_base:Truncation was not explicitely activated but `max_length` is provided a specific value, please use `truncation=True` to explicitely truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to `truncation`.


I can't find the class `Seq2SeqModel` on our repo so I can't reproduce your code.

You need to open a new issue with all the details so I can try to reproduce and debug this.

Should only print it once