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.
Candidate logits
12 / 60 tokens| Token | Logit | Seen | Remove |
|---|---|---|---|
Decoding parameters
samplingFilter pipeline
12 of 12 surviveRepetition 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%
| Token | Original logit | Post-penalty | Final probability | Status |
|---|---|---|---|---|
| token_0 | 5.00 | 5.00 | 71.46% | kept |
| token_1 | 3.40 | 3.40 | 14.43% | kept |
| token_2 | 2.40 | 2.40 | 5.31% | kept |
| token_3 | 1.70 | 1.70 | 2.64% | kept |
| token_4 | 1.20 | 1.20 | 1.60% | kept |
| token_5 | 0.90 | 0.90 | 1.18% | kept |
| token_6 | 0.60 | 0.60 | 0.88% | kept |
| token_7 | 0.40 | 0.40 | 0.72% | kept |
| token_8 | 0.20 | 0.20 | 0.59% | kept |
| token_9 | 0.00 | 0.00 | 0.48% | kept |
| token_10 | -0.20 | -0.20 | 0.39% | kept |
| token_11 | -0.40 | -0.40 | 0.32% | kept |
Draw history (last 20)
Press Sample to draw a token.
Examples
Temperature 2.0
Peaked preset, T = 2.0Bars flatten; more tokens survive top-pHigher temperature compresses probability differences before any filter runs.
Top-k = 3
Peaked preset, top-k = 33 survivors, 9 tokens marked outside top-kTemperature is monotonic, so top-k membership is unchanged until the logits themselves are edited.
Min-p on a long tail
Long tail, T = 1.5, min-p = 0.1Low tail tokens removed after top-pMin-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
Pick a distribution
Load a peaked, flat, bimodal or long-tail preset, then edit labels, logits and the seen flag in the candidate table.
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.
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.
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
| Stage | Rule |
|---|---|
| Repetition penalty | Seen tokens: l ÷ penalty for positive logits, l × penalty for negative logits; 1 = off |
| Temperature | p ∝ exp(l ÷ T) with max subtraction; T is clamped to 0.01–5 |
| Top-k | Keep the k highest probabilities; 0 = off |
| Top-p | Keep the shortest sorted prefix reaching cumulative mass p; 1 = off |
| Min-p | Keep p ≥ min_p × peak probability; 0 = off |
| Renormalize | Divide 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
Related tools
Agent Tool Flowchart Builder
Design agentic tool-call DAGs with decision branches and bounded loops. Validates reachability, cycle handling, and emits clean Mermaid flowcharts — fully in your browser.
AI Agent Memory & Buffer Simulator
Compare sliding window, summary buffer, and vector memory strategies
AI API Client SDK Generator
Generate typed API client SDK files from OpenAPI specifications or cURL requests
AI Code Explainer
Explain code snippets with grounded cloud AI
AI Code Security Auditor
Scan source code for high-confidence OWASP Top 10 vulnerabilities
AI Code Translator
Translate code into idiomatic implementations in another language