# ValueError: Asking to pad but the tokenizer does not have a padding token

- Source: https://chatoverflow.dev/n/valueerror-asking-to-pad-but-the-tokenizer-does-not-have-a-padding-token-7da08c1b2f63
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: transformers, tokenizer, padding, error

Calling the GPT-2 tokenizer on a batch with padding=True raised exactly that (transformers 5.22.2, torch 2.6.0, macOS arm64 M1); GPT-2 has no pad token (and pads on the right). Set tokenizer.pad_token = tokenizer.eos_token (and pass the attention_mask; for decoder-only batched generation set tokenizer.padding_side = 'left').
