Verbatome / Chapter 06Block → next token13 min read

In this lesson

Logits, temperature, and the token that comes out

The final vector becomes a bet over the whole vocabulary, a decoding policy picks the token - and the untrained toy model has a surprise in store.

By the end, you can

  • Trace the path from the last output vector to logits, probabilities, and a sampled token.
  • Distinguish what the model computes from what the decoding policy chooses.

Before you start: The Transformer block, the floor a model stacks

The tower is built. Text became tokens, tokens became vectors, attention let them talk, and a full block reshaped them. At the very top sits one output vector - two numbers, in our toy. And a reader is waiting for a word. This chapter is the machine’s last mechanical step, the one chapter 1 promised: turn a vector into a bet over the whole vocabulary, then actually place the bet. It is also the chapter where our hand-built toy gets caught pretending to know English.

Observe the table read backwards

To score a word, the model computes a dot product between the context vector and - surprise - that word’s own embedding row from chapter 3. The same table, read backwards: rows that were lookups on the way in become scorers on the way out. Many production models genuinely share these weights; the trick is called weight tying. Each raw score is a logit; softmax - the accountant from chapter 4 - converts logits into shares of 100 %.

Predict the toy’s first word

The context is the course trace, “eat an”. Every number in this machine was written by hand for teaching, and none of it was ever trained.

Your bet

After “eat an”, which noun does our hand-built model actually bet on?

Nobody grades this. Commit, and let the instrument settle it.

Generation studio / from vector to token

The top of the tower produces a vector; the reader wants a word. Watch the vector become a bet, then let the decoding policy choose.

Adjust k and p

From vector to bet

Current context → output vector h = [3.659, 1.933]

WordLogit h · E[word]Share (after T)Final share
cat · #314kept4.39246.1 %
dog · #271kept4.02231.8 %
queen · #409kept2.95410.9 %
king · #408kept2.90710.4 %
bicycle · #734kept-0.8370.2 %
car · #733kept-0.8530.2 %
orange · #901kept-1.6380.1 %
apple · #612kept-2.2360.1 %

The loop, for real

Every draw reruns everything: causal block → logits → policy → token appended to the context.

eatan

die #2019

Manipulate the policy

There it is: cat, at roughly 46 % - and orange buried near the bottom at 0.1 %, with only apple faring worse. Hold that thought; it is the most instructive number in this course, and we will come back to it.

First, work the controls. Slide temperature down to 0.5: the winner’s share balloons. Slide it to 2: the distribution flattens, underdogs breathe. Note what never changes: the ranking. Then switch policies. Greedy always takes the maximum - press Draw a token a few times and watch the toy write “eat an cat cat cat…”, a real pathology called degeneration that plagued early text generation. Top-k and top-p cut the tail before drawing; full sampling draws from everything. The die makes each draw reproducible: same seed, same text, every time.

Challenge Two missions. One: find settings that stop the “cat cat cat” loop without touching greedy’s argmax rule - then explain what you actually changed. Two: no temperature, at any value, ever makes orange overtake cat. Prove to yourself why by watching the logits column while you slide.

Explain the division of labor

The pipeline you just drove has a strict division of labor, and it is worth naming, because public debate constantly confuses the two halves:

  • The model computes: context vector → logits → (with temperature and softmax) a probability for every word. That is where its “knowledge” lives.
  • The decoding policy chooses: greedy, top-k, top-p, full sampling - these never touch the model. They decide how boldly to spend the probabilities the model produced.

Temperature belongs to the second half. Dividing all logits by the same number rescales confidence but preserves order - which is exactly what the second challenge mission demonstrates. (Chapter 4’s “score sharpness” slider was a teaching lens on attention; this is the real generation temperature.)

  1. The tower outputsh = one vector
  2. The table scoreslogit(word) = h · E[word]
  3. The policy picksnext token → back into the context

Now the cat. Why does a machine with every mechanism in place - tokens, embeddings, attention, a full block, weight tying - bet on cat after “eat an”? Because mechanisms carry no knowledge. Every matrix in this toy was authored by hand to be legible, not to be right. The chapter 1 counting table, dumb as it was, at least learned from data; our beautiful tower has never seen any. Fluency of machinery and truth of output are entirely separate achievements.

Scale check. This toy bets over 8 nouns in 2 dimensions; a production model bets over roughly 100,000 tokens in thousands of dimensions, and its function words live in the same vocabulary as everything else. The mechanics you just traced are the same; only the scale and the training differ.

Reflect on what temperature can never do

Checkpoint

Greedy decoding picks “cat” here at every temperature. Why can't temperature change that?

Greedy decoding picks “cat” here at every temperature. Why can't temperature change that?

Connect the loop, then break the spell

The loop is closed. Text → tokens → vectors → attention → block → logits → probabilities → sampled token → back into the context: you have now touched every stage of the model map, and nothing in it is magic. But the toy’s confident “eat an cat” leaves exactly one mystery standing, and it is the big one: where do good numbers come from? Nobody hand-writes the matrices of a real model. The machine writes them itself, by being wrong millions of times and nudging every number to be slightly less wrong. That process - training - is the next chapter, and it ends with this same bet flipping to orange.

Sources and scope
  • Press & Wolf (2017) shows that sharing the embedding and unembedding weights - the tying this lab makes visible - improves language models.
  • Holtzman et al. (2020) documents degeneration under greedy and beam decoding and proposes nucleus (top-p) sampling.
  • The vocabulary is the eight handcrafted chapter 3 rows; the prefix’s function words exist only as input fixtures. No number here comes from a trained model - that gap is the point of the chapter.
  • Content and claims reviewed on 2026-07-18.