Transformer

The Transformer is the neural-network architecture introduced in the 2017 paper *Attention Is All You Need*, and it is the foundation of virtually every modern large language model, image generator, and speech system. Its breakthrough was replacing the sequential, step-by-step processing of earlier recurrent networks with a mechanism — self-attention — that looks at an entire sequence at once and lets every element directly consult every other. That single change made it possible to train on far more data, in parallel, than anything before it. The diagram shows the repeating block that gets stacked to build the whole model.

The Transformer Block attention mixes tokens, the feed-forward network thinks per token — stacked N times Input embeddings + positional encoding Multi-head self-attentionevery token attends to every other Add & Norm Feed-forward networkexpand → nonlinearity → project Add & Norm to next block / output × N identical layers residual (skip) connections Inside one attention head Query · Key · Value each token makes 3 vectors scores = Q·Kᵀ / √d how much to attend softmax → weights sum to 1 across tokens output = Σ weight · V context-mixed vector No recurrence all tokens processed in parallel — the reason transformers scale Attention answers “which other tokens matter here?”; the feed-forward layer transforms each token given that context.

Self-attention is the core idea. For every token, the model produces three vectors — a query, a key, and a value. It compares each token's query against all the keys to decide how much attention to pay to every other token, normalizes those scores with a softmax, and returns a weighted blend of the values. The result is a new representation of each token that has absorbed exactly the context it needs, whether the relevant word is one position away or a thousand.

Multi-head attention looks in several ways at once. Rather than a single attention computation, the block runs several in parallel — different "heads" that can specialize, one tracking syntax, another coreference, another local phrasing. Their outputs are concatenated and projected back together, giving the model multiple relationship types per layer.

The feed-forward network processes each token alone. After attention has mixed information across positions, a small two-layer network is applied independently to every token: expand to a wider dimension, apply a nonlinearity, project back. This is where much of the model's raw capacity and stored knowledge lives. Attention decides *what to combine*; the feed-forward layer decides *what to do with it*.

Residual connections and normalization make depth trainable. Each sub-layer's output is added back to its input (a residual, or skip, connection) and normalized. This keeps gradients flowing cleanly through dozens or hundreds of stacked layers, which is what lets Transformers go deep without the signal degrading.

Parallelism is the reason it won. Because there is no recurrence, all positions in a sequence are processed simultaneously during training — a perfect match for the wide, parallel arithmetic of GPUs and TPUs. Recurrent networks had to march through a sequence one step at a time; the Transformer turned language modeling into big matrix multiplications, and that is exactly what modern accelerators do fastest.

PieceWhat it doesQuestion it answers
Query / Key / Valueper-token vectors for attentionwhat am I looking for, offering, carrying
Attention scoresQ·Kᵀ scaled, then softmaxwhich tokens matter to me
Multi-headparallel attention subspaceswhat relationships exist at once
Feed-forwardper-token transformationwhat to make of the mixed context
Residual + normadd input back, normalizehow to stay trainable when deep

Read a Transformer through an *all-at-once attention* lens rather than a *sequence-processing* lens: earlier models understood a sentence by walking through it word by word, carrying a running memory, while the Transformer lays the whole sequence out and lets every token pull directly from every other in a single parallel step. That shift is why it trains efficiently at massive scale, why context length is such a central design axis, and why "attention" — not recurrence or convolution — became the organizing principle of modern AI.

Transformer Architecture — The Foundation of Modern AI attention is all you need: self-attention + feed-forward + residuals + layer norm, stacked N times One Transformer Block (decoder-only, GPT-style) Input (x) residual RMSNorm Multi-Head Attention Q·K^T/√d → softmax → ×V + RMSNorm FFN (SwiGLU) up → gate × act → down Output (x') × N layers (N = 32 for 7B, 80 for 70B, 126 for 405B) Key Components Attention (QKV) global context, O(n²) in seq length FFN / MLP (2/3 of params) knowledge storage, per-token transform Residual connections gradient highway, enables depth Positional encoding RoPE (relative, extrapolatable) Causal mask autoregressive: can't see future tokens Transformer Variants Encoder-only: BERT (bidirectional, classification) Decoder-only: GPT, Llama, Claude (generation) Encoder-decoder: T5, BART (seq2seq, translation) Scale Progression GPT-1 (2018): 117M params, 12 layers GPT-3 (2020): 175B params, 96 layers Llama-3 (2024): 405B params, 126 layers The transformer is just attention + MLP + skip connections — its power comes from scale, data, and the training objective. Every frontier model — GPT-4, Claude, Gemini, Llama — is a transformer. The architecture won.

Take transformer further

Ask the copilot about this term, or have our engineers assess it against your process.