
OpenAI’s new distillation feature can use answers from a stronger model to fine-tune a faster, cheaper one for a specific task. The company behind ChatGPT has added it to its fine-tuning suite, with models such as GPT-4o and OpenAI o1 able to help prepare training data for GPT-4o mini. Testing by Trelis Research shows where the approach helps and why a good evaluation matters.
Fine-Tuning Builds on an Existing Model
TL;DR Key Takeaways :
- OpenAI’s distillation feature uses teacher-generated examples in supervised fine-tuning.
- A small touch rugby job overfitted, making its correct answer to a training question a weak test.
- On 22 separate questions, fine-tuned GPT-4o mini answered about 17 or 18 correctly, up from roughly 8.
- Synthetic answers need checking, and evaluation questions should be kept separate from training data.
- OpenAI’s free evaluation option involves sharing results, which may not suit valuable industry data.
Pre-training creates a model from vast quantities of raw or minimally processed data, potentially trillions of tokens. Supervised fine-tuning starts with an existing model and trains it further on curated examples, typically questions and responses in chat format. A dataset can range from 10 rows in a simple demonstration to potentially millions.
Fine-tuning can help with domain knowledge when retrieval methods such as retrieval-augmented generation, cosine similarity or BM25 still produce poor answers. It can also be combined with those methods. If the model already knows the answer but formats it poorly, try prompt engineering first; fine-tuning becomes more useful when a broad range of questions makes prompts brittle, such as when answers need citations at the end or a particular chain of thought.
For structured responses, OpenAI’s Structured Outputs support in gpt-4o-2024-08-06 offers another route: developers can define JSON Schemas through the API’s response_format parameter with strict mode enabled. Fine-tuning addresses the wider task of teaching an existing model from examples rather than just specifying a response structure.
Distillation Supplies Examples for Training
Distillation overlaps with fine-tuning rather than replacing it. It is a shortcut for preparing training data, and it can be applied during pre-training or fine-tuning. A developer might use GPT-4o to train smaller AI models when the stronger model gives satisfactory answers but its cost or latency is too high for the intended task.
In black-box distillation, the teacher generates answers or sequences that become training examples for the student, without requiring access to the teacher’s weights. The demonstration uses this approach. In white-box distillation, backpropagation adjusts the student’s probability distribution for each token toward the teacher’s distribution, using a mathematical method called KL divergence.
That second approach requires access to model internals or at least probability distributions. OpenAI does not expose the necessary information, while open-source models do. With OpenAI’s released feature, the practical route is to generate and store examples, then use them in a supervised fine-tuning job.
A Touch Rugby Test Trains GPT-4o Mini
The test uses a Google Colab notebook with GPT-4o as teacher and GPT-4o mini as student. It begins by evaluating both models on touch rugby questions, then generates synthetic answers, fine-tunes the student and evaluates it again. Touch rugby was chosen because its rules are relatively obscure to language models; some questions were devised by Trelis Research and others generated with ChatGPT.
On a question asking whether a try is worth one or five points, GPT-4o correctly answered one point, while GPT-4o mini answered five. Five points is the value of a try in normal rugby. This baseline identifies a specific mistake to check after training, although a single answer cannot establish overall accuracy.
The notebook installs the OpenAI Python package and checks its version with pip show before selecting the teacher. The API key goes into Colab Secrets, where it is enabled and imported with userdata. The same OpenAI project in which the key was created must be used to find the stored data.
A response function calls the OpenAI client’s chat completions create function with a sports-rule-expert system message, a question, a low temperature and top-p of 0.9. That top-p setting restricts sampling to tokens making up 90% of the probability, excluding less likely tokens. A similar data-generation function sets store to true and adds metadata so the answers can be found as a dataset.
GPT-4o generates answers for the 10 questions, which can then be found in Chat Completions by filtering on the metadata tag. Only nine completions appeared at first; rerunning generation with a new tag produced all 10, and the reason for the missing completion was not established. Ten samples are the minimum needed for fine-tuning.
Selecting the stored samples and clicking Distill opens supervised fine-tuning with the questions and answers available for inspection. The job uses GPT-4o mini as the base model, the selected dataset and a model-name suffix. Validation data is omitted in this small test, although uploading it as a JSONL file is normally recommended.
The job uses default hyperparameters because the meaning of OpenAI’s learning-rate multiplier and details of its training process are unclear. It completes after 10 epochs, while a previous job on a larger dataset ran for three. Training loss falls nearly to zero, indicating overfitting on the small dataset; roughly one epoch is generally preferred to reduce that risk, but the unclear controls make better parameter choices difficult.
After the finished model name is copied into the notebook, the fine-tuned student answers the try question correctly. The exact question was in its training set, though, and the model had overfitted, so the result is not surprising. A practical evaluation needs separate questions worded somewhat differently.
A Larger Evaluation Tests Unseen Questions
A more rigorous pipeline starts with source documents such as the touch rugby rules, then systematically generates diverse questions with relevant background information. A strong model at low sampling temperature can generate answers, but the rows should be filtered so that only answers judged correct enter the training data. That requires an evaluation pipeline of its own.
The advanced test generated around 200 questions, with about 193 training rows and 22 evaluation rows. The data was downloaded as JSONL, and training and validation data were uploaded for the fine-tuning job. Answers from the base and fine-tuned models were assessed by another language model given both the generated response and the ground-truth answer.
Evaluations were rerun three, possibly five, times to estimate variation using mean absolute deviation. Out of the evaluation questions, unfine-tuned GPT-4o mini answered roughly 8 correctly; GPT-4o scored similarly overall despite doing better on the single try-points question. After fine-tuning, GPT-4o mini answered about 17 or 18 correctly.
The test compared training data generated by either model and found little difference between them. The generator had ground-truth information from background documents, so it did not have to rely solely on its own knowledge, a likely reason for the small gap. Fine-tuned GPT-4o appeared slightly better than fine-tuned GPT-4o mini, but its result fell within mini’s error bars.
Evaluation and Cost Still Need Attention
OpenAI offers an evaluation framework for uploading data in JSONL, generating responses treated as ground truth and defining testing criteria before and after fine-tuning. Its interface does not offer a straightforward way to compare generated answers with an independently supplied ground-truth answer set, even though that comparison is important for meaningful evaluation. Users can also opt to share evaluation results with OpenAI in exchange for not paying for evaluations, which may be unattractive when industry-specific data is valuable.
Cost is part of the case for a smaller model, but generating training data with a stronger one also uses the API. The gpt-4o-2024-08-06 snapshot is priced at $2.50 per million input tokens and $10.00 per million output tokens. Those charges matter when planning how many teacher answers to generate and check before training.
We think the larger touch rugby test makes a useful case for fine-tuning, but the jump in correct answers is not a substitute for testing your own task. The small job’s near-zero training loss shows why a familiar question can give false confidence. Developers should keep evaluation questions separate, inspect the quality of synthetic answers and consider the value of their data before accepting free evaluations in exchange for sharing results.
Distillation is most useful when a stronger model already produces answers worth learning from and a faster, cheaper student would serve the task. The touch rugby results support that approach for this dataset, while the close teacher-model scores show why the quality and context of the training examples deserve as much attention as the model generating them.
More on ChatGPT:
- OpenAI DevDay 2024: Voice API and Developer Tools
- OpenAI Realtime API Demo: Building Your Own AI Voice Assistant
- ChatGPT Developer Tools: The DevDay Details Worth Knowing
Media Credit: Trelis Research
Disclosure: Some of our articles include affiliate links. If you buy something through one of these links, Geeky Gadgets may earn an affiliate commission. Learn about our Disclosure Policy.