# Z80-μLM: A Retrocomputing Micro Language Model

A 2-bit quantized language model, and the training pipeline for it, small enough to run as a 40KB CP/M binary on a Z80 processor with 64KB of RAM.

Z80-μLM is a small conversational language model, trained with quantization-aware training, built to run on a Z80 processor with only 64KB of RAM. Its weights are quantized to 2 bits each, packed four per byte, and inference uses only 16-bit integer arithmetic, generating text one character at a time by hashing input into 128 typo-tolerant, word-order-invariant buckets; the result is a roughly 40KB `.COM` binary, including inference code, model weights, and a chat-style UI, running on a 4MHz processor from 1976.

It ships with two pre-built examples, a casual-conversation chatbot and a 20-questions guessing game, plus tools for generating training data with an LLM (Ollama or the Claude API) and balancing class distributions across examples, and a training guide covering building from source and training custom models.

It runs on CP/M through emulators such as iz-cpm, or on a ZX Spectrum through Fuse; it is written in Python for training.

Website: https://github.com/HarryR/z80ai
