Softmax pooling across all four quadrants. The gate needs a score per quadrant. From what?
Key k = x WKᵀ: what each quadrant has. Query q = xTL WQᵀ: what top-left looks for. Score s = q · k
Two projections of the input, multiplied together. Where have we seen that before?
SwiGLU's pattern: projections feed the gate. Here s = (xTLWQᵀ) · (xjWKᵀ): how similar query and key are
Softmax pooling with one change: the gate reads projections, q · k, not raw values.
WV not drawn. The gates are plain numbers, so Σj aj(WVxj) = WV(Σj ajxj): WV can come after the gated sum and merge into the next linear layer. Running example: WV = I.
Same square-and-circle task, same 10 epochs, 3 seeds
MODEL · 10 EPOCHS
EACH SEED
MEAN
Conv stem + attention, no position
0.58 · 0.57 · 0.59
0.58
+ learned position (absolute)
0.81 · 0.51 · 1.00
0.77
+ offset bias, default lr
0.59 · 0.58 · 0.58
0.58
+ offset bias, 10× lr on the bias table
1.00 · 1.00 · 1.00
1.00
QUESTION
Why did the default learning rate fail?
Next slide: how to spot a stalled parameter.
MODERN MODELS
RoPE rotates q and k so the score depends on the offset. Same idea, built in. (1.00 here too.)
A learned offset bias gets back what convolution kept for free.
At 30 epochs, learned position and the default-lr offset bias also reach 1.00 on all 3 seeds (no position: 0.59). Conv stem = two 3×3 convs and a 4×4 patch conv (exp_position.py).
What if each 768-pixel window described a word? No camera for words: where do its pixels come from?
?
now: [MASK] row→ Linear 768 → 30,000
Each word gets its own segment; the model learns what to paint in it. For text, the patches are learned.Hide a word, predict it from the others: that's how BERT learns, on raw text.
768 = 16 × 16 × 3, a ViT-Base patch; ViT-Base and BERT-Base are 768 wide. Illustrative: 6 windows; only a few of each window's 768 pixels drawn.
Same network, new front end: each word's ID looks up its own row of a learned table
now: [MASK] row→ Linear 768 → 30,000
now: embedding lookup· E 30,000 × 768
WHERE DO THE ROWS COME FROM?
Random at first, learned in pretraining
No pre-made word2vec / GloVe vectors
Position (512 × 768): learned too
WHO PICKS THE PIECES?
WordPiece tokenizer, built first from piece counts: not learned
playing → play + ##ing, one row of E each
An embedding is a learned patch, one per word piece. The tokenizer picks the windows; training paints them.
BERT-Base: 30,000-piece WordPiece vocabulary, 768 wide. Illustrative: word IDs and row values; only a few of E's rows and of each row's 768 numbers drawn.
Post-norm puts a LayerNorm on every skip path, so the gradient to early layers crosses them all; pre-norm keeps a clean skip path: deep stacks train stably.
Warner et al. 2024; Xiong et al. 2020
11WHY REUSE E AT THE OUTPUT?
Input gradient is sparse: a word's row learns only when it appears. The output softmax touches every row, every step. Tying gives every row that signal.
But the jobs differ (read vs. predict). Many large models untie (more data; dense signal not needed). Tying saves ≈23 M parameters here.
BERT = our model, on text, pretrained.
BERT-Base, Devlin et al. 2019: ≈ 110 M parameters. Pretrained on raw text: fill in hidden words (15%). Tying saves ≈ 23 M.