llm-inference-lab
Weights
Speculative k

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.

0.0tokens / second
0 tokens0 ms/tokenacceptance n/a0 target passes
Nothing generated yet. Press Generate. Then try int4 with speculative k = 4 and watch which drafted tokens the target model accepts.

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.

Without a cache the whole context is recomputed every step. Open dots appear after Measure.

Perplexity against bits per weight

Held-out text, lower is better.

Labels give the change against float32.

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.