Truncation when tokenizer does not have `max_length` defined
Hello,

I'm currently writing some code using transformers, and have something similar to:

```python
model = AutoModel.from_pretrained(model_name, output_hidden_states=True)
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)

ids = tokenizer.encode(sentence, truncation=True)
```

The issue I am facing is when sentence has > 512 tokens (wordpieces actually) for certain models. The above code works fine for `bert-base-multilingual-cased`, but fails for `qarib/bert-base-qarib`, because the tokenizer in the latter case does not define a max length:

```bash
Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.

....

RuntimeError: The size of tensor a (515) must match the size of tensor b (512) at non-singleton dimension 1
```

So the model itself is limited to 512, but the tokenizer is not aware of this max length. Apart from asking the original model creators to define the max_model_length in their tokenizer, is there anything else I can do to "autodetect" the max length? Can I use `model.config.max_position_embeddings` as a proxy for max length when using the tokenizer?

Thanks!
Try this
`tokenizer(sentence, truncation=True, max_length=512)`

`model.config.max_position_embeddings` is the right way to see the max sequence length<|||||>Sounds good, thanks for the confirmation!