Token indices sequence length is longer than the specified maximum sequence length for this model (821 > 512). Running this sequence through the model will result in indexing errors
I am trying to generate a Boolean question using T5 transformer. using [this](https://github.com/ramsrigouthamg/generate_boolean_questions_using_T5_transformer/blob/master/t5_inference.py
![jupyter error](https://user-images.githubusercontent.com/72002381/174787727-ebc22c3d-0785-45b6-a5bd-5d0d652adb7e.PNG)
) link as a reference. 

```
def topkp_decoding (inp_ids,attn_mask):
  topkp_output = model.generate(input_ids=inp_ids,
                                 attention_mask=attn_mask,
                                 max_length=256,
                               do_sample=True,
                               top_k=40,
                               top_p=0.80,
                               num_return_sequences=(len(z)*2),
                                no_repeat_ngram_size=2,
                                early_stopping=True
                               )
  Questions = [tokenizer.decode(out, skip_special_tokens=True,clean_up_tokenization_spaces=True) for out in topkp_output]
  return [Question.strip().capitalize() for Question in Questions]
```

```
start = time.time()

passage =wo
truefalse ="no" + "yes"

#text = "truefalse: %s passage: %s </s>" % (passage, truefalse)

max_len = 256

encoding = tokenizer.encode_plus(text, return_tensors="pt")
input_ids, attention_masks = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)

#print ("Context: ",passage)
global output
output = beam_search_decoding(input_ids,attention_masks)
#print ("\nBeam decoding [Most accurate questions] ::\n")
#for out in output:
    #print(out)
global outputs
outputs = topkp_decoding(input_ids,attention_masks)
#print ("\nTopKP decoding [Not very accurate but more variety in questions] ::\n")
#for out in outputs:
    #print (out)

end = time.time()
#print ("\nTime elapsed ", end-start)
#print ("\n")
```
But I am getting an error **Token indices sequence length is longer than the specified maximum sequence length for this model (821 > 512). Running this sequence through the model will result in indexing errors** while running this code in jupyter. how to solve this issue?
Hi,

This question is better suited for our [forum](https://discuss.huggingface.co/), as we'd like to keep Github issues for bugs/feature requests.

This one is not a bug, you just need to truncate the inputs as they are longer than what the model expects:

````
encoding = tokenizer(text, truncation=True, return_tensors="pt")
````

Thanks!<|||||>Hey @NielsRogge shouldn't ideally in such a case there should be an error triggered or even if the warning is triggered the ideal nature of the tokenization process be to, forcefully truncate the input, as this could cause errors on a production grade system if left unchecked.<|||||>No we don't truncate by default, that would break the design of the library quite a bit. Users need to specify the truncation or padding behaviour themselves, as it can happen from the right or the left for instance, the max length can differ, etc.

See here for a guide on ["everything you always wanted to know about tokenization"](https://huggingface.co/docs/transformers/v4.15.0/preprocessing#everything-you-always-wanted-to-know-about-padding-and-truncation). <|||||>Okay sure @NielsRogge, I understand now.
