Ask a language model to tell you a bedtime story twice in a row, and you will get two completely different stories. Yet ask it for the capital of France twice in a row, and it will say Paris every single time.
How can the exact same network—with the exact same frozen weights—be both a rock-solid encyclopedia and an unpredictable storyteller?
The secret happens at the very final step of every single word. Remember: the transformer does not output one word. It outputs a glowing skyline of chances across its entire vocabulary—tall bars for likely words, medium bars for interesting runner-ups, and tiny slivers for weird words. To actually speak, the model has to pick one bar. That picking process is called Sampling.
1. The Temperature Dial
Before spinning the wheel to pick a word, we can reshape the skyline using a single dial called Temperature:
- Cold (near 0.0): The tallest bar stretches toward the ceiling while every runner-up shrinks to nearly zero. The model becomes deterministic—always picking the #1 safest guess.
- Balanced (around 0.7 – 1.0): The natural skyline shines through. Good alternatives share real slices of the wheel, creating lively, natural prose.
- Hot / Wild (above 1.4): The peaks flatten and the tiny weird bars rise up to meet them. Suddenly, absurd words compete on almost equal footing with sensible ones!
Drag the Temperature slider below and watch the eight candidate bars reshape in real time. Then hit Spin the Wheel a few times at cold, warm, and hot settings to feel how the picks change.
2. Trimming the Absurd Tail: Top-K & Top-P
Even at a gentle temperature, there is a hidden trap: a language model's vocabulary contains tens of thousands of tokens. Individually, words like spoon or refrigerator have tiny chances—but add thousands of tiny slivers together, and once in a while the wheel will land on complete nonsense.
To keep creativity without the nonsense, we place a glowing cutoff curtain that hides the unlikely "long tail" before spinning:
- Top-K keeps a fixed count of the tallest bars—say, the top 3 or top 4 words—and dims everything else.
- Top-P (Nucleus Sampling) is even smarter. Starting from the tallest bar, it keeps adding bars until their combined glow fills P% of the meter (for example, 85%). Everything beyond the curtain fades away.
Why do most modern assistants love Top-P? Switch between the Creative Story and Factual Answer contexts below and watch how Top-P automatically narrows when one answer is obvious—and widens when many answers are great!
Turning temperature down does not make a model smarter—it makes it more predictable. Turning temperature up does not make it more imaginative in a human sense—it simply lets lower-ranked words win the spin more often. Great settings match the task: low for code and facts, medium for writing and brainstorming.
3. Watch a Story Diverge
Because every single word is sampled one after another, tiny differences compound like ripples in a pond. One slightly unusual word at step 3 shifts the probability bars at step 4, which opens a whole new branch at step 5.
Click Generate Fresh Trio below to run the exact same starter sentence through three temperatures side by side—Cold (0.1), Balanced (0.8), and Wild (1.6). Watch how Cold repeats the same safe groove, Balanced explores vivid new paths, and Wild tumbles into joyful chaos.