Language Models · v1.0.5
2026-11-03 01:40:26

Already built
Built here

A single configuration object fixes every shape the model needs.
| key | GPT-2 124M |
|---|---|
vocab_size |
50,257 |
context_length |
1,024 |
emb_dim |
768 |
n_heads |
12 |
n_layers |
12 |
drop_rate |
0.1 |
Nothing downstream hard-codes a dimension.
A placeholder model establishes the data path before any internal component is real.
Two sentences of four tokens give output shape \([2,\ 4,\ 50257]\) — one unnormalized score per vocabulary entry, at every position.

Deep stacks suffer vanishing and exploding gradients. Normalization holds each layer’s outputs at a consistent scale.
\[\hat{x} = \gamma \odot \frac{x - \mu}{\sqrt{\sigma^2 + \varepsilon}} + \beta\]
emb_dim

A shortcut adds a layer’s input to its output, creating a shorter path for the gradient.
One pattern applied twice: norm, operate, drop, add.

\([B, T, \texttt{emb\_dim}]\) in, \([B, T, \texttt{emb\_dim}]\) out.

Input — embedding layers map token indices to dense vectors and add learnable positional embeddings, followed by dropout.
Body — a sequential stack of identical transformer blocks.
Head — a final layer normalization, then a bias-free linear projection into vocabulary space.
Output shape is unchanged from the placeholder: \([2, 4, 50257]\).
Parameter count
At 4 bytes per parameter: \(\approx 621.8\) MB of weights alone.
One architecture, four sizes
| Model | emb_dim |
n_layers |
n_heads |
|---|---|---|---|
| small | 768 | 12 | 12 |
| medium | 1,024 | 24 | 16 |
| large | 1,280 | 36 | 20 |
| XL | 1,600 | 48 | 25 |
Only the configuration changes.


Six generation steps from the prompt Hello, I am:
Hello, I am Featureiman
Byeswickattribute argue
Architecture alone does not produce language.