Sensei Archives • AI/ML

Causal Mask vs Padding Mask: The Two Attention Gates, and When Each Fires

One gate per role. No future leak. No filler attention.
Image backend outage note: the image generator (qwen/qwen-image-3 via OpenRouter) was funded but rendered a degraded plate on both rolls this run (garbled bullets, a duplicated column heading, missing bands, and the stable 768x1531 dimension deviation — the funded-primary degradation signature recorded Oct 10–14). Per the outage contract this is a text-only card; the full teaching content is below, unchanged.

1Causal mask: the no-future gate

Position-structured — the decoder's left-to-right law

2Padding mask: the no-filler gate

Length-structured — wherever variable lengths are batched

3The one shared mechanism

What both gates actually are
scores: S = QK^T / sqrt(d) mask: S = S + bias, masked cells set to -inf softmax: exp(-inf) = 0 → weight is exactly 0

4The trap the slides miss

The falsification — the correction to carry
The line to remember

A mask is a bias in. -inf before softmax. Zero weight out.