Lab 3: overfit a tiny GPT¶
The model uses byte IDs directly, learned position embeddings, pre-normalized causal attention, SwiGLU feed-forward layers, residual connections, and a tied language-model head. It trains on the included tiny corpus and then samples bytes.
This is an overfitting demonstration, not evidence of useful generalization. The corpus is repeated so loss falls in seconds on a CPU.
Follow one batch¶
tokens [B,T+1]
├─ inputs = tokens[:, :-1] [B,T]
└─ targets = tokens[:, 1:] [B,T]
inputs -> logits [B,T,256]
logits + targets -> scalar cross-entropy
Experiments¶
- Set
n_layers=0; embeddings and output head form a weak baseline. - Untie embeddings and compare parameter count.
- Increase sequence length and time one step.
- Hold out one sentence and compare train versus validation loss.
- Save model, optimizer, step, generator, and data state; try an exact resume.