DevTools Logo

LLM Sampling Parameter Playground

LLM Sampling Parameter Playground

See temperature, top-k, top-p, min-p and repetition penalty act on a toy token distribution, one stage at a time.

Runs in your browser12 candidates · seed 42
Try an example

Candidate logits

12 / 60 tokens
TokenLogitSeenRemove

Decoding parameters

sampling

Filter pipeline

12 of 12 survive
Repetition penalty: 12 → Temperature: 12 → Top-k: 12 → Top-p (nucleus): 12 → Min-p: 12 → Renormalize: 12

Repetition penalty

l' = l < 0 ? l × penalty : l ÷ penalty (seen tokens only)

  • token_071.5%
  • token_114.4%
  • token_25.3%
  • token_32.6%
  • token_41.6%
  • token_51.2%
  • token_60.9%
  • token_70.7%
  • token_80.6%
  • token_90.5%
  • token_100.4%
  • token_110.3%

Temperature

pᵢ = exp(l'ᵢ / T − max) ÷ Σⱼ exp(l'ⱼ / T − max)

  • token_071.5%
  • token_114.4%
  • token_25.3%
  • token_32.6%
  • token_41.6%
  • token_51.2%
  • token_60.9%
  • token_70.7%
  • token_80.6%
  • token_90.5%
  • token_100.4%
  • token_110.3%

Top-k

keep the k highest probabilities (k = 0 keeps all)

  • token_071.5%
  • token_114.4%
  • token_25.3%
  • token_32.6%
  • token_41.6%
  • token_51.2%
  • token_60.9%
  • token_70.7%
  • token_80.6%
  • token_90.5%
  • token_100.4%
  • token_110.3%

Top-p (nucleus)

sort desc; keep the shortest prefix whose cumulative mass ≥ p (boundary included)

  • token_071.5%
  • token_114.4%
  • token_25.3%
  • token_32.6%
  • token_41.6%
  • token_51.2%
  • token_60.9%
  • token_70.7%
  • token_80.6%
  • token_90.5%
  • token_100.4%
  • token_110.3%

Min-p

keep pᵢ ≥ min_p × max(p), so the threshold follows the peak

  • token_071.5%
  • token_114.4%
  • token_25.3%
  • token_32.6%
  • token_41.6%
  • token_51.2%
  • token_60.9%
  • token_70.7%
  • token_80.6%
  • token_90.5%
  • token_100.4%
  • token_110.3%

Renormalize

pᵢ = pᵢ ÷ Σ surviving pⱼ

  • token_071.5%
  • token_114.4%
  • token_25.3%
  • token_32.6%
  • token_41.6%
  • token_51.2%
  • token_60.9%
  • token_70.7%
  • token_80.6%
  • token_90.5%
  • token_100.4%
  • token_110.3%

Final distribution

token_0: 71.46% · token_1: 14.43% · token_2: 5.31% · token_3: 2.64% · token_4: 1.60% · token_5: 1.18% · token_6: 0.88% · token_7: 0.72% · token_8: 0.59% · token_9: 0.48% · token_10: 0.39% · token_11: 0.32%

TokenOriginal logitPost-penaltyFinal probabilityStatus
token_05.005.0071.46%kept
token_13.403.4014.43%kept
token_22.402.405.31%kept
token_31.701.702.64%kept
token_41.201.201.60%kept
token_50.900.901.18%kept
token_60.600.600.88%kept
token_70.400.400.72%kept
token_80.200.200.59%kept
token_90.000.000.48%kept
token_10-0.20-0.200.39%kept
token_11-0.40-0.400.32%kept

Draw history (last 20)

Press Sample to draw a token.

Examples

Temperature 2.0

Input
Peaked preset, T = 2.0
Output
Bars flatten; more tokens survive top-p

Higher temperature compresses probability differences before any filter runs.

Top-k = 3

Input
Peaked preset, top-k = 3
Output
3 survivors, 9 tokens marked outside top-k

Temperature is monotonic, so top-k membership is unchanged until the logits themselves are edited.

Min-p on a long tail

Input
Long tail, T = 1.5, min-p = 0.1
Output
Low tail tokens removed after top-p

Min-p scales with the current peak, unlike a fixed absolute threshold.

About this tool

The LLM Sampling Parameter Playground explains decoding filters by applying them, not by describing them. You edit a small distribution of candidate tokens and watch repetition penalty, temperature, top-k, top-p and min-p act in the canonical order before the survivors are renormalized into a final probability distribution.

Each stage renders the surviving candidates as bars with the exact formula beside it. Tokens removed at a stage stay visible but are grayed out with the reason for their removal — outside top-k, past the nucleus boundary, or below the min-p threshold. The survivor table mirrors the chart as text, so the same data is available to keyboard and screen-reader users.

A seeded random generator draws tokens from the final distribution, and the 100-draw mode shows a reproducible histogram next to the expected probabilities. There is no model behind the playground: it is client-side math on a toy distribution, useful for building intuition before tuning a real inference server.

What this tool does not do

  • No real model, vocabulary or multi-step generation loop is involved.
  • Candidates are capped at 60 and the chart is a DOM bar view, not a canvas plot.
  • Beam search is outside the scope of this filter playground.

How to use this tool

  1. Pick a distribution

    Load a peaked, flat, bimodal or long-tail preset, then edit labels, logits and the seen flag in the candidate table.

  2. Set decoding parameters

    Adjust temperature, top-k, top-p, min-p, repetition penalty and seed. Zero and one are the documented 'off' values for k, p and the penalty.

  3. Read the stages left to right

    Each panel shows the formula and the candidates alive at that point; grayed bars include the elimination reason in their accessible text.

  4. Sample and compare

    Press Sample for a seeded draw or Sample 100× for a histogram. Copy the share link to send the exact distribution and parameters to a colleague.

Use cases

Tuning inference parameters

Understand what a temperature or nucleus change does before applying it to a self-hosted model.

Teaching decoding

Show students the mechanics of sampling with visible candidates and stable, reproducible draws.

Writing documentation

Capture accurate stage-by-stage explanations without inventing model calls or real vocabularies.

Filter order and off values

StageRule
Repetition penaltySeen tokens: l ÷ penalty for positive logits, l × penalty for negative logits; 1 = off
Temperaturep ∝ exp(l ÷ T) with max subtraction; T is clamped to 0.01–5
Top-kKeep the k highest probabilities; 0 = off
Top-pKeep the shortest sorted prefix reaching cumulative mass p; 1 = off
Min-pKeep p ≥ min_p × peak probability; 0 = off
RenormalizeDivide survivor probabilities by their total mass

The order is fixed and displayed because changing it changes which tokens survive.

Common mistakes

Mistake:Thinking temperature changes top-k membership.

Fix:Temperature is monotonic; only the probabilities move. Top-k and top-p use the transformed probabilities.

Mistake:Treating min-p as an absolute cutoff.

Fix:Min-p is relative to the largest surviving probability, so it adapts to peaked and flat distributions.

Mistake:Expecting a chat or model call.

Fix:The playground is a toy distribution editor; selected encodings and models are out of scope.

Mistake:Using a different seed per draw and expecting reproducibility.

Fix:Keep the seed fixed — the same seed and parameters reproduce the same histogram.

Frequently asked questions

What order do the filters run in?

Repetition penalty, temperature, top-k, top-p (nucleus), min-p, then renormalization. That order is fixed and shown in the playground because applying the filters in a different order can change which tokens survive.

Why does temperature not change top-k membership?

Temperature applies the same monotonic transform to every logit, so the ranking stays identical. It changes the probabilities that top-k and top-p operate on, but the set of top-k tokens is the same until you change the logits themselves.

When is min-p better than top-p?

Top-p keeps a fixed cumulative mass, which can admit too many low-probability tokens on a flat distribution. Min-p sets its cutoff as a fraction of the current peak, so it adapts as the distribution sharpens or flattens. Many inference stacks use both.

Does repetition penalty apply before or after temperature?

Before. The playground uses the common Hugging Face convention: seen tokens with positive logits are divided by the penalty and negative logits are multiplied by it, then temperature is applied to the adjusted logits.

What seed should I use for reproducibility?

Any integer works, including zero. The same seed, candidates and parameters always produce the same draw sequence because a mulberry32 stream is deterministic. Copy the share link to preserve the whole setup.

Does this tool call a model?

No. Candidates are a toy distribution you edit. Nothing is uploaded and there is no real vocabulary, so the playground is for understanding filter mechanics rather than predicting a production model's output.

References & standards