Train a byte-level GPT from scratch — entirely in your browser, in a Web Worker, on WebAssembly. The UI thread stays responsive throughout.
Runs the same matrix multiply on the WebGPU compute kernel and on the WASM kernel, checks they agree, and reports the speed-up. WebGPU-capable browser required (Chrome / Edge 113+).
In-browser training is single-threaded WebAssembly — comfortable up to
roughly 1M parameters. To train bigger (5–25M+ is fine on a
laptop), run the Python reference locally, where it uses your GPU
(Apple MPS / CUDA). bench.py measures what your machine
can handle; configs/model.small.json is a ready ~10.8M model.
git clone https://github.com/sarthakagrawal927/tinygpt
cd tinygpt
python -m venv python_ref/.venv && source python_ref/.venv/bin/activate
pip install -r python_ref/requirements.txt
# measure how fast your machine trains, at several model sizes:
python python_ref/bench.py
# train a ~10.8M model on your own text:
python python_ref/train.py --model-config configs/model.small.json \
--data your-text.txt --out checkpoints/run
# generate from it:
python python_ref/sample.py --checkpoint checkpoints/run --prompt "Once "