A Real Configuration
Audit every weight matrix, bias vector, LayerNorm pair, and embedding table in a 124-million-parameter Transformer configuration.
The problem
Marketing labels round real checkpoints to headlines like "124M parameters," making large architectures sound mysterious. We are not loading or training a language model in the browser here; instead, we can audit the exact five-number configuration of GPT-2 small, [d_model, d_ff, layers, vocab, max_seq] , using the same layer-counting algebra from earlier pages.
Where does every scalar in that 124,439,808-parameter checkpoint come from, and how much sits inside the 12 repeated Transformer blocks versus the vocabulary and position embedding tables?
Work through the numbers
Start inside one Transformer block with and . Self-attention uses four biased linear projections (query, key, value, output), contributing parameters. The feed-forward sublayer maps with biases, contributing parameters.
Each block also contains two LayerNorm layers, and each LayerNorm stores a scale vector and shift vector of length , adding scalars. Summing gives 7,087,872 parameters per block. Stacking 12 identical blocks contributes block parameters.
Now count the shared tables outside the blocks. Token embeddings store parameters, learned position embeddings store parameters, and the final LayerNorm adds scalars (the output vocabulary head reuses the token embedding matrix). Those non-block tables total 39,385,344 parameters, and parameters in full ([7087872, 85054464, 39385344, 124439808]).
The live model
The four bars display [per_block, all_blocks, embeds_and_lnf, grand_total] as n_layers varies on [768, 3072, n_layers, 50257, 1024]. At n_layers , stacked blocks hold 14,175,744 parameters while embeddings hold 39,385,344 (total 53,561,088), so vocabulary tables dominate shallow models. At n_layers , blocks reach 42,527,232 and pass embeddings (total 81,912,576). At default n_layers , total hits 124,439,808, and at 24 layers it reaches 209,494,272.
![Four horizontal bars auditing [768, 3072, 12, 50257, 1024]: per-block 7087872, 12 blocks 85054464, embeddings 39385344, and total 124439808.](../assets/ml/a-real-configuration--demo.png)
let n_layers = scene.parameter("n_layers", 12.0, 2.0, 24.0, 2.0);
let d = input.slice(0, 0, 1);
let d_ff = input.slice(0, 1, 2);
let vocab = input.slice(0, 3, 4);
let max_seq = input.slice(0, 4, 5);
let attn = 4.0 * d * (d + 1.0);
let mlp = 2.0 * d * d_ff + d_ff + d;
let per_block = attn + mlp + 4.0 * d;
let all_blocks = n_layers * per_block;
let embeds = vocab * d + max_seq * d + 2.0 * d;
let total = all_blocks + embeds;
let lst = torch.list().add(per_block).add(all_blocks).add(embeds).add(total);
let answer = torch.cat(lst, 0);
out.set("config_audit", answer);
{
"config_audit": [
7087872,
85054464,
39385344,
124439808
]
}Watch the parameter change
Your turn
The starter audit outputs [7087872, 7087872, 39385344, 46473216] on the 12-layer configuration instead of [7087872, 85054464, 39385344, 124439808]. Return [per_block, all_blocks, embeds_plus_lnf, grand_total] for any five-element [d_model, d_ff, layers, vocab, max_seq] vector with biased projections, two LayerNorms per block, a final LayerNorm, and tied token embeddings; Check tests both this checkpoint and unseen architectures to exact integer precision.

let d = input.slice(0, 0, 1);
let d_ff = input.slice(0, 1, 2);
let layers = input.slice(0, 2, 3);
let vocab = input.slice(0, 3, 4);
let max_seq = input.slice(0, 4, 5);
let attn = 4.0 * d * (d + 1.0);
let mlp = 2.0 * d * d_ff + d_ff + d;
let per_block = attn + mlp + 4.0 * d;
let all_blocks = per_block;
let embeds = vocab * d + max_seq * d + 2.0 * d;
let total = all_blocks + embeds;
let lst = torch.list().add(per_block).add(all_blocks).add(embeds).add(total);
let answer = torch.cat(lst, 0);
out.set("config_audit", answer);
{
"config_audit": [
7087872,
7087872,
39385344,
46473216
]
}Return [per_block, all_blocks, embeds_plus_lnf, grand_total] for any [d_model, d_ff, layers, vocab, max_seq] configuration with biased projections and tied token embeddings.
Read the result carefully
Two proportions stand out in [7087872, 85054464, 39385344, 124439808]. First, inside every block, the two-layer feed-forward network holds 4,722,432 of the 7,087,872 scalars, almost two-thirds of the block, while the four attention projections hold one-third.
Second, storing 124,439,808 parameters in 32-bit floating point ( bytes each) already occupies bytes, nearly half a gigabyte before gradients, optimizer states, or activations are allocated. Exact paper formulas still explain every single weight, yet no human hand will ever inspect a 124-million-cell array directly.
Recap
- One Transformer block with biased projections and two LayerNorms stores scalars.
- Weight-tied token embeddings, learned position embeddings, and final LayerNorm add scalars outside the repeated stack.
- For GPT-2 small (
[768, 3072, 12, 50257, 1024]), twelve 7,087,872-parameter blocks plus 39,385,344 embedding scalars sum to 124,439,808 parameters.