Transformer Architecture

conceptmatureCreated: 2026-07-24Updated: 2026-07-24Source: arxiv.org/abs/1706.03762
architecturetransformerreference

Transformer Architecture

The Transformer is the foundational neural network architecture for all modern LLMs, introduced by Vaswani et al. in the 2017 paper "Attention Is All You Need."

Core Innovation

The Transformer replaces recurrence (RNNs) and convolution (CNNs) with a purely attention-based mechanism. This allows:

  • Parallel computation — All tokens processed simultaneously during training
  • Long-range dependencies — Direct connections between any two positions
  • Scalability — Architecture scales to trillions of parameters

Architecture Components

Encoder-Decoder vs Decoder-Only

The original Transformer used an encoder-decoder structure, but most modern LLMs (GPT-4o, Llama 4, Claude 4) use decoder-only architecture with causal masking.

Key Components

  1. Multi-Head Self-Attention — Each token attends to all others
  2. Feed-Forward Networks (FFN) — Position-wise MLP layers
  3. positional-encoding — Adds position information (often RoPE in modern models)
  4. Layer Normalization — Pre-norm or post-norm placement
  5. Residual Connections — Skip connections around each sub-layer

Modern Innovations

Scaling Laws

The Transformer exhibits predictable scaling-laws: performance improves with increased parameters, data, and compute according to power-law relationships.

Training

Transformers are trained via pretraining on large text corpora, followed by SFT and RLHF or DPO.

Related Concepts