Assume GPT-2 small has layers, , feed-forward width , vocabulary and context length with learned positional embeddings, and output weights tied to the token embedding, where each projection has a bias and each layer has two layer norms. How many parameters does it have?
Sequence models and transformers, Transformers
Level L3 Intermediate. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can count parameters systematically by component and arrive at the well-known million.
Key idea
One block has parameters (attention , MLP , two layer norms ), so the model has about block parameters plus the embeddings.
Steps
- Attention: are four matrices with biases, so .
- MLP: has and has , so .
- Two layer norms, each with scale and shift: .
- Per block: .
- Twelve blocks: .
- Token embedding: . Positional embedding: . Final layer norm: . The output projection reuses the token embedding, so it adds nothing.
- Total million.
Common mistakes
- Counting the output projection again when weights are tied; untied would add about million.
- Forgetting positional embeddings, biases or the final layer norm.
- Using instead of in the MLP.
How long your answer should be
Half a page with a small table; 5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Sequence models and transformers: Count the matrix-multiply FLOPs of one transformer layer's forward pass for sequence length , model width and feed-forward width (one sequence, ignoring softmax, layer norm and biases). Which part dominates, and at what does attention's term equal the linear-in- part?
Next in Sequence models and transformers: A corpus has the words low (), lower (), newest () and widest (), each split into characters. BPE merges the most frequent adjacent pair. WordPiece merges the pair with the highest score . Which pair does each choose first, and why do they differ?