Chip Foundry Services Request Assessment

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.

Input embeddings + positional encoding
Tokens mapped to vectors
Transformer blockStacked N times (N = 32 for 7B, 126 for 405B)
Multi-head self-attention
Every token consults every other
Add & Norm
Residual connection + normalize
↻ next block
Add & Norm
Residual connection + normalize
Feed-forward network
Expand, nonlinearity, project
Output / next block
Final layer feeds the output head
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.

Try it yourself: self-attention from scratch, in NumPy. Build the Q/K/V → softmax → weighted-sum mechanism the diagram above describes, for a tiny 4-token sequence, and watch how attention weights redistribute as you change one vector.

import numpy as np

np.random.seed(0)
seq_len, d_model = 4, 8

X = np.random.randn(seq_len, d_model)          # 4 tokens, 8-dim embeddings
Wq, Wk, Wv = (np.random.randn(d_model, d_model) * 0.1 for _ in range(3))

Q, K, V = X @ Wq, X @ Wk, X @ Wv

scores = Q @ K.T / np.sqrt(d_model)             # scores = Q·K^T / sqrt(d)
weights = np.exp(scores - scores.max(axis=1, keepdims=True))
weights /= weights.sum(axis=1, keepdims=True)   # softmax, rows sum to 1

output = weights @ V                            # output = sum(weight · V)

print("Attention weights (each row sums to 1):")
print(np.round(weights, 3))
print("\nToken 0 attends most to token:", weights[0].argmax())

Open questions: if you scale up one token's embedding by 10x before computing `Q`, which row of `weights` changes the most, and why does the $1/\sqrt{d_{\text{model}}}$ scaling term matter for keeping that effect from saturating the softmax? Why does self-attention need all three of Q, K, and V instead of just comparing tokens directly? Your deliverable: run the code above, then change `seq_len` to 8 and explain in one paragraph why the attention-score matrix grows the way it does as sequence length increases — this is the $O(n^2)$ cost the Key Components panel mentions.

The original paper described an encoder-decoder, not the decoder-only shape most people now mean by "a Transformer." The architecture above is deliberately simplified to the repeating block; the actual 2017 paper paired two separate stacks — an encoder that reads the whole source sentence at once, and a decoder that generates the target sentence one token at a time, attending both to its own prior outputs and to the encoder's output via a second, cross-attention layer:

The Original Transformer — Encoder-Decoder "Attention Is All You Need" (2017) — encode the source sentence, decode the target ENCODER Multi-Head Self-Attention Add & Norm Feed-Forward Network Add & Norm × N layers + Positional Encoding Input Embedding Inputs source sentence tokens encoder output used as K, V DECODER Masked Multi-Head Self-Attention Add & Norm Cross-Attention (to encoder) Add & Norm Feed-Forward Network × N layers + Positional Encoding Output Embedding Outputs (shifted right) target tokens generated so far Linear Encoder reads the whole source at once; decoder generates target tokens one at a time, attending to its own past output (masked) and every encoder position (cross-attention). Softmax → Output Probabilities (next target token)

Nearly every model people talk about today — GPT, Llama, Claude — dropped the encoder half entirely and kept only the decoder. There is no source sentence to encode and no cross-attention layer; the model simply predicts the next token conditioned on everything generated so far, with a causal mask forcing each position to see only earlier positions. This decoder-only shape is why "autoregressive" and "GPT-style" became near-synonyms for "Transformer" in casual usage, even though the original architecture was built for translation, not open-ended generation:

Decoder-Only — The ChatGPT / GPT Architecture no encoder, no cross-attention — one autoregressive stack generating a single next token Softmax → next-token probabilities Linear (unembedding) Final RMSNorm DECODER BLOCK Add & Norm Feed-Forward Network (SwiGLU / MLP) Add & Norm Masked (Causal) Multi-Head Self-Attention × N layers (32 for 7B, 126 for 405B) Causal mask token i attends only to tokens ≤ i → left-to-right, one token at a time + Positional Encoding (RoPE) Token Embedding Input: the prompt + every token generated so far to produce the next token, the whole sequence runs through the stack again GPT, Llama, Claude: the same decoder half as above, with the cross-attention to an encoder removed.