Skip to main content
Interactive 3D/Sampling Strategies: Temperature, Top-K, Top-P
Original (argmax)(20 active)
theandcatsatquickvocab tokens →prob
After Temperature(20 active)
theandcatsatquickvocab tokens →prob
Method
Temperature
Eff. vocab
19
Entropy
3.46 bits
Selected
-
Controls
Temperature1.0
0.1 sharp3.0 flat
Top-K10
120
Top-P (nucleus)0.90
0.11.0
Temperature: divide logits before softmax. Lower = peakier.

Top-K: keep only the K highest-prob tokens.

Top-P: keep smallest set summing to p. Adapts to distribution shape.

Sampling Strategies: Temperature, Top-K, Top-P - Interactive Visualization

The same LLM produces wildly different outputs depending on how you sample from the token distribution. Temperature scales logits (lower = more deterministic), top-K restricts to the K most likely tokens, and nucleus (top-P) keeps the smallest set of tokens whose cumulative probability exceeds P. This demo shows each strategy reshaping the distribution in real time.

  • Temperature slider - watch how values below 1.0 sharpen the distribution and above 1.0 flatten it
  • Top-K sampling - set K and see which tokens survive the cutoff on a live probability bar chart
  • Top-P (nucleus) sampling - see the cumulative probability curve and where the nucleus boundary falls
  • Compare greedy decoding (always pick the top token) vs sampled decoding on the same prompt
  • Understand why temperature=0 gives reproducible outputs and temperature=1.5 produces hallucinations

Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.