Level 3 · Module 16 · 10 minutes
Pretraining, fine-tuning and inference
- Describe pretraining as next-token prediction on a large amount of text.
- Explain what fine-tuning and human feedback add.
- Explain why a model still hallucinates after training.
A large language model is produced in stages, and the difference between those stages explains a lot about how it behaves. The biggest stage is pretraining. Later stages shape the model's behaviour, and ordinary use is a third, separate stage.
Pretraining: predict the next token
During pretraining, the model is given a very large amount of text and asked to predict the next token after a passage. The correct answer is simply the actual next token in the text, so no person has to label every example. When the prediction is wrong, the weights are adjusted. Repeating this over a huge amount of writing teaches the model the patterns of language, including many facts that appear in the text.
Fine-tuning and human feedback
Pretraining alone produces a model that continues text, which is not the same as answering requests helpfully. In fine-tuning, the model is trained further on examples of the behaviour wanted, such as following an instruction or writing in a particular format. People may also review and rank outputs, and these rankings help train the model towards answers that reviewers preferred. The details vary, and real pipelines are more complex than this summary.
Inference: using the frozen model
When you use the model, it is not learning. Inference uses the weights as they were saved. Your messages and corrections do not update them. Some services keep conversations and may use them later, and some offer memory features, but that is separate from the model learning in the moment.
Why it still hallucinates
The whole process trains the model to produce likely sequences, not to check facts. Nothing in the training loop guarantees truth. That is why a model can be fluent, helpful and wrong at the same time. This kind of confident mistake is often called a hallucination, and it is one reason a separate step, such as searching trusted documents or asking a person to verify, is needed for factual work.
A teaching picture, not a commercial system
This lesson describes the stages in a simplified form. Commercial systems use very large data sets, extensive evaluation and safety work before release. The sequence of pretraining, tuning and inference is broadly accurate, but the lesson skips most of the engineering detail.
Deepen Your Understanding
Reinforce what you have learned with recommended video tutorials from trusted educational creators.
A longer, optional general-audience talk about what large language models are, how they are trained and why they can sound convincing without being reliable.
Source: Andrej Karpathy on YouTube · checked 2026-11-27. The lesson is complete without the video.
Common misconception
A model trained on enough text becomes a reliable source of facts. Training teaches likely sequences of tokens, not a store of verified facts. Without a separate check, a model can still produce false statements fluently. Reliability comes from verification, not from the amount of training text alone.
Guided practice
Choose a paragraph and write the next word for five positions in a row, then ask a friend to do the same. Compare the choices and note why several are plausible. Explain in two sentences why this is like pretraining and why no model is trained. This is a paper exercise; no model is trained.
Knowledge check
Independent practice
Write a short example from your own work or daily life and decide whether it is AI, ordinary software or a mixture. Then explain why. Save it in your notes; no account is required.
Last reviewed: · Report a problem