Preparing a Dataset for Instruction Fine-Tuning
Once a model has been instruction fine-tuned, the natural next question is whether it actually got better.
Asking Whether the Model Actually Improved
Once a model has been instruction fine-tuned, the natural next question is whether it actually got better. This article is about the stage where that question gets answered. Before any training happens, the instruction data has to be ready, and after training, the fine-tuned model's responses have to be judged. The two tasks named in this article, preparing a dataset and organizing instruction data in training batches, both concern the instruction data used in fine-tuning. The judging step, automated evaluation, comes at the very end of the overall process.
What do you think happens?
Suppose you take three answers from the fine-tuned model, read them carefully, and decide the model is doing well. What can you safely conclude?
Reveal answer
You have a rough feeling for performance, and nothing more
Three answers cannot show how often the model fails, which kinds of questions it struggles with, or whether a change you made helped or hurt. Reading three responses gives a impression, not a measurement.
Why Reading Samples by Hand Breaks Down
The early approach to checking a fine-tuned model was to take a handful of examples from the test set, look at what the model wrote in response, and judge the quality by eye. In the material this article draws on, that approach was limited to three examples.
The problem is not only that three examples are few. Three answers cannot tell you how often the model fails, which kinds of questions it struggles with, or whether a change you made last week helped or hurt. The method also does not scale. Reading hundreds or thousands of responses by hand is slow, tiring, and hard to repeat consistently from one review to the next. A judgment that depends on how tired the reader is at the time is not a dependable way to compare two versions of a model.
Reading a few sample responses by hand gives only a rough idea of performance. It does not scale to larger numbers of responses, and it cannot by itself show failure rates or whether one version is better than another.
Handing the Scoring Job to a Second LLM
The solution the source develops is to let another, larger LLM do the scoring. In automated evaluation, the fine-tuned model writes responses to the test set questions, and a second model reads each response and assigns it a score. The second model does not need to be trained for this job in the course of the evaluation. It is an already trained model that is used only to read responses and score them.
The second model is described as larger, and that choice matters for the design. The evaluator needs to be at least as capable as the thing it is judging. If the judge is weaker than the model it scores, its scores would not carry much meaning. This is why the source moves from a small local model to a larger one when it discusses the options later on.
Compare this with manual sampling. Manual sampling has a person in the loop for every response, which is why it stalls at a few examples. In the automated version, the person designs the test set and reads the resulting scores, while the evaluator reads the responses. The same flow can be repeated on a larger set of responses without the reader being the bottleneck.
Where Evaluation Fits in the Three Stages
Instruction fine-tuning is organized as a three-stage process. The first stage prepares the dataset. The second stage fine-tunes the LLM. The third stage evaluates it. Automated evaluation belongs to the third stage. The source lays out nine numbered steps for the full process and shows which stage each one falls under, but the individual preparation steps are outside the scope of this article.
The source states the purpose of the third stage directly. Once the fine-tuned model has produced its responses, the goal is to quantify its performance by scoring those responses for the test set. This means the evaluator is not an extra add-on bolted onto the end of the work. It is the last step in the same pipeline that began with preparing the data.
Choosing Where the Evaluator Runs
The source develops the evaluator in two forms. The first version uses an existing instruction-fine-tuned 8-billion-parameter Llama 3 model developed by Meta AI. The second option uses a larger proprietary model. Each form has a different place where the evaluator runs and a different path the data takes.
Preparing a Dataset Versus Organizing Batches
Preparing a dataset sits inside supervised instruction fine-tuning. Supervised instruction fine-tuning is a process that trains a model using instruction data, and before that training can happen, the data has to be ready. Organizing instruction data in training batches is a related but separate task. It concerns how instruction data is arranged for training. Both tasks concern the same instruction data, but they are not the same job.
| Aspect | Preparing a dataset | Organizing instruction data in training batches |
|---|---|---|
| Relationship to fine-tuning | A step within supervised instruction fine-tuning | A related task that concerns how instruction data is arranged |
| What it operates on | The instruction data as a whole | The instruction data, as it is arranged for training |
| What it establishes | The readiness of the data before training | The arrangement of that data into batches used for training |
| Position in the illustration | Comes before batch organization | Comes after preparation |
Two related tasks that both concern the instruction data used in fine-tuning. The source does not describe the preparation steps or any particular batching method.
Following the Data Through Each State
The easiest way to see how the two tasks relate is to follow the instruction data as it moves through them. The diagram below traces its state at each point. It shows the order given in the source's illustration, with preparation before batch organization, and it does not imply any order beyond that.
Read the diagram carefully. The first transition moves the collection from a raw state into a prepared state, which is the readiness that dataset preparation establishes. The second transition takes that prepared data and arranges it for training in batches. Neither transition, as the source describes it, is a training step, and neither is the evaluation stage that comes last.
Worked Trace of a Small Evaluation Run
Scoring a test set instead of three sample answers
A developer wants to know whether a fine-tuned model improved. The developer has a test set of 500 questions. Reading three answers by hand would be the old method. Describe how the automated evaluation handles the full set. The numbers here are illustrative and are not from the source.
- 1Ask the test set questions
The fine-tuned model writes a response to each of the 500 questions, producing 500 responses.
- 2Pass each response to the evaluator
The evaluator, a second LLM such as the local Llama 3 8B model running through Ollama, reads each response.
- 3Collect the scores
The evaluator assigns a score to each response, so the developer has a score for every item in the test set rather than three impressions.
- 4Read the aggregate
Because every response has a score, the developer can see how often the model does poorly and compare the result with an earlier version, which the three-answer method could not show.
The same flow handles 500 responses as easily as three, and the result is a set of scores that can be compared across versions.
Mistakes Beginners Make With the Evaluation Stage
Common mistake Treating a few hand-read answers as proof that the model improved
Why it failsThree answers give a rough feeling only. They cannot reveal failure rates or which question types cause trouble.
Do this insteadScore the full test set with an evaluator so the results can be counted and compared.
Common mistake Choosing an evaluator that is weaker than the model it judges
Why it failsThe evaluator needs to be at least as capable as the thing it is judging, or its scores carry little meaning.
Do this insteadPick an evaluator with at least the capability the source calls for, and move to a larger model such as GPT-4 through the OpenAI API when the local model is not enough.
Common mistake Assuming Ollama can also train or fine-tune the model
Why it failsOllama is a tool for inference and does not support training or fine-tuning.
Do this insteadUse Ollama only to run the evaluator, and keep training as a separate stage.
Common mistake Treating automated evaluation as an optional extra after the pipeline
Why it failsEvaluation is the third stage of the same three-stage process that begins with preparing the dataset.
Do this insteadPlan the evaluation stage from the start, since it is the last step in the same pipeline.
Common mistake Using the words preparing a dataset and organizing batches as if they were the same task
Why it failsPreparation establishes readiness of the instruction data, while batch organization concerns how that data is arranged for training.
Do this insteadKeep the two tasks separate in your notes, even though both concern the same instruction data.
Checking Your Understanding of the Pipeline
A teammate says that automated evaluation is an optional extra that can be added after the fine-tuned model is delivered. Using the three-stage process, explain why this is not how the source frames it, and state where dataset preparation fits.
Hints
- Look at which stage automated evaluation belongs to in the three-stage process.
- Think about what the evaluation stage does with the responses the fine-tuned model has produced.
- Dataset preparation is the first stage, so it comes before fine-tuning and evaluation.
Key Takeaways
- Reading a few sample responses by hand gives only a rough idea of performance and does not scale, so a larger LLM can take over the scoring job.
- Instruction fine-tuning has three stages: prepare the dataset, fine-tune the LLM, and evaluate it. Automated evaluation is the final stage of that pipeline.
- The 8-billion-parameter Llama 3 model can run locally through Ollama as the evaluator, which keeps test set responses on your machine, while GPT-4 through the OpenAI API offers a stronger judge at the cost of sending responses to a web service.
- Preparing a dataset is a step within supervised instruction fine-tuning, while organizing instruction data in training batches is a related task that concerns how the same data is arranged for training.