TL;DR — AI model distillation in 2026: compress 671B models to 7B with 5-50x size reduction. DeepSeek R1-Distill-Qwen-32B captures ~85% of R1's reasoning at 1/20th cost. Three types: logit (Hinton, soft labels, KL divergence), sequence-level (SFT on teacher outputs, R1 method), hidden-state (DistilBERT: 40% smaller, 60% faster, 97% GLUE). On-policy distillation (GKD): student generates, teacher labels, 2-3x cost. CoT distillation: distill reasoning traces, R1-Distill beats larger non-reasoning models on AIME. White-box vs black-box: logit access requires open-weights. Legal: OpenAI, Anthropic prohibit distillation from APIs. Data: 1K-5K for narrow tasks, 20K-100K for broad instruction-following. Pipeline: generate → filter → dedupe → train → evaluate.
AI Model Distillation in 2026: How to Compress 671B Models to 7B with Knowledge Distillation
Distillation is how 671B frontier models become 7B consumer-GPU models. By training a small student to mimic a large teacher, you can compress capabilities at 5-50x size reduction with surprisingly small quality loss. It's the quiet workhorse behind most production small models.
Key Statistics
| Metric | Value | Source |
|---|---|---|
| R1-Distill-Qwen-32B reasoning retention | ~85% of R1 | localaimaster 2026 |
| R1-Distill size reduction | 1/20th inference cost | localaimaster 2026 |
| R1-Distill training data | ~800K prompts | localaimaster 2026 |
| DistilBERT size reduction | 40% smaller | redwerk 2026 |
| DistilBERT speed improvement | 60% faster | redwerk 2026 |
| DistilBERT quality retention | 97% on GLUE | redwerk 2026 |
| Size reduction range | 5-50x | localaimaster 2026 |
| Narrow task data | 1K-5K curated samples | redwerk 2026 |
| Broad instruction data | 20K-100K samples | redwerk 2026 |
| On-policy distillation cost | 2-3x off-policy | localaimaster 2026 |
| GKD quality gain | Better long-form generation | localaimaster 2026 |
Distillation Methods Comparison
| Method | Signal Source | Teacher Access | Complexity | Best For |
|---|---|---|---|---|
| Logit (Hinton) | Soft labels (probabilities) | White-box (open-weights) | High | Maximum signal per sample |
| Sequence-level | Generated text | Black-box (any API) | Low | Simplicity, CoT distillation |
| Hidden-state | Intermediate activations | White-box (shared architecture) | Medium | BERT-family compression |
| On-policy (GKD) | Student-generated + teacher labels | White-box | High | Long-form, reasoning |
| CoT distillation | Reasoning traces + answers | Black-box or white-box | Low | Reasoning transfer (R1-Distill) |
Sources: localaimaster (2026), tanhdev (2026), redwerk (2026).
Distillation Pipeline
Source: redwerk (2026), localaimaster (2026), tanhdev (2026).
Distillation vs Fine-Tuning vs RAG
| Approach | What It Changes | Best For | Upfront Cost | Inference Cost |
|---|---|---|---|---|
| Distillation | Model capability | Small model matching large model | High | Lowest |
| Fine-tuning | Model behavior | Tone, style, format, domain | Moderate | Moderate |
| RAG | Model knowledge | Current info, citations | Low | Higher |
| Hybrid | All three | Production agents | Highest | Low at scale |
Source: localaimaster (2026), ailearnings (2026).
R1-Distill Results
| Model | Size | AIME 2024 | Runs On | Cost vs R1 |
|---|---|---|---|---|
| DeepSeek R1 (teacher) | 671B (37B active) | 79.8% | Data center | 1x |
| R1-Distill-Qwen-32B | 32B | ~68% | RTX 4090 | ~1/20x |
| R1-Distill-Qwen-14B | 14B | ~59% | RTX 4090 | ~1/48x |
| R1-Distill-Llama-8B | 8B | ~50% | Laptop | ~1/84x |
| R1-Distill-Qwen-7B | 7B | ~45% | Laptop | ~1/96x |
Source: localaimaster (2026), tanhdev (2026). Approximate values — exact scores vary by benchmark version.
Implementation Guide
| Phase | What to Do | Timeline |
|---|---|---|
| 1. Choose teacher | Open-weights: R1, Llama, Qwen. Check license | 1 day |
| 2. Choose student | Match architecture family. Qwen, Llama, Mistral | 1 day |
| 3. Collect prompts | Real domain prompts: 1K-5K (narrow), 20K-100K (broad) | 1-2 weeks |
| 4. Generate teacher outputs | Teacher generates responses. For CoT: include reasoning | 1-3 days |
| 5. Filter and clean | Verify correctness, dedupe, drop outliers, spot-check 5% | 3-5 days |
| 6. Split data | 85-90% train, 10-15% eval | 1 hour |
| 7. Train student | SFT with LoRA. 30-90 min for 1K examples (7B) | 1-3 hours |
| 8. Evaluate | Compare vs teacher, vs base, on actual task distribution | 1-2 days |
| 9. Check for regression | Test on general tasks — ensure no catastrophic forgetting | 1 day |
| 10. Deploy | Serve with vLLM or Ollama. 5-50x cheaper than teacher | 1-2 days |
| 11. Monitor | Track quality, latency, cost vs teacher in production | Ongoing |
Best Practices
-
Use open-weights teachers — DeepSeek R1 (MIT), Llama 3, Qwen 2.5, Mistral. Closed-model APIs (GPT-5, Claude) prohibit distillation in their terms. The safe approach is open-weights (redwerk 2026).
-
Quality over quantity — 1K-5K well-curated samples beat 50K noisy ones. The student learns whatever is in the data, including the teacher's biases and hallucinations. Time spent on filtering usually exceeds time spent on training (redwerk 2026).
-
Use real domain prompts — production logs, support tickets, redacted user queries. Diversity matters more than raw volume past a certain point. If real prompts aren't available, generate seeds and have a human review (redwerk 2026).
-
Filter for correctness — for math/code, verify answers against ground truth. For open-ended, use quality filtering. Drop hallucinations. Spot-check a random 5% slice (redwerk 2026).
-
Include CoT for reasoning — distill not just the answer but the chain-of-thought. This is how R1-Distill transfers reasoning capability. The student learns to structure its thoughts, decompose tasks, and self-correct (tanhdev 2026).
-
Use LoRA for training — train the student with LoRA/QLoRA for efficiency. 30-90 minutes for 1K examples on a single GPU. The student's adapter can be merged for zero inference overhead (localaimaster 2026).
-
Prove no regression — after distillation, test the student on general tasks to ensure it hasn't forgotten general capabilities. Compare against the base model on general benchmarks (redwerk 2026).
-
Consider on-policy distillation for long-form — GKD (student generates, teacher labels) produces better long-form and reasoning quality. 2-3x compute cost but worth it for high-stakes models (localaimaster 2026).
For related topics, see our how to fine-tune LLM, LoRA vs QLoRA, small language models, AI reasoning models, and evaluate fine-tuned LLM guides.
FAQ
What is on-policy distillation (GKD) and when should I use it?
On-policy distillation, also known as GKD (Generalized Knowledge Distillation), is a distillation approach where the student generates completions from its own distribution, and the teacher labels each position in the student's completion. This addresses the exposure bias problem of off-policy (sequence-level) distillation. The exposure bias problem: in standard sequence-level distillation, the student trains exclusively on teacher-generated data. At test time, the student generates from its own distribution, which may differ from the teacher's. Errors accumulate because the student rarely learns from its own induced states. The student is trained on teacher trajectories but deployed on student trajectories — a train-test mismatch. How GKD works: (1) Student generates — at each training step, the student generates a completion from the prompt using its own current policy. (2) Teacher labels — the teacher computes logit distributions for each position in the student's completion. (3) Distillation loss — compute KL divergence between teacher and student distributions on the student-generated sequence. (4) Update — the student is updated to better match the teacher on its own generated outputs. The difference from off-policy: off-policy distillation trains on teacher-generated sequences. On-policy distillation trains on student-generated sequences with teacher labels. The student learns from what it would actually produce at inference, getting teacher-level guidance per token. Advantages: (1) Better generation quality — especially for long-form and reasoning. The student learns to correct its own errors. (2) Reduced exposure bias — training and inference distributions match. (3) Dense token-level feedback — the teacher provides guidance at every token position. Disadvantages: (1) 2-3x compute cost — need a teacher forward pass per training step. The teacher must score every student-generated sequence. (2) More complex implementation — need to coordinate student generation and teacher scoring in the training loop. (3) Slower training — student generation + teacher scoring per step is slower than off-policy SFT. (4) Requires white-box teacher — need teacher logits, so open-weights only. Implementation: GKD is implemented in TRL via GKDTrainer. Configure the teacher model, student model, and training data. The trainer handles the student generation and teacher scoring loop. When to use GKD: (1) Long-form generation — the exposure bias problem is most severe for long sequences. GKD's advantage grows with sequence length. (2) Reasoning tasks — where the student needs to learn multi-step reasoning. GKD helps the student learn from its own reasoning errors. (3) High-stakes models — where the 2-3x compute cost is justified by quality gains. (4) When you have an open-weights teacher — GKD requires logit access. (5) When off-policy distillation quality is insufficient — if sequence-level distillation produces a student that's good but not great, GKD can close the gap. When NOT to use GKD: (1) Short-form tasks — for short outputs (classification, extraction), the exposure bias is minimal. Off-policy is sufficient. (2) API-only teachers — GKD requires logit access. Use sequence-level distillation with API teachers. (3) Cost-sensitive projects — 2-3x compute cost may not be justified. (4) Quick prototyping — start with off-policy, upgrade to GKD if quality is insufficient. Prefix on-policy distillation: a 2026 optimization. Research shows that GKD's learning signal is assigned unequally towards early tokens. Aligning the prefix is often sufficient for the student to complete the remaining reasoning correctly. Prefix OPD achieves performance close to full OPD while reducing training compute significantly — supervising only the first part of each student trajectory. The key: 'On-policy distillation addresses the exposure bias problem by training on student-generated sequences with teacher labels. It produces better generation quality, especially for long-form and reasoning, at 2-3x compute cost.' Use GKD for long-form and reasoning tasks where off-policy quality is insufficient. Start with off-policy, upgrade to GKD if needed (localaimaster 2026, arxiv 2026)."
- question: "What is DistilBERT and what can I learn from it?"
answer: "DistilBERT is the most famous example of model distillation in NLP. Created by HuggingFace, it demonstrated that BERT could be compressed by 40% and run 60% faster while retaining 97% of its language understanding capabilities on the GLUE benchmark. It is the proof point that distillation works and the reference case every distillation guide cites. What DistilBERT did: (1) Teacher — BERT (110M parameters). The original Google language model. (2) Student — DistilBERT (66M parameters). 40% smaller. (3) Method — hidden-state distillation. The student mimics the teacher's intermediate layer activations, not just the output. A triple loss: (a) Distillation loss — KL divergence between teacher and student output distributions. (b) MLM (Masked Language Modeling) loss — standard cross-entropy on masked tokens. (c) Cosine embedding loss — align student and teacher hidden states. (4) Architecture — removed token-type embeddings and pooler from BERT. 6 layers instead of 12. (5) Result — 40% smaller, 60% faster, 97% of GLUE quality. (6) Training — trained on the same data as BERT. No additional data needed. What DistilBERT proved: (1) Distillation works — a smaller model can match a larger model's performance with minimal quality loss. (2) Hidden-state distillation is effective — matching intermediate activations, not just outputs, preserves more of the teacher's capability. (3) The quality ceiling is high — 97% retention is close to perfect. For most tasks, the difference is negligible. (4) Speed and size improvements are real — 40% smaller and 60% faster makes the model practical for deployment. (5) No additional data needed — distillation can work with the same training data as the teacher. Lessons for LLM distillation in 2026: (1) Start with a strong teacher — BERT was the best model available. Use the best open-weights teacher you can (R1, Llama 3, Qwen 2.5). (2) Match architecture when possible — DistilBERT worked because the student was the same architecture as the teacher, just smaller. For LLMs, distilling within the same family (Qwen to Qwen, Llama to Llama) is easier than cross-family. (3) Use multiple loss signals — DistilBERT used three losses (distillation, MLM, cosine embedding). For LLMs, combine distillation loss with standard cross-entropy. (4) Remove unnecessary components — DistilBERT removed token-type embeddings and pooler. For LLMs, consider removing unnecessary components from the student architecture. (5) 97% is the ceiling — DistilBERT retained 97% of BERT's quality. This is the best case. For LLMs, expect 85-97% retention depending on the task and method. (6) The floor is lower than you think — when teams skip data quality and evaluation, the result is a small model that is confidently wrong on the inputs that matter. The key: 'DistilBERT shrank BERT by 40% and ran 60% faster while keeping 97% of its language understanding on GLUE. That is the ceiling. The floor, when teams skip the steps, is a small model that is confidently wrong on the inputs that matter.' DistilBERT is the proof that distillation works. But it's also a reminder that the ceiling is 97%, not 100% — and the floor is much lower if you cut corners on data and evaluation (redwerk 2026, localaimaster 2026)."
- question: "How do I evaluate a distilled model?"
answer: "Evaluating a distilled model requires comparing it against both the teacher model and the base student model on your actual task distribution. Without proper evaluation, you don't know if distillation actually transferred capability or just produced a different model. Evaluation steps: (1) Compare against the teacher — run the student and teacher on the same test set. The student should capture 85-97% of the teacher's quality. If the gap is larger, the distillation didn't work well — check data quality, training config, or try a different method. (2) Compare against the base student — run the distilled student and the original (non-distilled) student on the same test set. The distilled model should outperform the base model. If it doesn't, distillation added no value. (3) Compare against fine-tuning — compare the distilled model against the base model fine-tuned on your task data. If fine-tuning achieves similar results, distillation may not have been necessary. (4) Test on actual task distribution — published benchmarks (MMLU, GLUE) are useful for comparison, but your actual task distribution is what matters. Create a test set that reflects what the model will see in production. (5) Test for regression — evaluate the distilled model on general tasks (not just your specific task) to detect catastrophic forgetting. If general performance drops significantly, the distillation has degraded general capabilities. (6) Use task-specific metrics — for classification: accuracy, precision, recall, F1. For generation: BLEU, ROUGE, BERTScore. For reasoning: AIME, GPQA, SWE-Bench. For code: pass@k. Choose metrics that reflect your task's success criteria. (7) Human evaluation — for subjective tasks (tone, style, quality), use human evaluators. Have 3+ evaluators rate responses. Calculate inter-annotator agreement. (8) LLM-as-judge — use a frontier model to evaluate responses. Provide scoring criteria and have the judge model rate responses. Faster than human evaluation but less reliable. (9) Measure inference cost — track tokens/second, latency, GPU memory, and cost per query. The whole point of distillation is cheaper inference — verify you're actually getting it. (10) Measure quality-to-cost ratio — compare quality (accuracy, F1) per dollar of inference cost. The distilled model should have a much better quality-to-cost ratio than the teacher. (11) A/B testing — deploy the distilled model alongside the teacher. Route a percentage of traffic to the distilled model. Compare user engagement, satisfaction, or task completion rates. (12) Regression testing — maintain a set of test cases that the model must pass. Run these after every retraining. The common failure mode: the student is confidently wrong on inputs that matter. The student produces well-structured, plausible-sounding outputs that are incorrect. This happens when: (a) The teacher's hallucinations were included in the training data. (b) The training data didn't cover the full distribution of inputs. (c) The student overfit to the training data and doesn't generalize. Prevention: (1) Filter teacher outputs for correctness — don't include hallucinations in training data. (2) Cover the full input distribution — include diverse prompts that cover the variety of inputs. (3) Hold out evaluation data — never evaluate on training data. (4) Test on real production inputs — not just benchmark data. (5) Monitor in production — track quality metrics and user feedback. The key: 'The training part is the easy 20 percent. The data and evaluation work is the 80 percent that decides whether the project delivers or stalls.' Evaluation is not optional — it's the only way to know if distillation worked. Budget as much time for evaluation as for data preparation and training combined (redwerk 2026, localaimaster 2026)."