ai/how-a-chatbot-writes-one-guessed-word-at-a-time.md
How a chatbot writes: one guessed word at a time
A chatbot doesn't plan its reply and then type it out. It repeats one small step: look at the text so far, give every possible next token (a word or piece of a word) a probability, pick one, add it, and go again.
This page lets you drive that loop yourself with a tiny next-word model built from twelve sentences, chop text into tokens with a toy tokenizer, and drag a temperature slider to see how the dice get loaded. Then it shows why a model trained to be likely can sound sure and still be wrong.