How a model learns: data, training, and prediction
On this page
Listen to this lesson · 2-minute audio overview
A model is not programmed with answers. It learns in two stages: first it absorbs patterns from enormous amounts of text, then it is shaped into an assistant that can follow instructions. This lesson walks through both.
On this page
Lesson 1 defined a model as software trained to predict what comes next. This lesson opens that up. “Learning” here does not mean learning the way a person does. It means changing numbers inside a system, based on examples, until the system gets better at a task. A model starts as a system of millions or billions of adjustable numerical values, called parameters, the values the model uses to make its predictions, and training adjusts those values.
1. Data: what a model is fed
Training starts with data, and for a language model that data is mostly text: books, articles, websites, code, conversations, reference works. Many large language models are trained on billions or trillions of tokens, far more text than a person could read in a lifetime, although exact dataset sizes are often not disclosed. Before training, the text is chopped into small pieces called tokens, because a model works with numerical representations, not with written words directly. A token might be a whole common word, a fragment of a rarer one, a punctuation mark, or another short character sequence. Each token is assigned a numerical ID. The model then converts that ID into a set of numbers that it uses in its calculations.
Where the data comes from shapes what the model can do: training on code can improve a model’s ability to generate and work with code, and training on material in multiple languages can help a model work across those languages. But training data is not the only influence. The model’s design, the training method, later training stages, and the tools connected to it all matter too.
2. Training: adjusting billions of dials
Think of a model’s parameters as billions of tiny dials. That is a metaphor, not a physical description: the dials are numbers used in calculations inside the model. At the start of training they hold small, carefully chosen starting values, and the model’s predictions are generally poor. Training turns those dials, a little at a time, so the predictions improve.
A central exercise in basic pre-training looks like this. Take a passage of text and give the model the beginning of it. Ask it to predict the next token. For example, given “The capital of France is”, the model might assign a high probability to “Paris” and lower probabilities to other words. A probability is simply a numerical estimate of how likely each possible next token is, according to the model. Training compares those probabilities with the actual next token and calculates a numerical error, called loss: a lower loss means the model assigned higher probabilities to the correct next tokens, on average. An optimization method then uses that error to adjust the parameters, so that correct next tokens become more likely in future. The general approach is called gradient-based optimization: gradients show how changing each parameter would change the loss, and a common underlying method is gradient descent. This process is repeated across enormous numbers of examples, processed in batches (a batch is a group of examples processed together), often over many passes through the data.
Nobody writes hand-made grammar rules into the model. But the training data itself contains grammar, facts, and examples of reasoning, and the model learns to apply those learned patterns to new examples. That is how a system trained only to predict text can end up able to summarise, translate, and write code. Reproducing those patterns is not the same as verifying them, and it does not guarantee reliable reasoning.
Training is enormously expensive in computing power, involving huge numbers of calculations across many specialised processors. Training the largest models requires substantial computing infrastructure and capital, making it accessible to only a limited number of organisations. Using a trained model, called inference, avoids repeating the original training, but serving a large model still needs significant computing resources, especially for long conversations and high-volume use.
3. After pre-training: shaping the model
Pre-training produces a model that has learned to continue text. It may already answer some questions, by completing question-and-answer patterns it has seen, but answering well is not what it practised. That is why most language models designed to act as assistants undergo further training, called post-training, before they reach you as an assistant.
Post-training can take several forms. Supervised fine-tuning trains the model further on examples of good answers. Preference training uses comparisons or ratings of responses to help optimize a model toward more desirable outputs. Those comparisons can come from people, from automated evaluators, or from machine-generated feedback. Reinforcement learning adjusts the model based on reward signals, for example for answers that follow instructions well. A reward is a numerical signal indicating how desirable a result is according to the training objective. The exact recipe varies from model to model, and some go through several post-training stages.
This is also why a product like ChatGPT is not just a model. It is a model combined with surrounding software. This may include system instructions the user never sees, conversation history and, in some products, persistent memory, safety rules, and tools such as web search. Behaviour is shaped both by the model’s training and by these application-level instructions and controls. Pre-training builds broad capabilities; post-training and the product around it adapt those capabilities into something that answers questions and follows instructions.
4. Prediction: what the model does when you use it
When you type a prompt, the model uses the prediction capability developed during training: it predicts the next token. It uses the available conversation context, including your prompt, relevant earlier messages, and any additional instructions supplied by the application. There are limits to how much context it can process at once, and the application may shorten or summarise older messages. The model calculates probabilities for the possible next tokens, selects one, adds it to the text, and repeats. Each selection becomes part of the context for the next one, so a reply grows token by token.
It does not always select the most probable token. That approach is called greedy decoding, and with all other conditions fixed it tends to produce the same continuation every time. Often the model instead samples, selecting a token from the probability distribution, so less likely tokens sometimes get picked. If several words are plausible, sampling allows the model to choose between them rather than always taking the most probable one. A setting called temperature controls how concentrated or spread out the probabilities are before sampling. At low settings the model favours the most probable tokens more strongly. At higher settings less probable alternatives have a greater chance of being selected. This can make responses more varied, but it does not guarantee creativity and it does not improve factual accuracy. Some applications expose temperature or related sampling controls, sometimes under labels such as “creativity”, and some do not.
This is one reason the same prompt can give different answers on different days. Sampling is one cause; model updates, changed system instructions, and different context are others. The model generates its response rather than simply retrieving a stored answer, although the application may supply retrieved information as context. Models can also memorise and reproduce passages from training data. Many AI products combine the model with retrieval, fetching relevant information from external sources and supplying it as additional context.
More data is not automatically better
It is tempting to think more data is always better. It is not. What matters is also what the data contains, how reliable and relevant it is, how diverse it is, and how it is selected. A model learns the patterns in its data, including the bad ones, so training on text full of errors and confident nonsense can reinforce incorrect patterns, making the model more likely to reproduce them. Carefully written text can also contain false information, and messy internet discussion can contain valuable explanations, so data cleaning is not a guarantee of accuracy.
Many developers therefore filter their training datasets, removing low-quality material, deduplicating them by removing repeated or near-identical copies, and balancing sources by adjusting how much different categories of material contribute to the training dataset. Even carefully selected datasets still contain gaps, errors, and biases. Data quality is one factor among several, alongside the model’s size, its design, and how it is trained.
What training does not guarantee
Training gives a model patterns and relationships learned from examples, not a searchable fact table. Three limits follow from that, and they help explain several common frustrations people have with AI:
- It can be fluent without being right. A hallucination is an output that presents false or unsupported information as though it were true. Hallucinations can happen when information is missing from training, when the model has learned an incorrect pattern, or when it makes an unjustified guess. Predicting plausible text is not the same as checking whether a statement is true. A model can learn factual relationships, recognise contradictions, and sometimes correct itself, but its training objective does not guarantee that the most probable continuation is factually correct. Lesson 4 covers this in full.
- Its knowledge has an approximate cutoff, not a clean expiry date. Developers may publish a knowledge cutoff, an approximate date indicating how recent the information in a model’s training data may be, but different sources cover different periods, so it is not a precise boundary. Information supplied at runtime, in your prompt, in a document you upload, or through tools such as web search, can give it newer information. Web search does not change the original training cutoff; it supplies additional context while the model is being used.
- Fluent language is not proof of understanding. A model can produce convincing explanations without reliably checking whether they are correct. It can sound confident while being wrong. Training optimises for plausible continuation, not for truth, so a fluent sentence and a true sentence are different things. That is why checking matters, and why the human stays in the loop.
Try it: what happens when a model does not know?
See prediction in action with a chatbot you already use. About 10 minutes.
- Ask something widely known. Enter “The capital of the country that hosted the first modern Olympic Games is” and ask the chatbot to complete the sentence three times. The expected answer is Athens, Greece: the first modern Summer Olympics were held in Athens in 1896. Does it give the same answer each time?
- Ask something it cannot know. Ask “What colour is the front door of my home?” Unless you have already told it, the chatbot has no reliable way to know. Observe what it does: does it admit that, ask for more information, or make a guess?
- Compare. Did it give a consistent answer to the familiar question? Did it acknowledge lacking information about the front door? If it made a confident guess, did that confidence make the guess more reliable? A confident-sounding answer is not proof that a model knows something, and familiarity does not guarantee correctness.
One response does not establish how reliable a model is. This exercise illustrates the difference between familiar information and information that is unavailable to the model, not a controlled test of correctness.
Key terms
- Model: a computational system trained to recognise patterns and produce outputs from inputs.
- Token: a small piece of text, a word, a word fragment, or a punctuation mark, represented numerically inside the model.
- Tokenization: the process of dividing text into tokens and assigning each token a numerical ID.
- Parameter: an adjustable numerical value inside a model. Training changes parameters to improve predictions.
- Batch: a group of training examples processed together during one training step.
- Pre-training: the initial large-scale training that develops broad capabilities, commonly through next-token prediction.
- Post-training: training stages after pre-training that adapt a model to answer questions, follow instructions, and perform specific tasks.
- Fine-tuning: further training of an existing model on selected examples. Supervised fine-tuning, which uses examples of good responses, is one common form.
- Supervised fine-tuning: further training on examples that show the model what good responses to particular inputs look like.
- Preference training: training that uses comparisons or ratings of responses to encourage more desirable outputs.
- Reinforcement learning: a training approach in which a model is adjusted using reward signals that indicate how desirable its outputs are.
- Loss: a numerical measure of how poorly a prediction matched its target. Training works by reducing loss.
- Gradient: information about how changing a parameter would change the loss.
- Gradient descent: an optimization method that uses gradients to adjust parameters in the direction that reduces loss. Most modern training uses variants of gradient descent.
- Inference: using a trained model to process an input and generate an output.
- Probability: a numerical measure, between zero and one, of the model’s estimated likelihood that a given token comes next.
- Sampling: selecting a token from a probability distribution, rather than always taking the most probable one.
- Greedy decoding: a method of generating text that selects the most probable next token at each step.
- Temperature: a setting that changes how concentrated or spread out the probabilities used during sampling are. It is a numerical setting, not physical temperature.
- Hallucination: an output that presents false or unsupported information as though it were true.
- Knowledge cutoff: an approximate date, often published by the developer, indicating how recent the information in a model’s training data may be.
- Retrieval: finding relevant information in an external source, such as a document collection or a web search, and supplying it to the model as additional context.
- Deduplication: removing repeated or near-identical material from a dataset.
Keep going
Next: Lesson 3, Talking to a model: prompts that work. You now know how a model learns. The next lesson is about the other side of the conversation: how what you type shapes what you get back, and why small changes to a prompt can change the answer completely.
Further reading on this site: Lesson 1, which sets up the model, chatbot, and agent distinction this lesson builds on.


