HomeAI & Machine LearningToken Sampling Lab 2D: Temperature, Top-k & Nucleus Sampling

Token Sampling Lab 2D: Temperature, Top-k & Nucleus (Top-p)

Interactive 2D simulator of how a language model picks its next word: a live sorted probability bar chart, a draggable cumulative-nucleus curve and a temperature-response curve, all computed from the same real softmax + top-k + top-p math.

AI & Machine Learning2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-artificial-intelligence-computer-science-2 ↗ Open standalone

Every time a large language model writes a word, it first computes a probability for every token in its vocabulary, then samples one. This 2D simulator lays that process out as three linked panels — a sorted probability bar chart, a draggable cumulative-nucleus curve, and a temperature-response curve — all driven by the same real softmax, top-k and top-p math a 3D bar-ring version of this lab uses. Drag the temperature, top-k, top-p and peak-sharpness sliders (or drag directly on the cumulative curve) to reshape the distribution, then press "Sample next token" to perform a real weighted random draw and append the chosen word to a growing sentence.

⚙ Under the hood

Watch a language model's next-token probability distribution reshape across three linked 2D panels — a sorted bar chart, a draggable cumulative-nucleus curve and a temperature-response curve — as you drag temperature, top-k, top-p and peak-sharpness sliders, then sample a real weighted-random token from it.

LLMsamplingtemperaturetop-pdecodingNLP

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)