A ~111k parameter character-level transformer. Zero build step. Open this file in any browser.
| token embedding (vocab x dim) | |
| position embedding (block x dim) | |
| attention qkv + proj (per layer) | |
| MLP fc + proj (per layer) | |
| layer norms (per layer) | |
| final layer norm | |
| total |
tokens -> token embedding + position embedding
-> [ LayerNorm -> causal self-attention -> residual
LayerNorm -> MLP (GELU, 4x width) -> residual ] x n_layer
-> final LayerNorm
-> linear head (tied to token embedding)
-> next-character logits
pip install torch python train.py # writes out/tinypip0.pt python generate.py --prompt "ROMEO:" --tokens 300