More on the topic...
Generating detailed summary...
Failed to generate summary. Please try again.
On February 11, 2026, Andrej Karpathy released microGPT: a single Python file—243 lines long—that builds, trains and runs a GPT model from scratch with no external dependencies beyond os, math, random and argparse. Instead of hundreds of packages you pip-install before even seeing code, microGPT stands alone. It downloads a list of baby names, converts each character into a number using two special tokens (<BOS>, <EOS>) plus the sorted unique characters from the dataset, and then learns to predict the next character in a name. The end result is a toy GPT that generates new, realistic-sounding names.
About 40 lines of code implement an entire automatic differentiation engine mirroring PyTorch’s autograd. A custom Value class wraps every number, tracks its children in the computation graph, and defines backward functions for addition, multiplication and other ops. When you call .backward(), the code builds a topological ordering of operations and propagates gradients back through that graph. This lets the model adjust its randomly initialized weight matrices—embeddings, attention projections and feed-forward networks—using gradient descent.
The transformer itself lives in roughly 100 lines. Karpathy defines embedding matrices (wte for token, wpe for position), draws random Gaussian weights, then in each layer applies RMSNorm, projects inputs into queries, keys and values, computes scaled dot-product attention across four heads, and feeds the result through a small two-layer MLP. With a 16-dimensional embedding, sequence length of eight and a single layer, microGPT uses about 4,000 parameters. The same architecture underpins GPT-4, but at a trillion-parameter scale. This project strips away every extra file and dependency to reveal the core math in clear, runnable Python.
Questions about this article
No questions yet.