You watched the model pick one next token. But one token isn't a sentence. This is the loop that turns a single prediction into a whole paragraph — and it's a loop you already know.
Generation is a loop. The model predicts one token, that token is added to the text, and the whole thing is fed back in to predict the next one.
while loop you already know — roughly text += predict(text), run again and again.The loop needs a stop condition. Models have a special token — the end-of-sequence (EOS) token — and when the model picks it, generation ends.
while (next != EOS). Pick EOS and the condition breaks — the answer is done.Because each token is fed back in, token N can't be computed until tokens 1…N-1 exist. Writing is strictly sequential.
You've watched a trained model write. But where do the weights that make each prediction come from? Next, how models learn — turning a giant pile of text into the numbers that power the loop.