Skip to content

Glossary: NLP with Transformers

Padding, truncation

Also written: padding, truncation, [PAD], max_length

Padding adds `[PAD]` tokens to short texts so a batch has equal lengths. Truncation cuts texts that are longer than the model's limit, such as 512 tokens for BERT.

Where the book teaches it

Related terms

Attention maskSpecial tokensData collator