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.
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 / pj = exp(zi − zj) — only the gap matters
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.)
confidence = maxi pi
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:
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.