The Big Picture
Building an assistant like the ones you chat with happens in stages. Each stage has a different goal.
| Stage | What happens | Result |
|---|---|---|
| Pretraining | The model reads huge amounts of text and learns to predict the next token | A base model that continues text |
| Instruction tuning | It is trained on examples of questions and good answers | A model that follows instructions |
| Preference alignment | Humans or rules rank answers and the model is nudged toward better ones | More helpful and safer replies |
| Inference | You send a prompt and get a reply | What your app uses |
Stage 1: Pretraining
The model sees text with the next token hidden. It guesses, checks how wrong it was, and adjusts its numbers (parameters or weights) a tiny bit. This repeats an enormous number of times.
The wrongness is called loss. A common loss is based on the probability the model gave to the correct token. The lower the loss, the better the guess.
p(correct) = 0.9 loss = -ln(p) = 0.105 | p(correct) = 0.5 loss = -ln(p) = 0.693 | p(correct) = 0.1 loss = -ln(p) = 2.303 | p(correct) = 0.01 loss = -ln(p) = 4.605
If the model gave the right token a probability of 0.9, the loss is small. If it gave only 0.01, the loss is large. Training pushes the loss down.
Stage 2 and 3: Making It Helpful
- Instruction tuning teaches the format of a conversation, such as answering a question directly
- Alignment uses ranked examples or rules so replies are more helpful, honest and safe
- Methods have names such as RLHF and DPO. You do not need the math to build apps, but you should know they exist
Stage 4: Inference
Inference is when the trained model answers you. It reads your prompt and produces tokens one by one. Training is done by the model provider. As an app developer you mostly work at inference time, or you fine-tune a smaller model later.
Parameters, Data and Compute
| Term | Meaning |
|---|---|
| Parameters | The learned numbers inside the model. Bigger models have more |
| Training data | The text the model learned from. Its quality matters a lot |
| Compute | The computer power needed to train and to run the model |
| Knowledge cutoff | The date after which the model saw little or no data |
Practice
- Run the loss demo with p = 0.7 and p = 0.2
- Explain in your own words why a lower loss means a better model
- Write which stage you would use to teach a model your company's tone
Conclusion
Pretraining gives a model language skill, instruction tuning and alignment make it useful, and inference is where your apps use it.

