Rúben GalvãoThe Rabbit Hole

The Rabbit Hole / AI / Model architectures

OpenAI · Architecture map

GPT-2

The original decoder-only transformer recipe: layer norm, learned positions and multi-head attention.

GPT-2, 2019 · GPT release timeline

Inside GPT-2

Size
Parameters
124M
Layers
12
Width
768
Mixer
Multi-head
Select a component to explore it.
Inside multi-head attention · Transformer layers 1–12
12 heads.

Earlier context dimmed · current token bright · dashed regions contain cached entries.

GPT-2: Transformer layers 1–12 · multi-head attention12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context. Keys and values for all 12 heads, 64 values each, per token per layer.12 heads; the front face shows one representative.12 headsAttention input. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Earlier context is dimmed; outlined columns are current.Current token computation.Attention input768CLWq. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Wq76864Wk. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Wk76864Wv. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Wv76864K cache. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Earlier columns are cached; outlined columns are newly computed.Cached positions from earlier decoding steps.Current token computation.K cache64CLV cache. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Earlier columns are cached; outlined columns are newly computed.Cached positions from earlier decoding steps.Current token computation.V cache64CLQ context. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Earlier context is dimmed; outlined columns are current.Current token computation.Q context64CLScaled query–key scores, masking and softmax. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.CLCL×. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.×Joined heads. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.12Wo. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Wo768768Attention output. 12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.Earlier context is dimmed; outlined columns are current.Current token computation.Attention output768CL
Model-specific details
Transformer layers 1–12 · 12 repetitions
One dense feed-forward network per layer with a GELU activation (hidden size 3072, four times the width), used by every token.
Attention and positions
12 heads of 64 values, each with its own keys and values; causal attention over a 1,024-token context.
Memory
Keys and values for all 12 heads, 64 values each, per token per layer.

Learned positions and a dense stack

The picker includes the 124M and 1.5B checkpoints. All GPT-2 sizes use the 1,024-token training context.

Explore the components

Sources for this map