The Improviser · Lesson 1 — The Maths · Part 2 ← Course
Optional · go further · part 2 of 2

The maths — the engine under the odds.

The why behind Part 1's demo: why the model works in raw scores, why softmax turns them into probabilities, and how it finally commits to a note.

Part 1 showed what softmax does — turn scores into odds that sum to 100%. This page is the why. Two questions do all the work: where do those raw scores (logits) come from and why exponentiate them (softmax), and — once you have the odds — how does the model actually pick a note (argmax) and know how much to trust it (confidence)?

Each card gives the motivation first, then the formula, then a worked example you can follow line by line — using the same three notes (C, E, G) from the Part 1 demo.

The two mechanics, and why they exist.

Motivation first — why each step is there — then the formula, then the same numbers carried through by hand.

1 · Logits → softmax
What is a logit? It's the model's raw enthusiasm score for a note — like points a judge scribbles down before anyone turns them into percentages. Over our C-major phrase the scores might be C = 2.4, E = 1.0, G = 0.4, and something negative (say −3) for a note it dislikes. High means "I favour this here"; negative means "probably not." They're not percentages — they can be any size and don't add to anything tidy. (The name is short for log-odds; softmax is just the step that turns them back into odds. They come out of the network's very last layer — one raw number per note in the vocabulary.)

Why work in raw scores at all? It's far easier for a network to learn unconstrained numbers than to output valid probabilities directly (which must be positive and sum to 1). So the model does the easy thing, and we convert afterwards.

Why not just divide by the sum? Because logits can be negative, and a plain "divide by the total" would hand you negative "probabilities" — nonsense. Softmax fixes it in two moves. First it exponentiates (ez): that forces every value positive, and — the elegant part — turns an additive gap between two scores into a fixed odds ratio (a gap of 1 is always ≈ 2.7×, whatever the absolute numbers). Then it divides by the total so they sum to 1. A neat consequence: adding the same amount to every logit changes nothing — only the gaps matter.
pi = exp(zi) / Σj exp(zj) — softmax
pi / pj = exp(zi − zj) — only the gap matters
Worked, step by step · z = 2.4, 1.0, 0.4
1exponentiate: e2.4 = 11.02 · e1.0 = 2.72 · e0.4 = 1.49
2total them: 11.02 + 2.72 + 1.49 = 15.23
3divide each by the total: 11.02/15.23 = 0.72, 2.72/15.23 = 0.18, 1.49/15.23 = 0.10
4check: 0.72 + 0.18 + 0.10 = 1.00
Add 5 to every logit → 7.4, 6.0, 5.4 → you get the same 0.72 / 0.18 / 0.10. Shift them together and nothing moves; that's why "only the gap matters."
In Lesson 1: the engine behind every bar — and the demo on Part 1.
2 · Argmax & confidence
Why this step. Softmax hands you a whole spread of odds, but the model has to commit to one note. Argmax is just "which position holds the largest value" — take the tallest bar. And because softmax preserves order, the winner is the same whether you read the probabilities or the raw logits (argmax p = argmax z): you don't even need softmax to pick — you need it to report.

Why confidence matters. The height of that winning bar is the confidence — how far to trust the choice. Near 1 = sure; barely above the rest = a guess. That one number is what lets you set a threshold, hedge, or flag "the model isn't sure" — and it's the seed of hallucination, because a tall bar means most likely, not correct. (Always taking the top note is greedy decoding; whether to instead sample a lower note is exactly what Lesson 5's temperature dial controls.)
note = argmaxi pi
confidence = maxi pi
Worked · sure vs hesitant
Afrom card 1: C 0.72, E 0.18, G 0.10 → argmax = C, confidence 0.72 — a clear winner
Bnow closer logits z = 1.2, 1.0, 0.8 → softmax → C 0.40, E 0.33, G 0.27
argmax is still C, but confidence is only 0.40 — barely ahead
Same winning note, very different certainty. A wide logit gap gives a tall, lonely bar (sure); a narrow gap gives a flat spread (hesitant) — exactly what "leave it hanging" looked like on The Odds.
In Lesson 1: the note played is the tallest bar; confidence is its height.

Where to take it next.

Every idea above is a doorway. If you want to keep going, these are the next words to search — each is the natural step up from what you just saw:

Cross-entropy / log losshow a model is scored on its probabilities while it learns — the training signal behind softmax.
Log-probabilitieswhy models add log-probs instead of multiplying probabilities across a whole phrase (avoiding underflow).
Bayes' theoremupdating a probability when fresh evidence arrives.
Entropy & informationmeasuring how spread-out, or how surprising, a distribution is.
KL divergencehow far one distribution sits from another.

None of these are needed to carry on — but each deepens the picture of what "the improviser" is really doing under the hood. Several — probability, distributions, Bayes — are natural candidates for full, music-flavoured lessons of their own down the line.

That's Lesson 1 — free, start to finish.

You just saw how an AI chooses its next word, all the way down to the maths. The other 14 lessons build on it — how the model remembers a conversation, why it sometimes makes things up, how it searches your own files, and more. Same plain language, same hear-and-see-it style, all the way through.

Unlock all 15 lessons — $20.26 →
2026 founding price · one-time · yours forever · fair pricing by country
Buying for someone else? Gift this course →
Know someone who's decided AI isn't for them?

Send them Lesson 1 — it's free, no signup. If it clicked for you, it'll probably click for them too.

Go deeper — what this page does and doesn't cover optional

This is the output maths

Everything across both parts is about the model's output — how the raw scores (logits) become probabilities, and how the next note is chosen from them. That's the part Lesson 1 actually used, and it's genuinely most of what you need to reason about an LLM's behaviour day to day. (Scoring a whole phrase — multiplying the per-note probabilities, and the log-prob trick that keeps that from underflowing — is left for the "next words to search" list above.)

What's deliberately left out

It does not cover how the model produces those raw scores in the first place — the network that produces them, and how it is trained. That machinery is a much deeper rabbit hole, and this course leaves it out on purpose: you can build real intuition, and real things, without it.

If you do want to go there

The search terms are: neural networks, backpropagation, the transformer architecture, and self-attention. Fair warning — that path is a course (or three) in itself.