Architecture (Model Architecture)
From the Transformer LM backbone to Attention, RoPE, and modern components: understand language model architecture
Overview
The Architecture module starts from a complete decoder-only Transformer LM, then progressively breaks down core components such as Attention, RoPE, Normalization, MLP, and the residual stream.
We recommend starting with the Transformer LM overview to build the overall data flow from token ids to next-token logits, then moving on to topics like Attention and RoPE.
Chapters
Transformer LM
From token ids to next-token logits: build a mental model of the decoder-only Transformer forward pass
Attention Mechanisms
MHA, Causal Attention, GQA / MQA, and the design and evolution of Gated Attention
Position Encoding and RoPE
From sinusoidal PE to rotary position embeddings: understand the math, implementation, and length extrapolation of RoPE
Learning Path
| Stage | Content | Goal |
|---|---|---|
| Overall | Transformer LM | Master the input/output contract, shape changes, and forward pass |
| Core | Attention mechanisms | Master Self-Attention, Multi-Head, Causal Masking |
| Core | Position encoding and RoPE | Understand the evolution of position encoding; master RoPE principles and implementation |
| Optimization | GQA/MQA | Understand KV cache optimization and memory efficiency |
| Advanced | Length extrapolation | Master long-sequence methods like NTK-aware and YaRN |
CookLLM Docs