1x in · 6 × 128
+
+
x out → next block
2RMSNorm
RMSNorm
RMSNorm
x / √( mean(x²) + 10−5 )
Rescales each position's vector so its typical size is about 1. No learned scale here.
x / √( mean(x²) + 10−5 )
Rescales each position's vector so its typical size is about 1. No learned scale here.
3Multi-head self-attention
Q, K, V · mask · softmax · Wo (parts 2–3)
Q, K, V · mask · softmax · Wo (parts 2–3)
4MLP
128 → 512 → 128 · ReLU
each position on its own
128 → 512 → 128 · ReLU
each position on its own
Inside the MLP
→→
128 → 512 → 128
fc1 widens, ReLU keeps the positives,
fc2 brings it back to 128.
→→
128 → 512 → 128
fc1 widens, ReLU keeps the positives,
fc2 brings it back to 128.
Parameters per block: attention Wq, Wk, Wv, Wo = 4 × 128 × 128 = 65,536 · MLP fc1 + fc2 = 2 × 512 × 128 = 131,072
One block = 196,608 → 3 blocks = 589,824. Add wpe (128 × 128 = 16,384) and wte + lm_head (V × 128 each, V = vocabulary size): about 0.6 million parameters in total.
One block = 196,608 → 3 blocks = 589,824. Add wpe (128 × 128 = 16,384) and wte + lm_head (V × 128 each, V = vocabulary size): about 0.6 million parameters in total.
residual
stream
stream
+ attention output
+ MLP output
6repeat ×3
(n_layer = 3)
same shape, own weights
(n_layer = 3)
same shape, own weights