Transformer Block Assembly › Comparing Block Architectures
Language AI HandbookAll chapters Transformer Block Assembly › Comparing Block ArchitecturesOne section · Sections in this chapter10 / 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
Different models use slightly different block configurations. Let's compare the major variants:
# Define configurations for major architectures
architectures = {
"GPT-2": {
"norm_type": "LayerNorm",
"norm_placement": "Pre-norm",
"ffn_type": "Standard (GELU)",
"ffn_expansion": 4.0,
"attention_type": "Dense",
},
"LLaMA": {
"norm_type": "RMSNorm",
"norm_placement": "Pre-norm",
"ffn_type": "SwiGLU",
"ffn_expansion": 2.7, # ~8/3 with gating
"attention_type": "Dense + RoPE",
},
"Mistral": {
"norm_type": "RMSNorm",
"norm_placement": "Pre-norm",
"ffn_type": "SwiGLU",
"ffn_expansion": 2.7,
"attention_type": "Sliding Window + GQA",
},
"BERT": {
"norm_type": "LayerNorm",
"norm_placement": "Post-norm",
"ffn_type": "Standard (GELU)",
"ffn_expansion": 4.0,
"attention_type": "Dense (bidirectional)",
},
}Transformer Block Architecture Comparison ====================================================================== Component GPT-2 LLaMA Mistral BERT ---------------------------------------------------------------------- Norm Type LayerNorm RMSNorm RMSNorm LayerNorm Norm Placement Pre-norm Pre-norm Pre-norm Post-norm Ffn Type Standard (GELU)SwiGLU SwiGLU Standard (GELU) Ffn Expansion 4.0 x2.7 x2.7 x4.0 x Attention Type Dense Dense + RoPESliding Window + GQADense (bidirectional)
The table shows main design decisions that distinguish architectures:
- Modern models (LLaMA, Mistral) use RMSNorm for efficiency and SwiGLU for improved FFN expressiveness
- BERT is a notable exception, using post-norm placement (it predates the pre-norm stability insights)
- FFN expansion is smaller with gated variants because gating effectively doubles the hidden dimension
To visualize how these architectural choices affect parameter allocation, let's compare parameter counts across different model scales:

The scaling chart reveals an important insight: as models grow larger, the FFN becomes increasingly dominant. At , the FFN accounts for over 80% of transformer layer parameters. This explains why efficiency innovations (like Mixture of Experts) primarily target the FFN component.