Evaluating a Fine-Tuned LLM
Instruction fine-tuning is a three-stage process: preparing the dataset, fine-tuning the LLM, and evaluating the LLM.
Why Training Is Not the Last Step
By the time the chapter reaches this point, two large pieces of work are already finished. The first is a model that has been pre-trained and loaded into memory. The second is a dataset of instructions that has been cleaned, formatted, and turned into batches. Instruction fine-tuning is the step that connects these two pieces. The model is trained further, this time on instruction examples, so that it learns to respond to the kind of input the dataset describes.
Fine-tuning changes a model's behavior, but a changed model is not automatically a better one. After training, you still have to find out how well the model performs on the task you cared about. That question is the subject of this article: how a fine-tuned model is evaluated once training has finished. Keep one idea in mind as you read. Evaluation is a process that produces a number from a collection of model outputs, and each step hands a slightly different collection to the next step. The final number only makes sense if you understand what each step did to that collection.
The Three Stages at a Glance
Instruction fine-tuning is organized as a three-stage process. Stage 1 prepares the dataset. Stage 2 fine-tunes the LLM. Stage 3 evaluates the LLM. The diagram below places the steps described in this lesson under the stage each one belongs to, in the order they run. The full layout in the chapter numbers nine steps in total, and the steps shown here are the ones the lesson names.
Notice where the fine-tuning work sits. Stage 1 and Stage 3 surround it. Stage 1 produces the batched data loaders that the training step will consume, and Stage 3 looks at the responses the tuned model produces afterward. Stage 2 is the only stage in which the model's weights are trained, and it contains three steps: loading the pretrained LLM, running instruction fine-tuning, and inspecting the modeling loss.
What the Pretrained Model and Dataset Each Contribute
Fine-tuning does not begin from random weights. The starting model is the one loaded in the previous section, and fine-tuning continues training that model. The data side is the instruction dataset prepared earlier in the chapter. That dataset was processed at the start of the chapter, so the fine-tuning step does not repeat that preparation work. In other words, the pretrained LLM supplies the starting weights and the general capability already learned, while the instruction dataset supplies the examples that shape how the model should respond.
Fine-tuning also needs a way to compute loss and run training. The chapter already contains code for both, so the fine-tuning code imports two functions from chapter 5 instead of writing those routines again: calc_loss_loader, which handles the loss calculation, and train_model_simple, which runs the training procedure. Four inputs meet at the single fine-tuning step: the pretrained LLM, which is loaded and then trained further; the instruction dataset, which supplies the examples; and the two chapter 5 functions, which supply the loss calculation and the training procedure. The diagram below shows how these inputs feed that one step.
Finding Which Stage a Problem Belongs To
Suppose a run of the process produces a result you did not expect. The three-stage structure gives you a way to narrow the search. Ask first which stage the problem most likely belongs to, then look only at the steps inside that stage. If the data loaders are wrong, the cause lies in Stage 1. If the model is loaded incorrectly or the loss and training steps misbehave, the cause lies in Stage 2. If the responses look wrong after training finishes, the cause may lie in Stage 3, where responses are extracted and scored.
What do you think happens?
An averaged evaluation score is poor after training, and you then discover the batched data loaders were built incorrectly. Which stage does the cause belong to?
Reveal answer
Stage 1: Prepare dataset
Stage 1 produces the batched data loaders that the training step consumes, so a fault in the loaders is a Stage 1 fault even though its symptom appears in the final score.
From Test Set to One Score
Evaluation has its own internal progression. Each step changes the collection it works on: from inputs, to raw responses, to scored responses, and finally to a single average. The diagram below traces that collection. Read it from left to right and notice what the collection holds after each step.
Worked Example: Two Sets With the Same Average
Two response sets that share one average
Imagine a test set of four items, and a hypothetical scorer that gives each response a score from 1 to 5. The source does not specify a scoring scale, so this scale is an assumption made only for illustration. Set A and Set B each have four scored responses. Do they have the same performance?
- 1Record the per-item scores for Set A
Set A scores are 3, 3, 3, and 3. Every response is middling.
- 2Record the per-item scores for Set B
Set B scores are 5, 5, 1, and 1. Some responses are excellent and some are poor.
- 3Average each set
Adding the scores and dividing by the count gives 3 for Set A and 3 for Set B. The single averaged number is identical.
- 4Compare the per-item scores
The averages hide the spread. Set B has two responses scored 1, which the average alone does not reveal.
Both sets report an average of 3, but their per-item scores differ sharply. Keeping the per-item scores is what shows that Set B contains both strong and weak responses.
Mistakes When Reading an Averaged Score
| What the average shows | What the average hides | What to keep when you need detail |
|---|---|---|
| One summary number for the whole test set | The spread of individual scores | The per-item scores from the scored collection |
| A single overall level of performance | Which specific items scored poorly | The list of responses paired with their scores |
| A comparison between two runs | Whether two runs with equal averages differ per item | Per-item scores for both runs side by side |
What an averaged score reports and what it leaves out
Common mistake Treating the average as a complete description of quality
What it looks likeReporting that a model scored 3 and assuming every response was adequate.
Why it failsAn average summarizes the test set but hides the spread of individual scores.
Do this insteadKeep the per-item scores when you need detail about which responses succeeded or failed.
Common mistake Assuming two equal averages mean equal quality
What it looks likeSet A and Set B both average 3, so they are judged the same.
Why it failsDifferent per-item distributions can produce the same average.
Do this insteadCompare the per-item scores of both sets before drawing a conclusion.
Common mistake Blaming the scoring step for every poor number
What it looks likeAssuming a low average means the scorer is broken, without checking the stage the fault belongs to.
Why it failsA low score can come from loaders, the loaded model, or the training steps, which sit in other stages.
Do this insteadMap the symptom to a stage first, then narrow the search inside that stage.
Common mistake Trying to explain a single example from the final average alone
Practice: Locate the Problem
A fine-tuned model was trained correctly and its loader and loss checks passed, but after training finished its extracted responses look wrong. Which stage should you examine first, and why?
Hints
- Recall which stage is described as the one where responses are extracted and scored.
- Stage 2 is the only stage in which the model's weights are trained.
Summary
At a glance
- Instruction fine-tuning is a three-stage process: Stage 1 prepares the dataset, Stage 2 fine-tunes the LLM, and Stage 3 evaluates it.
- Fine-tuning continues training a pretrained LLM on the instruction dataset, reusing
calc_loss_loaderandtrain_model_simplefrom chapter 5 instead of rewriting them. - Evaluation runs the fine-tuned model on a test set, collects raw responses, scores each one, and averages the scores into a single number.
- An average hides the spread of individual scores, so keep per-item scores whenever you need detail.
- When a result looks wrong, map the symptom to a stage first, then narrow the search to the steps inside that stage.