Transformer Block Assembly › Key Parameters
Language AI HandbookAll chapters Transformer Block Assembly › Key ParametersOne section · Sections in this chapter15 / 16 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
When implementing transformer blocks, these parameters control capacity and efficiency:
-
(model dimension): The embedding dimension that flows through the entire block. Typical values range from 256 (small models) to 12288 (GPT-3 scale). This dimension must be divisible by since each head operates on dimensions.
-
(attention heads): Number of parallel attention mechanisms. More heads enable attending to different types of relationships simultaneously. Common choices are 8, 12, 16, or 32 heads.
-
(FFN hidden dimension): The intermediate dimension of the feed-forward network. For standard FFNs, typically . For SwiGLU, typically (approximately 2.7×) to maintain similar parameter count. The gating mechanism effectively doubles the width, so a smaller explicit expansion compensates.
-
norm_type: Choice between RMSNorm (faster, used in LLaMA/Mistral) and LayerNorm (original, used in GPT-2/BERT). RMSNorm is preferred for new architectures.
-
norm_placement: Pre-norm (normalize before sublayers) or post-norm (normalize after). Pre-norm is standard for modern deep models due to better gradient flow.
-
ffn_type: Standard (two linear layers with activation) or gated (SwiGLU, GeGLU). Gated variants improve expressiveness at similar parameter cost.
-
causal: Whether to apply causal masking in attention. Required for autoregressive language models, disabled for bidirectional encoders like BERT.
-
(normalization epsilon): Small constant (typically to ) added to prevent division by zero in normalization. The RMSNorm formula divides by . Without , a vector of all zeros would cause a division by zero. May need adjustment (e.g., instead of ) for mixed-precision training where numerical precision is lower.