Interactive Lab ยท LLMs & Transformers

How do raw scores become clean probabilities?

A neural net's final layer spits out raw scores that could be anything-3, 12, 0.5. How do those become clean probabilities that sum to 100%? One function: softmax. It exponentiates the scores, then normalizes, so the biggest score gets an exaggerated share. Drag the logits and watch the distribution form.

๐ŸŽฌ Watch the 45-second explainer, then turn the knobs yourself below โ†“

โ–ถ The playground, drag each logit, then bend the temperature

-6+10
-6+10
-6+10
-6+10
-6+10
โ„๏ธ 0.2 ยท sharpflat ยท 4.0 ๐Ÿ”ฅ
ฮฃ probabilities100.0%softmax always sums to exactly 1.
winner cat its prob 42.6% entropy 0.00 / 1.00 bits certainty 0%

๐Ÿงญ Where this fits

Softmax is the last layer of every classifier and the heart of attention weights and LLM token sampling, logits become the probabilities behind every 'next word'. The shift-invariance you just proved is a real numerical-stability trick (subtract the max) present in every production implementation, and temperature scaling (see that lab) divides these exact logits.

The code that's actually running



  

๐Ÿ”ฎ Predict, then test

Set two logits nearly equal (say cat = 3, dog = 2.9) and drag the rest way down. At T = 0.2 vs T = 3, how does the split between the top two change? Now hit โ€œ+5 to every logitโ€predict what happens to the bars before you look (hint: softmax is shift-invariant, only the differences between logits matter).

The takeaway

Your new mental model of softmax