LLM Temperature & Top-P Sampling Visualizer

An interactive visualization using 12 built-in mock token probabilities that shows how temperature and top-p (nucleus sampling) reshape an LLM's output distribution - a local simulation, not a real model call.

FreeOnline Tool
Loading…

How to Use

  1. Drag the "Temperature" slider (0 to 2, step 0.05) to see how the probability distribution flattens as temperature rises and sharpens as it falls.
  2. Drag the "Top-P" slider (0 to 1, step 0.05) to watch low-probability tokens beyond the cumulative threshold get cut off (shown grayed out).
  3. Or click one of the preset buttons (Deterministic, Balanced, Creative, Wild, Default) to instantly apply a common T/Top-P combination.
  4. Check the three stat cards above the chart: distribution entropy (higher = more random), the number of active tokens (probability greater than 0), and the current top token with its percentage.
  5. The token probability bar chart below updates in real time - bar length reflects relative probability, and tokens cut by Top-P appear in light gray with reduced opacity.
  6. Click "Load Sample (Default Distribution)" any time to reset back to Temperature = 1.00, Top-P = 1.00.

Features

  • 12 fixed mock tokens with baseline probabilities (fruit names standing in for vocabulary candidates), simulated entirely client-side - no real LLM API is called
  • The Temperature slider applies the standard algorithm: convert probabilities to log-logits, divide by T, then re-apply softmax to adjust distribution sharpness
  • The Top-P slider sorts tokens by probability descending, keeps only tokens within the cumulative probability threshold, renormalizes them, and zeroes out the rest
  • Live computation of three stats: distribution entropy, count of active tokens, and the current top token with its probability
  • Five preset parameter combinations (Deterministic / Balanced / Creative / Wild / Default) for one-click comparison of common sampling strategies
  • Bar-chart visualization that clearly distinguishes "kept" tokens from those "cut by Top-P"

Use Cases

Build intuition for the temperature parameter
Before calling an OpenAI/Anthropic-style API, drag the slider to feel how the output distribution shifts continuously from "deterministic" to "random" as temperature moves from 0 to 2, informing what value to pick.
Understand how top-p (nucleus sampling) truncation works
Watch how lowering top-p from 1.0 progressively excludes low-probability candidates from the sampling pool, clarifying how top-p interacts with temperature.
Use as a teaching aid for training or onboarding
Explain LLM sampling parameters to new teammates or students with this visual tool instead of pure formulas, making the distribution changes easier to grasp.
Compare common preset configurations
Cycle through the five presets ("Deterministic," "Balanced," "Creative," "Wild") to compare their resulting entropy and active-token counts, helping decide on sensible defaults for a given use case.

FAQ

Is this tool actually calling GPT or Claude's API to sample tokens?
No. It uses 12 fixed, built-in mock tokens with preset probabilities. All math (softmax scaling, top-p truncation) runs locally in your browser - no real LLM endpoint is ever called.
Different providers use different temperature ranges - is 0-2 here accurate?
0-2 is a general demonstration range chosen to clearly show the transition from a sharp to a flat distribution. When calling a real API, follow that provider's documented range (some cap temperature at 1, others at 2).
How exactly is "distribution entropy" calculated?
Using the standard information-entropy formula H = -Σp·log2(p), summed over the probability distribution after temperature scaling and top-p truncation have both been applied. Higher entropy means a more uniform (more random) distribution.
Does setting top-p to 1.0 truncate any tokens?
No. Top-p = 1.0 keeps the full cumulative probability range of all candidates, so only temperature affects the distribution at that point.
Can I edit the built-in token list or starting probabilities?
Not currently - the 12 tokens and their base probabilities are fixed demo data, kept constant so every user sees the same underlying distribution change.