Before we talk about data cleaning or learning-rate tricks, it helps to see what fine-tuning actually does. Training is one loop, run many times. Each time, the model looks at a small pack of examples, guesses the next piece of text, checks how wrong it was, and nudges its weights a tiny bit to do better next time.
Imagine practicing a skill with flashcards:
That is basically how a large language model (LLM) learns during fine-tuning.
The model never reads letters the way we do. A tokenizer turns text into a list of token IDs. Training packs those IDs into fixed-length windows (the context length) so the GPU can process many examples efficiently.
| Approach | Plain-English idea | Trade-off |
|---|---|---|
| Full batch | Use the whole dataset for one update. | Most accurate direction, but far too slow for big data. |
| One example at a time | Update after every single row. | Cheap, but the signal is very noisy. |
| Mini-batch | Update after a small group of examples. | Stable enough, and GPUs like this pattern. |
During training, the model predicts the next token at every position in the window, not only once at the end. That gives many teaching signals from each sequence.
Lower loss means the model is assigning higher probability to the real text.
Backpropagation figures out, for each trainable weight, which way to push it to reduce the loss. Then the optimizer takes a step:
new_weights = old_weights - learning_rate * gradient
| Term | Meaning |
|---|---|
| Step | One mini-batch → one weight update |
| Epoch | One full pass over the training set |
| When to stop | When loss on held-out validation data flattens — more training often means memorizing |
The wiggle in the training curve is normal. Each mini-batch is a random sample, so its loss is a noisy estimate of the “true” average loss.
Fine-tuning repeatedly shows the model mini-batches of tokens, scores next-token guesses with cross-entropy, and takes small optimizer steps downhill on that loss.