Blog
I stopped renting the big model for boring jobs: a distillation guide
- Distillation
- Small models
- Costs
Here is a question I keep getting in different words: the big model handles our task beautifully, but running it on every request is eating us alive. What now? My answer has become boring and predictable. You let the big model teach a small one, then you run the small one.
That is distillation, and the original idea is older than the hype cycle. Hinton's distillation paper showed a small student learning from a large teacher's soft outputs all the way back in 2015. What changed is that the teachers got absurdly good and the students got cheap enough to run anywhere. This is the practical version: when it works, how I do it, and where I would not bother.
Key takeaways
- Distill the boring, narrow, high volume jobs. Leave the open ended clever stuff on the frontier model.
- Same tokenizer on both sides means you can use logit distillation. Different tokenizers means plain sequence training, so do not fight the vocabulary mismatch.
- Always finish on-policy: let the student write, then let the teacher correct it. That step is what makes it survive contact with production.
- Judge the student on fresh generations it wrote alone, never on loss against teacher text.
- Check the teacher's licence first. A lot of commercial terms forbid training on outputs, and that kills the project on day one.
The three flavors, minus the mystique
People make distillation sound complicated and it really is not. There are three ways to teach, in order of how much effort they take. The simplest is sequence level: the teacher writes answers for a pile of your real prompts, and you fine-tune the student on those pairs like normal training data. This is also the whole trick behind the DeepSeek R1 distills everyone passed around, where the teacher's reasoning traces became the student's training data. The LocalAI Master guide covers this whole toolkit well and I kept coming back to it while writing this.
Then there is the classic Hinton form, logit distillation. Instead of learning from the teacher's final answer, the student learns from the teacher's full probability distribution at each token, softened with a temperature knob. Each example carries way more information than a single hard label. The catch is that both sides need the same tokenizer, and you need access to the logits, which rules out most API teachers.
At the far end sit rationale distillation and hidden state matching. Rationale means the student learns the reasoning before the answer, not just the answer, which is where the R1 style gains come from. Hidden state matching copies intermediate layers. I have only reached for those on reasoning heavy tasks. For most jobs, sequences plus a good finish get you almost all of it. The AppLab overview puts a number on the prize: their R1 distill example keeps roughly 85 percent of the teacher's reasoning at about one twentieth of the inference cost. Your mileage will vary, but the direction is right.
When it pays, and when I would not bother
Distillation pays when the job is narrow, high volume, and stable. One input shape, one output shape, thousands of runs a month, and the definition of good barely moves. Classifiers, extractors, rerankers, formatters, single format drafters. The ByteLedger pipeline guide draws the same line I do: bounded output spaces distill cleanly, open ended capability does not.
So before anything else, I run a cheap test. I point a small model with a good prompt at the task and watch it fail. Then I point the frontier teacher at it and watch it pass. If the small one already passes, I never needed a pipeline. If the teacher fails too, no student will save me. The gap between those two results is the entire business case, and it takes an afternoon to measure.
Two boring checks before you start spending GPU hours. First, read the teacher's terms. Many commercial licenses prohibit using outputs to train a competing model, full stop. Second, write down what a run costs you today and how often it succeeds. I track that as cost per successful task, because without a baseline every later number is theater.
The pipeline I actually run
I start with real traffic, not a synthetic benchmark. A few thousand real prompts, deduplicated, with the ugly ones deliberately kept in. If your data is all clean examples, your student will meet reality for the first time in production, and that meeting will go badly.
The teacher generates at low temperature for factual jobs. For reasoning jobs I keep the traces, because the steps are the training signal, not just the final answer. Then I filter hard: dropped fields, wrong formats, refusals, anything that fails my own checks. A student trained on unfiltered teacher text learns the teacher's mistakes too, and the teacher makes plenty.
Training itself is almost anticlimactic. LoRA rank 16 to 32 is enough for most distills, learning rate around 2e-4 to 5e-4, three to five epochs, and I watch for overfitting after epoch three because that is where it always shows up. The Ertas note on distillation suggests the same starting recipe. One rule from Trefon's notes that I follow exactly: same tokenizer, use logit KL. Different tokenizers, use sequence level and do not fight the vocabulary mismatch. Store top-k logits instead of full distributions unless the teacher runs right next to you.
The step everyone skips, and why their student falls over
Here is the failure I see constantly. Someone trains a student purely on teacher text, loss looks great, demos look great, then production traffic arrives and the student faceplants. The reason is simple once you see it. Training taught the student to continue the teacher's perfect text. Production asks it to continue its own imperfect text. The first small mistake compounds because the student has never seen its own mistakes before.
The fix is called on-policy distillation, or GKD, and it costs two to three times more in teacher calls, which is exactly why people skip it. The student generates, the teacher corrects those generations, and the student learns to recover instead of just imitate. I start off-policy because it is cheap and gets most of the way there, then I finish on-policy because that is the part that survives reality. Skipping the finish to save a few dollars of teacher calls is the most expensive saving I know.
And I evaluate on generations, never on loss. A lower KL against teacher text tells you nothing about what happens when the student writes alone. Same task type, same success checks, teacher and student side by side, judged on the end state the way I describe in evals that check the end state. When the student's cost per successful task beats the teacher on the same checks, I switch that task type and move to the next boring job.
Use cases: tasks that are worth distilling
The rule above is narrow, high volume and stable. In a typical business that points to a short list of jobs. These are the ones I would look at first, and two I would leave with the big model.
- Routing support tickets. One input shape, a fixed set of queues, thousands a month. A classic classifier that a small student handles well once the teacher has labelled enough real tickets.
- Pulling fields out of invoices and receipts. Vendor, date, amount, tax: a bounded output that a student can learn, with the frontier model kept as a fallback for the odd document.
- Tagging content. Ad creatives, articles or products tagged with a small, fixed taxonomy. The same tags every time is what makes the tagging useful, and a student is cheap enough to run on everything.
- Reranking search results. A small reranker tuned on your own queries and the results you marked as right, as in the local search post, where the reranker only judges near-ties.
- Formatting and single-format drafts. Turning notes into a fixed template, or writing one kind of short message in a house style.
- Where I would not bother. Open-ended reasoning, strategy, anything where the definition of good keeps moving, and anything built on facts that change weekly. Those stay with the rented frontier model, or go to retrieval.
Try it this week: the afternoon gap test
Before any pipeline, run the cheap test from this post on one task. A small model with a good prompt, then the frontier teacher, on the same 30 real inputs with the same checks. The gap between the two is the whole business case.
Goal: plan an afternoon test that tells me whether one task is worth distilling.
Inputs: the task, a description of its inputs and outputs, roughly how many runs per month, and what a good output looks like.
Constraints: one small model with a good prompt versus one frontier model, on the same 30 real inputs with the same pass or fail checks. Remind me to read the teacher's terms on using outputs for training. Do not suggest training anything yet.
Definition of done: the checks to use, how to pick the 30 inputs, a results table to fill in, and the decision rule: distill if the small model fails and the teacher passes, stop otherwise.My take: distill the boring parts first, keep the brain rented
Every team I meet wants to distill the clever part first. The clever part is the worst candidate. It is open ended, it changes monthly, and the teacher itself is still improving there. You will distill a moving target and maintain the pipeline forever.
I go the other way. The extractor, the classifier, the reranker, the formatter. Stable, high volume, and a 7B student can match a giant teacher on one bounded job. That is where the 5 to 50x size reductions the guides quote actually happen. Keep the frontier model where judgment lives. Put students where repetition lives.
This whole question sits inside a bigger one people keep asking: is fine-tuning dead in 2026, and should it be RAG or distillation or prompting instead. My answer is that they are different tools. Retrieve the facts that move, distill the repetition that does not, fine-tune the behavior that prompting cannot hold. I wrote up the middle one in the LoRA and QLoRA guide. Start with the boring parts and the math takes care of itself.
Frequently asked questions
Should I distill or just fine-tune?
Fine-tune when you have good human labels and the behavior to learn is yours. Distill when a frontier teacher already does the task and you can collect its outputs at volume. Plenty of teams do both: distill teacher traces first, then fine-tune on their own corrections.
How much data do I need?
A few thousand real prompts is a normal start, more for reasoning tasks. Diversity beats raw count every time. Keep the ugly inputs, filter bad teacher outputs, and hold out a set the student never trains on.
Logit or sequence level?
Same tokenizer plus access to logits: logit KL with temperature. API teacher or different tokenizer: sequence level with plain training. Either way, finish with a short on-policy phase where the student writes and the teacher corrects.
How do I know the student is good enough to ship?
Run teacher and student side by side on the same task with the same success checks. Compare cost per successful task, not cost per run. Ship when the student matches on success rate at a lower cost per success.
Which business tasks are good candidates for distillation?
Narrow, high-volume, stable jobs: routing support tickets, extracting invoice fields, tagging content with a fixed taxonomy, reranking search results and single-format drafting. Open-ended reasoning and fast-changing facts are poor fits.
Sources
- Hinton et al: Distilling the Knowledge in a Neural Network arxiv.org
- LocalAI Master: Knowledge Distillation Complete Guide (2026) localaimaster.com
- AppLab: AI Model Distillation in 2026 app-lab.ai
- ByteLedger: Distillation Pipeline Guide for 2026 byteledger.vizleo.com
- Trefon: LLM Distillation, Logit KL, Temperature, On-Policy trefon.com
Talk to me
Building an AI product and need someone senior to own the technical side? Book a free 30-minute call.