Transformer
The foundational neural architecture behind modern LLMs and multimodal AI that replaces recurrence with Self-Attention for fully parallelizable, long-range sequence modeling
Table of Contents
Structure Diagram
What is Transformer?
The foundational neural architecture behind modern LLMs and multimodal AI that replaces recurrence with Self-Attention for fully parallelizable, long-range sequence modeling. It is a core concept in Model Architecture within AI / ML.
Core Principles
Introduced in Attention Is All You Need (2017), the Transformer eliminated the sequential bottleneck of RNNs by using Self-Attention to relate every token in a sequence in parallel.
Each Transformer block pairs a Multi-Head Attention layer (mixing information across tokens) with a Feed-Forward / MLP layer (transforming per-token features), stabilized by residual connections and normalization stacked dozens of layers deep.
Practical Takeaways
- Built for GPU parallelism and Scaling Laws: Parallel sequence processing unlocked trillion-token pre-training where loss decreases predictably with model size, data, and compute.
- Modern LLM defaults differ from 2017: Production models standardize on Pre-Norm (RMSNorm), RoPE, SwiGLU, GQA, and FlashAttention.
- Mind quadratic $O(N^2)$ attention scaling: Very long contexts rely on IO-aware FlashAttention kernels, context parallelism, or hybrid state-space layers.
Notable Examples
- GPT, Claude, Gemini & Llama: Built on modern Decoder-only Transformer backbones.
- Vision Transformer (ViT): Tokenizes image patches to bring Transformer scaling to computer vision.
- Diffusion Transformers (DiT) & AlphaFold: Unified video generation and molecular modeling under the same backbone.