Learning curve
Loss is how surprised it is by the real next character. Lower is better.
training texttext it has never seenpure guessing
Live experiment · by Grady Davis
The same kind of network behind modern AI assistants, just tiny: 62,000 parameters instead of billions. Every layer and every derivative is written by hand in plain JavaScript, and it’s training right now on your CPU cores. It starts out knowing nothing. Watch the text.
Loss is how surprised it is by the real next character. Lower is better.
training texttext it has never seenpure guessing
Each character’s learned vector, flattened to 2D. Letters that behave alike drift together.
vowelsconsonantscapitalspunctuationspace & newline
Give it a start. It continues one character at a time, rolling weighted dice from its own odds.
Its probability for each possible next character after your prompt, updated as it trains.
Attention: for the next character, how much each head weighs every earlier character. Brighter means more.
Same prompt, same dice, at each milestone. This is the whole story of training.
Under the hood
About 1,017 lines of JavaScript and CSS, no libraries, no server, covered by 10 automated tests. AI does most of the typing; the engineering is mine.
No autograd. The backward pass for layer norm, attention, GELU, the linear layers and the tied output head is derived on paper and written out. Every tensor’s gradient is checked against finite differences to better than one part in 100,000 before anything ships.
Training is synchronous data parallel, the way big models train across GPUs: each Web Worker gets the weights, samples its own batch, and sends back gradients. The page averages them, clips them, and takes an AdamW step with warm-up and cosine decay.
Weights are transposed so every matrix multiply is a dot product with its running sum in a register. GELU uses its one-exp sigmoid form. A separate worker writes the samples and draws what it’s looking at, so the page never stalls.
This is the architecture idea, not the scale. Real assistants have billions of parameters, read trillions of words and train for weeks on thousands of GPUs. This one reads a few hundred thousand characters for a few minutes. Shakespeare text is public domain; nothing you paste leaves the tab.