One job: guess the next token
You have heard the dismissal โ "it's just fancy autocomplete." Here is the uncomfortable truth this chapter delivers: that is accurate. And it is also one of the most misleading true sentences in all of technology. By the end you will be able to defend both halves โ the "true" and the "wildly misleading" โ with a straight face.
Start with the job, stated using everything you now own. Given the context โ the tokens so far (Chapter 7), each riding in as its arrow (Chapter 8) โ the model produces a probability distribution over every token in its vocabulary: one bar per token, all $V$ of them, roughly fifty thousand bars, rebuilt from scratch. Then one token is sampled โ Chapter 6's weighted die โ appended to the context, and the whole thing runs again. The entire job fits in one expression:
$$p(\text{next} \mid \text{context})$$In words: the probability of each possible next token, given all the tokens so far. That conditional bar "$\mid$" is Chapter 6's "given" โ read it as "the next token, given the context."
This generate-append-repeat cycle has a name: autoregressive generation โ a fancy word for "the output is fed back in." And that feedback has a consequence worth pausing on: one adventurous pick early in a sentence changes the context for every pick after it. That is why two runs of the same prompt can drift into entirely different paragraphs โ a snowball, not a script. There is no plan; there is only the next token, over and over, each one reshaping the ground for the one after it.
One honest promise about scope before we open the toolbox. Today we take the model's scores as given โ a box that somehow rates all fifty thousand candidates. How the box computes good scores is the story of Chapters 10 and 11. Today we nail down what the scores are and how they become choices: raw scores, then probabilities, then one sampled token.
The box's raw scores: logits
Here is what actually falls out of the box's far end โ and it is not probabilities. For each of the $V$ tokens the box reports one raw score: any number at all, positive or negative, no rules. The name for one of these scores is a logit (say it "LOH-jit"). A big logit means the box likes that candidate; the absolute numbers mean nothing on their own โ only how they compare.
Let's set up the worked example we will ride for the whole chapter, and let's be honest about the cheat inside it. The context is Chapter 6's old friend, "the cat sat on the ___", and we will watch just three candidates โ mat, couch, keyboard โ pretending, for arithmetic's sake, that these three are the whole vocabulary. Everything on this page scales to fifty thousand candidates without changing a single step; we shrink $V$ to $3$ only so the sums fit on one line. The box reports three logits โ call the letter $z$, the traditional symbol for a logit, with the bold vector $\mathbf{z}$ collecting all of them:
$$z_{\text{mat}} = 2.0, \qquad z_{\text{couch}} = 1.0, \qquad z_{\text{keyboard}} = 0.0$$In words: the box rates mat highest at 2.0, couch in the middle at 1.0, and keyboard lowest at 0.0. (One quiet note for the attentive: back in Chapter 6 these same three words carried 0.60 / 0.25 / 0.15 from counting storybooks. The model's learned opinion needn't match our little shelf of storybooks โ different source, different numbers, same three words.)
Why won't the raw scores do as they stand? Because probabilities, in Chapter 6's language, must obey two house rules: each must sit between 0 and 1, and together they must share exactly one unit of belief. Logits break both โ 2.0 is no probability, and a score of $-3$ would be nonsense as one. Notice that last point: negative scores are perfectly legal logits, and any converter we build has to swallow them without complaint. So we need a machine that turns any list of scores into an honest distribution โ and does it without scrambling the ranking the box worked so hard to compute.
We already built the tool for step one. Chapter 4 handed us a function that turns any number, positive or negative, into a positive one, with no ties at zero. Time to cash that check.
Softmax: scores become shares of belief
The recipe has two moves. Move one โ exponentiate. Run every logit through $e^z$, the exponential of Chapter 4. From that chapter's table, reused not rederived: $e^{2.0} \approx 7.39$, $e^{1.0} \approx 2.72$, and $e^{0.0} = 1$. All positive, order intact, no ties at zero. (A logit of $-1$ would have contributed $e^{-1} \approx 0.37$ โ a smaller share, still positive, still legal โ which is exactly why negatives cause the machine no trouble.) Move two โ normalize. Divide each by the total, $7.39 + 2.72 + 1 = 11.11$, so the three shares sum to exactly 1. That is Chapter 6's conservation of belief, engineered on purpose.
Here is the winner worked in full:
$$p(\text{mat}) = \frac{e^{2.0}}{e^{2.0} + e^{1.0} + e^{0.0}} = \frac{7.39}{7.39 + 2.72 + 1} = \frac{7.39}{11.11} = 0.665$$In words: exponentiate mat's score, then divide by the sum of everyone's exponentiated scores โ mat gets 66.5 percent of the belief. The other two follow the same recipe: $p(\text{couch}) = 2.72/11.11 = 0.245$ and $p(\text{keyboard}) = 1/11.11 = 0.090$. Check the conservation law: $0.665 + 0.245 + 0.090 = 1.000$. A real, legal distribution โ the bars of Chapter 6.
That machine has a name: softmax. In general form, for candidate $i$ out of a whole vector of logits $\mathbf{z}$:
$$\mathrm{softmax}(\mathbf{z})_i = \frac{e^{z_i}}{\sum_j e^{z_j}}$$In words: candidate $i$'s probability is $e$ to its own score, divided by the sum of $e$ to everyone's score. That $\sum_j$ is Chapter 6's add-them-all-up, and the $e$ is Chapter 4's exponential โ two old tools meeting inside one new machine.
Two properties make softmax feel inevitable, and both survive a hand-check. First: only the gaps between logits matter. Shift every score up by 1 โ scores $[3, 2, 1]$ โ and the distribution comes out identical.
Second: each $+1$ of logit multiplies a candidate's share of belief by $e \approx 2.72$. Mat sits exactly one logit above couch, and indeed $0.665 \div 0.245 \approx 2.71$ โ that is $e$, give or take a rounding crumb. Hold onto that fact; it is where most people's intuition goes wrong.
Notice, finally, the shapes of Chapter 6 hiding in here: softmax output can be peaked or flat depending on how spread out the logits are โ big gaps make spikes, small gaps make plains. Which raises an irresistible question: could we reshape that spread ourselves? Yes. That is the next section.
Temperature: the promised knob
Back in Chapter 6 we wrote an IOU: "a knob that reshapes peaked toward flat and back." Here it is, and it is one line of arithmetic. Before softmax, divide every logit by a number $T$ โ the temperature:
$$\mathrm{softmax}(\mathbf{z}/T)_i = \frac{e^{z_i/T}}{\sum_j e^{z_j/T}}$$In words: shrink or stretch all the scores by the same factor $T$, then convert to probabilities exactly as before. Everything downstream is untouched; only the logits going in are rescaled.
Work the cold case, $T = 0.5$, in full. Dividing by 0.5 doubles every logit, so $\mathbf{z}/T = [4.0, 2.0, 0.0]$. Now $e^{4.0} \approx 54.6$ โ hand-checkable by Chapter 4's rule, $e^4 = e^2 \cdot e^2 = 7.39 \times 7.39$ โ while $e^{2.0} \approx 7.39$ and $e^{0} = 1$, for a total of $63.0$:
$$p(\text{mat}) = \frac{e^{4.0}}{e^{4.0} + e^{2.0} + e^{0.0}} = \frac{54.6}{63.0} = 0.867 \qquad (T = 0.5)$$In words: at half temperature, mat's share climbs from 0.665 to 0.867; $p(\text{couch}) = 0.117$ and $p(\text{keyboard}) = 0.016$ get squeezed. The gaps between the scores grew, so the exponentials pulled apart and the distribution sharpened onto its favorite. Cold means confident.
Now the hot case, $T = 2$. Dividing by 2 halves every logit: $\mathbf{z}/T = [1.0, 0.5, 0.0]$. The $e$-values are $e^{1} \approx 2.72$, then $e^{0.5} \approx 1.65$ (the number whose square is $e$ โ check: $1.65 \times 1.65 \approx 2.72$), and $e^{0} = 1$, summing to $5.37$. The shares come out $p(\text{mat}) \approx 0.506$, $p(\text{couch}) \approx 0.307$, $p(\text{keyboard}) \approx 0.186$. (They add to 0.999 โ the missing 0.001 is rounding, not leaked belief.) The gaps shrank, the exponentials huddled together, and the distribution flattened. Hot means adventurous โ keyboard just doubled its odds.
Push the dial to its ends, stated as limits in plain language. As $T$ shrinks toward 0, the tallest bar takes everything โ that is Chapter 6's "greedy," the same word, now with a mechanism behind it. As $T$ grows huge, every candidate drifts toward an equal $1/3$ (or, in the real model, $1/50{,}000$) โ pure uniform chance, the model's opinion washed out entirely. Real systems ship with $T$ around 0.7โ1.0 as typical practice; coders drop it low for predictable answers, writers raise it for surprise.
Play the game
Enough arithmetic on paper โ here are the chapter's exact numbers, live and under your thumb. At $T = 1$ the three bars for "the cat sat on the ___" stand at 0.665 / 0.245 / 0.090, just as we computed. Drag the temperature slider and watch them reshape; press Sample to roll Chapter 6's weighted die and append the winner to the history strip.
One sentence on what you are holding: this widget is the entire output end of a real LLM. Production systems bolt refinements onto the die roll โ you will hear the names top-k and top-p โ but the spine is exactly this: logits, then $\mathrm{softmax}(\mathbf{z}/T)$, then a sample.
Autocomplete โ true, and wildly misleading
Grant the true half first, and generously. Mechanically, an LLM does what your phone keyboard does: it proposes the next piece of text. Your phone does it by counting โ which word usually followed the last one or two you typed? That is literally Chapter 6's storybook-shelf arithmetic (12 mats out of 20), running on your own texting history. Small context, simple counts, an honest little machine. So far the dismissal holds.
Now the misleading half โ and the whole thesis of this site in one contrast. The LLM is not counting recent pairs. It computes its fifty thousand scores fresh every single time, from the entire context, through one enormous composed function (Chapter 4's machines-feeding-machines) whose billions of dials $\theta$ โ theta, the collective name for every tunable number โ were tuned on a large fraction of everything humans have written. One word placed early โ Chapter 6's "wet" โ lawfully reshapes the scores at the far end of the paragraph. Your phone cannot do that. The difference is not one of degree but of kind.
Here is the deeper point, stated carefully. To autocomplete well โ at every position, across law briefs and lullabies and Python โ the scores must reflect grammar, facts, style, and the logic-shaped regularities of how ideas follow ideas. The training pressure is humble ("guess the next token"); what it takes to satisfy that pressure is not. The job description is autocomplete; the qualifications are most of human knowledge. That gap between a humble objective and the machinery it demands is the single most important idea on this page.
Why the LLM cares
This chapter is not one gear of the machine โ it is the machine's contract with the world, and the rest of the site fills in its two blanks. Blank one: how does the box turn "the wet cat sat on the" into logits that put towel on top? That machinery is attention and the transformer, Chapters 10 and 11 โ and you can already see the puzzle from here: "wet" sits five tokens back, yet it must reach forward and bend the scores at the blank.
Blank two: where do those billions of dial-settings $\theta$ come from? That is all of Part III. One seed, planted exactly as Chapter 4 promised: training grades the model by looking at the probability it gave the correct next token โ and if the model gave the right answer only $p = 0.1$, the natural logarithm of Chapter 4 converts that to a penalty of 2.3. (You were told back then that this number "returns wearing a suit"; here it is trying the suit on. The full tailoring is Chapter 12 โ no formula today.)
And every knob you have met in a real product now has a mechanism behind it. The "temperature" slider in an API is this chapter's $T$; "deterministic mode" is greedy; answers changing between runs is sampling; and pricing per token (Chapter 7) is charged per turn of this loop โ one full fifty-thousand-score computation per generated token, which is exactly why long answers cost real money. (Chapter 18 makes that loop fast; for now, just the name.)
Let's close Part II-so-far warmly. Text becomes IDs (Chapter 7); IDs become arrows (Chapter 8); and the machine's one move is to turn today's arrows into tomorrow's token (this chapter). You can now state, without hand-waving, what an LLM is: a function from a sequence of token IDs to a probability distribution over the next ID, sampled with a temperature knob, in a loop. Two chapters remain in Part II to open the box that makes those scores worth trusting.
What you now know
- An LLM's entire job is $p(\text{next} \mid \text{context})$: score every one of its ~50,000 vocabulary tokens, convert scores to a distribution, sample one token, append it, and play again โ autoregressive generation.
- The raw scores are logits โ any numbers at all โ and softmax turns them into an honest distribution in two moves: $e^z$ makes everyone positive (order intact), then dividing by the sum makes the shares total exactly 1.
- Our worked hand: logits $[2.0, 1.0, 0.0]$ became 7.39, 2.72, 1 under $e^z$, and shares 0.665 / 0.245 / 0.090 after dividing by 11.11 โ and each $+1$ of logit multiplies a share by $e \approx 2.72$.
- Only the gaps between logits matter: shifting all scores by the same amount leaves the distribution untouched โ $[3, 2, 1]$ gives 0.665 all over again.
- Temperature divides every logit by $T$ before softmax: $T = 0.5$ sharpened mat to 0.867, $T = 2$ melted it to 0.506 โ reshaping belief without touching what the model knows; $T \to 0$ is greedy, $T$ huge is uniform.
- "Fancy autocomplete" is true โ and misleading: predicting the next token well across all human text forces the scores to reflect grammar, facts, and style; and because the game rewards plausibility rather than truth, fluent confident errors (hallucinations) are the game played perfectly on the wrong question.
Where we're headed. One blank remains in the contract, and it's the big one: how does the box turn "the wet cat sat on the" into logits that put towel on top? The context isn't a single arrow โ it's a whole sequence of them (Chapter 8), and they need to talk to each other: "wet," sitting five tokens back, has to reach forward and change what the blank expects. The mechanism that lets token arrows look at each other, decide who matters, and trade information is called attention โ the single most consequential idea in modern AI. And here's the satisfying part: it is built almost entirely out of Chapter 2's dot products. You already own every tool it needs.