A padding token is inserted into shorter tokenized sequences so every sequence in a batch has the same length. Transformer models use this uniform shape for efficient batch processing. section 5.2.2
Recognizing padding in BERT inputs
With bert-base-uncased, trailing 0 values in input_ids convert to [PAD] tokens. The corresponding attention_mask values are 0, distinguishing padding from the original sequence tokens, whose mask values are 1.



