The standard ways to make a language model faster and cheaper to run, written by hand and measured on a real trained model that runs in this page. Switch a technique on, press Generate, and see what it buys and what it costs in quality.
Request
Same src/ files as the tests and the benchmark.
Target: 4 layers. Draft for speculation: 1 layer, same tokenizer.
Live generation
Tokens per second counts compute time only.
tok drafted, acceptedtok drafted, rejectedtok chosen by the target insteadtok bonus after all accepted
Speed and quality for every setting
Recorded columns come from docs/results.json (node scripts/benchmark.mjs). The teal column is measured now, by this browser, with the same code.
Takes about a minute. Perplexity does not depend on speed, so only tokens per second is re-measured.
Speed against context length
Cost of one more token, log scale.
Perplexity against bits per weight
Held-out text, lower is better.
Batching
Each point is a batch size (1, 2, 4, 8, 16): decoding throughput against the latency of one step.
Try to break it: quantise too far (int2)
Two bits per weight leaves three usable levels. The same prompt runs at float32, int4 and int2, greedy, so only the weights differ.
Not run yet.
A bad draft model
The draft samples at a wrong temperature. Acceptance should drop, and the output must stay what the target alone would produce.
Not run yet.
A prompt past the context
The model only learned positions 0 to 127. A longer prompt is refused with a clear error rather than reading positions it never saw.
Not run yet.