Skip to content
AI DemystifiedHow AI actually works
Lesson 03 of 22Foundationsbeginner4 min

How AI Responds

The Slot Machine: next-token prediction

How does AI generate text?

The model predicts the most likely next token, one step at a time. Think of a slot machine of candidates with probabilities. Temperature reshapes those odds. This lab uses an honest teaching engine: distributions re-sum to 1.

Simulated engine

Probabilities and full replies come from a client-side simulator, not a production API. The shape of sampling and temperature is real; the vocabulary is a teaching toy.
Balanced

Move temperature, then Send or Auto: bars and wording both change.

1
Package
2
Predict
3
Generate
4
Append

Press Send to package the request, then pick tokens by hand or run Auto for a full simulated reply.

Key Insight

Low temperature peaks on the top token. High temperature flattens the bars so unlikely words win more often. The model is not deliberating like a person: it is sampling from a learned distribution.

Optional deeper: attention

Attention lets each token look at other tokens in the window. Explore it below, or later in the Transformer lesson for the full stack.

Attention visualizer

Loading attention visualizer…

Check your understanding

1/5

How does AI generate the next word?

Sources, scope & review statusVerified Jul 29, 2026

Claims this lesson makes

  • Stable conceptAutoregressive models repeatedly score possible next tokens and sample or select one token before continuing.

Next content review: 2027-07-29. Source links establish the lesson's claims; interactive numbers remain labeled simulations unless explicitly identified as measured data.