# UserWarning: Using `pad_token_id` but `padding_side` is not set. The tokenizer will use 'right' padding by default, which may not be optimal for decoder-only models.

- **ID:** `huggingface/tokenizer-fast-vs-slow-padding`
- **Domain:** huggingface
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

When a tokenizer's `padding_side` is not explicitly set, it defaults to 'right', which causes incorrect causal masking in decoder-only models like GPT or LLaMA, leading to degraded generation quality.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| transformers>=4.34.0 | active | — | — |
| tokenizers>=0.14.0 | active | — | — |

## Workarounds

1. **Set `tokenizer.padding_side = 'left'` before tokenization for decoder-only models. This ensures padding tokens are on the left and do not interfere with causal attention.** (95% success)
   ```
   Set `tokenizer.padding_side = 'left'` before tokenization for decoder-only models. This ensures padding tokens are on the left and do not interfere with causal attention.
   ```
2. **Use the `pad_token_id` and explicitly pass `attention_mask` to the model to avoid reliance on padding_side defaults.** (85% success)
   ```
   Use the `pad_token_id` and explicitly pass `attention_mask` to the model to avoid reliance on padding_side defaults.
   ```

## Dead Ends

- **** — Setting `padding_side='right'` explicitly silences the warning but does not fix the causal masking issue for decoder-only models. (60% fail)
- **** — Ignoring the warning and proceeding with training often leads to subtle quality degradation that is hard to detect until evaluation. (40% fail)
