Lesson 01.04
How AI builds a sentence
You will be able to explain repeated next-token prediction.
What you’ll do
- FamiliarStart with something familiar
- IdeaThe idea
- Try itTry it
- EngineeringWhy this matters in engineering
- Apply itApply it
- Check1 question, with feedback
Start with something familiar
Analogy
Imagine writing a sentence by revealing one piece at a time. After writing “The capital”, the next piece depends on what is already on the page.
The idea
A typical generative LLM predicts a small piece of text, selects a continuation, adds it to the text and repeats. Each new piece becomes part of the input for the next prediction. This can produce a whole answer. A piece is formally called a token; we will examine tokens next.
Try it
SimulationBuild a sentence piece by piece
Click Generate next piece until the sentence is complete; reset and switch examples.
The capital of Germany is
IllustrativePredefined illustrative pieces, not live tokenizer output
Why this matters in engineering
When a chatbot streams an answer, the application can display output as it arrives rather than waiting for the entire response. Streaming and token prediction are related but not identical; a displayed chunk can contain multiple tokens.
Apply it
Exercise
Your turn
Describe what would happen if the first generated piece changed from “terminal” to “browser”.