What happens each time an LLM writes a word

How does an LLM decide what to write next?

How LLMs work · about 5 minutes

An LLM writes one small piece of text at a time. It reads everything so far, gives every possible next piece a chance, picks one, adds it, and goes again. Here is that loop on a real model, with its real numbers.

Sketch: Xiaohei lifts the "mat" tile from a long counter of pieces to finish "The cat sat on the", then goes again