cutaway ↖ LINCHPIN · AI Innovation Lab
Lesson 4 · How It Writes

It does not always pick
its best guess.

Once it is trained, the model writes by guessing the next character, adding it, and guessing again from what it now has. But it does not always take its top guess. One dial decides how adventurous it is. You are about to turn that dial on the trained model and watch the writing change in front of you.

Step 1 · Meet the dial, then make a call
Key term
temperature
Cold · frozenHot · wild

Why that word? Think of heat. Cold, and the model freezes onto its safest next character every time, so it loops and repeats itself. Hot, and its choices bounce around wildly, until the words stop making sense. One number sets how hot the model runs.

Now make a call

Turned cold, the model almost always takes its single most likely next character. Turned hot, it lets unlikely characters win too. In a moment you will turn this one dial yourself, from cold to hot, on the same line, changing nothing else. Before you do: which setting do you think writes something you would actually want to read?

Cold Warm Hot

The line for it to continue (change it to anything you like):

Now you try · the live model

Write something with it yourself.

Type any opening line. The real model, running live, continues it one character at a time. Lower the dial and it plays safe; raise it and it takes chances. It is not recalling a memorized passage and it does not answer questions; it writes brand-new text in Shakespeare's style, the same move you watched above.

Try
Temperature 0.80 Warm
Cold · frozenHot · wild
See the real code, line by line
Sampling Scores From: model.py · generate()
Why it mattersThis is how the model actually writes, one character at a time, and where the temperature dial lives.
Key conceptScore every possible next character, reshape the odds with temperature, then draw one at random.
What to look for"logits / temperature" is the dial; "torch.multinomial" is the weighted die that keeps the writing from repeating.
for _ in range(max_new_tokens):
idx_cond = idx[:, -self.config.block_size:] # crop to the context window
logits, _ = self(idx_cond)
logits = logits[:, -1, :] / temperature # focus on the last position
probs = F.softmax(logits, dim=-1)
idx_next = torch.multinomial(probs, num_samples=1)
idx = torch.cat((idx, idx_next), dim=1)
Hover or tap any line above. Its plain-English explanation appears right here.