Sampling the next token
A language model doesn't emit words — it emits a probability distribution over the next token. Everything we call "sampling" — temperature, top-k, top-p, min-p — is just reshaping that distribution before drawing from it. Drag the controls and watch the shape change; then press Sample and watch draws pile up where the probability is.
Thank you very
␣much99%␣very0.3%,0.3%much0.1%␣Much0.0%␣well0.0%␣highly0.0%␣greatly0.0%␣sincerely0.0%␣MUCH0.0%␣deeply0.0%␣good0.0%␣carefully0.0%␣best0.0%␣many0.0%␣hard0.0%
Showing top 16 of 50 candidates · 50 kept after filtering. Probabilities are over the dumped candidates (a softmax of the top-50 logits), not the full vocabulary. Draw repeatedly and the gold ticks converge to the bars.
How this demo is built
No model runs here. A one-time offline script (scripts/build_traces.py) ran
gpt2 once, dumped the top-50
(token, logit) pairs for each prompt to
src/data/sampling_traces.json, and committed that tiny file. Everything you see
is pure TypeScript (src/components/sampling-core.ts) reshaping that vector in
your browser — so the page stays a static asset with zero inference cost. It's the reusable
recipe for any interactive demo on this site: dump → JSON → typed island.