lab / 08

Next token

Every bead is one word a language model might write next, and every bin is a candidate word. Drop beads to finish the sentence, then turn the temperature down or up and watch the piles tighten or spread.

prompt

The cat sat on the

1.00

Around 1. These are the model's own odds, untouched: “mat” 49%, “moon” 0.5%.

This is what an LLM does for every word it writes: score every candidate, turn the scores into probabilities, and roll the dice. Temperature decides how loaded the dice are.

How this works

Each bin has a logit: the model's raw score for that word. Dividing every logit by the temperature and taking softmax turns the scores into probabilities that add up to 100%. Low temperature stretches the gaps between scores, so the favourite takes nearly everything. High temperature shrinks the gaps, so the odds even out.

A real Galton board makes a bell curve because every peg is a fair coin. This one is rigged, openly. Before a bead leaves the funnel, the board draws its word at random with those probabilities. That draw is the sample. The bead then takes a random route with exactly the right number of left and right bounces to reach that word's bin, so the bounces are real-looking but the piles follow the model, not a bell curve. The thin outline on each bar is that word's probability at temperature 1, the model's own odds. The amber routes show where beads are likely to go at the current temperature, and the dashed line in each bin marks where the pile should reach if the samples matched the probabilities exactly.

Started from an hourglass Galton board with a bead histogram.