llm Client-Side Only

Top-K Sampling Playground

Simulate Top-K truncation filtering. Adjust K to prune unlikely tokens and view re-normalized probability distributions.

Concept Breakdown: How Language Models Sample & Select Tokens

1. The Ice Cream Shop (Temperature)

At Temperature 0.1, you always pick vanilla. It is safe and predictable. At Temperature 1.5, you randomly pick chili-mango or bubblegum. High temperature makes AI creative; low temperature makes it factual.

2. The VIP Guest List (Top-K)

Top-K says: "Only consider the top K contenders". If K=3, the AI throws away all other candidates and only chooses between the 3 frontrunners, preventing weird typos or nonsense words.

3. The Quality Filter (Top-P)

Top-P (Nucleus) adds probabilities until reaching P (e.g. 90%). If the model is 95% certain about one word, it picks that word immediately. If uncertain, it widens the net to include several good alternatives.

TEMPERATURE (T)0.70
0.1 (Greedy/Peak)1.0 (Balanced)2.0 (Chaotic)
TOP-K FILTER5
K = 1 (Argmax)K = 5K = 8 (All)
TOP-P (NUCLEUS)90%
10% (Tight)90% (Standard)100% (No filter)
Context:"The afternoon sun faded away, and the sky turned "[Predicting Next Token...]
CANDIDATE TOKENS (Green = Eligible for sampling, Grey = Filtered out)3 of 8 eligible
"blue"
74.5%
"clear"
15.5%
"dark"
10.1%
"cloudy"
pruned
"bright"
pruned
"vast"
pruned
"orange"
pruned
"infinite"
pruned

Quick Reference & Instructions

Simple steps, pro tips, and execution details

1

Provide Inputs

Type, paste, or select your values in the form fields below.

2

Instant Live Analysis

Calculations and formatting happen automatically with zero delay as you type.

3

Copy or Use Output

Copy results or apply the clean output directly to your projects.

How It Works

Orders candidates by probability descending, keeps strictly the top K choices, and scales their sum to 100%.

Frequently Asked Questions

Common questions about calculations, assumptions, and edge cases.

Yes, Top-K Sampling Playground is 100% free with unlimited calculations and zero paywalls or subscriptions.