Next-token prediction generates text one word or token at a time, using the preceding context to choose what should come next. During training, repeated predictions refine associations between context and likely continuations. This can produce useful, human-like language without guaranteeing truth, logic, or understanding. section 4.2.1
Figure 4.6 An LLM sees this sentence nine times, each time learning from the prediction of a single word at the end of each of the nine sequences.
Shows how one sentence becomes multiple training examples, each ending where the model predicts a single word. section 4.2.1
The strategy works by:
- Using keywords and phrases in the preceding text to narrow the plausible next words. section 4.2.1
- Applying extensive association calculations refined through billions of training updates. section 4.2.1
- Producing fluent continuations even when a prompt contains a false premise, because the model is not trained directly for accuracy or contradiction. section 4.2.1
- Working best when a request resembles material in the training data, while degrading as the task becomes more unique. section 4.3
Figure 4.7 Context can help you make decent predictions about the next word. As you move from left to right, additional text that might occur in a sentence is added. The images in the thought bubble for each sentence show how the added context eliminates predictions.
Illustrates how adding context eliminates candidate continuations and makes the next prediction more constrained. section 4.2.1
A useful pattern with a dangerous edge
A request to calculate pi in Python resembles abundant training material, so the model can return correct-looking code. A request to translate that function into the esoteric language Modula-3 requires more extrapolation. The same predictive mechanism can also confidently explain an absurd claim about spaghetti because the question’s wording activates familiar material-property language. section 4.2.1 section 4.3
Listing 4.1 ChatGPT calculating pi in Python
def calculate_pi(terms):
pi = 0
for i in range(terms):
term = ((-1) ** i) / (2 * i + 1)
pi += term
pi *= 4
return pi
print(calculate_pi(1000000)) #1
Provides a concrete Python artifact produced for a familiar programming task. section 4.3








