Raw textto [B, T, 50257]
Specification
- Attention
- 12 heads, each with its own keys and values; 64 features per headconfig.jsonmodel.py 102–108
- Feed-forward
- GELU MLP, 3,072 hidden features (4 × width)config.jsonmodel.py 115–128
- Context
- 1,024 positions, the learned position tableconfig.json
Parameters124,439,808
124,439,808 parameters in GPT-2 Small
| Component | Calculation | Parameters |
|---|---|---|
| Token embedding | 50,257 × 768 | 38,597,376 |
| Position embedding table | 1,024 × 768 | 786,432 |
| Layer | 7,087,872 × 12 | 85,054,464 |
| Final LayerNorm | 768 + 768 | 1,536 |
| Model total | 124,439,808 | |
Counted from the pinned configuration and code. The token embedding is counted once; the tied vocabulary projection adds nothing. Not checked against the checkpoint’s tensors.
Weights · whole model
4 bytes per parameter. The token embedding, 50,257 × 768, is 31.0% of the model; the readout multiplies by its transpose, so it owns none, and a separate readout would add the embedding’s bytes again.
config.jsonmodel.py 154–155, 171Sources
Direct evidence
The released forward pass provides contextual evidence for input IDs, embedding states, the independently addressed layer loop, final normalization, and tied vocabulary logits.
model.py 147–174 ↗ · openai/gpt-2 @ 9b63575ef427
Excerpt
h = tf.gather(wte, X) + tf.gather(wpe, positions_for(X, past_length))… lines 158–162 omitted …
for layer, past in enumerate(pasts):
h, present = block(h, 'h%d' % layer, past=past, hparams=hparams)… lines 165–166 omitted …
h = norm(h, 'ln_f')… lines 168–170 omitted …
logits = tf.matmul(h_flat, wte, transpose_b=True)The Small configuration supports a derived exact total of 124,439,808 parameters, with the token embedding counted once. 124M is a rounded size label; checkpoint tensors have not been independently counted.
config.json $ ↗ · openai-community/gpt2 @ 607a30d783df