Skip to the interactive
ExplainerTools Watch the 34-second film

AI · interactive

How does AI pick its next word?

Model · illustrative token logits

Every word, probability and control is drawn in code. Temperature reshapes fixed illustrative logits; the sample point chooses from the resulting distribution.

1 See

A chatbot does not write a paragraph in one leap. It repeatedly scores possible next tokens, selects one and adds it to the context.

2 Change

3 Understand

Watch the 34-second film
Model notes and sources

Model. Five illustrative next tokens have fixed scores (logits) z. Temperature T turns them into probabilities with softmax: pi = exp(zi/T)/Σjexp(zj/T). Lower T concentrates probability on the largest logit; higher T spreads it out. The sample point from 0 to 1 selects the interval it lands in, making the choice deterministic and inspectable in this tool.

Illustrative only. “The moon rose over the …” and the logits for horizon, trees, city, water and piano were written for this explainer. They are not output from a named model, are not calibrated, and must not be read as a benchmark. Real tokenizers often split words into smaller pieces, real vocabularies contain tens or hundreds of thousands of tokens, and products may use greedy decoding, top-k, top-p, repetition penalties or other sampling rules.

What temperature cannot do. A lower temperature does not make a model factually correct; it only changes how sharply it favors the scores already produced. A higher temperature does not create knowledge; it raises the chance of lower-scored continuations. The photo is an AI-generated illustration with a blank screen; every visible word, number and probability is code-drawn.

Sources: Google for Developers, Softmax (scores mapped to a probability distribution); Hinton, Vinyals and Dean (2015), Distilling the Knowledge in a Neural Network (softmax temperature); Holtzman et al. (2020), The Curious Case of Neural Text Degeneration (decoding and nucleus sampling).

An ExplainerTools Original.

Keep exploring

Up next

  1. 0:34Short · watchHow does an AI chatbot pick its next word?The same idea in about thirty seconds.
  2. Interactive · Computer ScienceWhy do AI agents need tools?
  3. Interactive · Computer ScienceHow high can you count on ten fingers?