Lurker News
How small can a language model be while still doing something useful? I wanted to find out, and had some spare time over the holidays.

Z80-μLM is a character-level language model with 2-bit quantized weights ({-2,-1,0,+1}) that runs on a Z80 with 64KB RAM. The entire thing: inference, weights, chat UI, it all fits in a 40KB .COM file that you can run in a CP/M emulator and hopefully even real hardware!
It won't write your emails, but it can be trained to play a stripped down version of 20 Questions, and is sometimes able to maintain the illusion of having simple but terse conversations with a distinct personality.
--
The extreme constraints nerd-sniped me and forced interesting trade-offs: trigram hashing (typo-tolerant, loses word order), 16-bit integer math, and some careful massaging of the training data meant I could keep the examples 'interesting'.
The key was quantization-aware training that accurately models the inference code limitations. The training loop runs both float and integer-quantized forward passes in parallel, scoring the model on how well its knowledge survives quantization. The weights are progressively pushed toward the 2-bit grid using straight-through estimators, with overflow penalties matching the Z80's 16-bit accumulator limits. By the end of training, the model has already adapted to its constraints, so no post-hoc quantization collapse.
Eventually I ended up spending a few dollars on Claude API to generate 20 questions data (see examples/guess/GUESS.COM), I hope Anthropic won't send me a C&D for distilling their model against the ToS ;P
But anyway, happy code-golf season everybody :)

Comments (122) 36 threads

Show all comments

Showing thread 8 of 36

roygbiv21 reply#
Awesome. I've just designed and built my own z80 computer, though right now it has 32kb ROM and 32kb RAM. This will definitely change on the next revision so I'll be sure to try it out.
wewewedxfgdf2 replies#
RAM is very expensive right now.
tgv2 replies#
We're talking kilobytes, not gigabytes. And it isn't DDR5 either.
boomlinde3 replies#
Yeah, even an average household can afford 40k of slow DRAM if they cut down on luxuries like food and housing.
wewewedxfgdf#
Maybe the rich can but not all retro computer enthusiasts are rich.
charcircuit#
If you can afford to spend a few dollars without sacrificing housing or food, you are being financial irresponsible.
ant6n3 replies#
Busy cut down on the avocado toast!

Continue this thread — 3 replies

StilesCrisis#
thats-the-joke.gif
wickedsight1 reply#
I just removed 128 megs of RAM from an old computer and am considering listing it on eBay to pay off my mortgage.
nrhrjrjrjtntbt#
I wonder what year past 128M ram would pay off mortgage. Maybe 1985