Knowledge distillation is a machine learning paradigm that transfers the dark knowledge encoded in a cumbersome teacher model to a lightweight student model. Instead of training the student solely on hard labels from a dataset, it learns to replicate the teacher's soft output probabilities, capturing inter-class similarities and nuanced decision boundaries that one-hot labels discard.
Glossary
Knowledge Distillation

What is Knowledge Distillation?
Knowledge distillation is a model compression technique where a compact 'student' model is trained to mimic the behavior and output distributions of a larger, more complex 'teacher' model, transferring generalization capabilities without replicating parameter volume.
The process minimizes a divergence metric, typically Kullback-Leibler divergence, between the softened logits of the teacher and student. A temperature hyperparameter controls the softness of the probability distribution, exposing the student to the richer structural information the teacher has internalized. This yields a compact model that retains high accuracy with significantly lower inference latency.
Key Features of Knowledge Distillation
Knowledge distillation transfers the generalization capabilities of a large, complex teacher model to a compact, efficient student model by training the student to match the teacher's output distributions.
Teacher-Student Architecture
The fundamental framework involves a pre-trained, high-capacity teacher model and an untrained, lightweight student model. The student learns not from the original ground-truth labels alone, but by mimicking the teacher's behavior. The teacher provides soft targets—probability distributions over classes—which contain richer information than hard labels, including inter-class similarities and the teacher's uncertainty estimates.
Soft Targets and Temperature Scaling
A critical mechanism where the teacher's output logits are divided by a temperature parameter (T) before applying softmax. Higher temperatures produce softer probability distributions, revealing the dark knowledge of non-target classes. The student is trained to minimize the divergence between its own softened outputs and the teacher's softened outputs using Kullback-Leibler (KL) divergence loss, often combined with a standard cross-entropy loss against ground truth.
Distillation Loss Functions
The training objective combines two loss components:
- Distillation Loss: KL divergence between the student's softened logits and the teacher's softened logits, weighted by T².
- Student Loss: Standard cross-entropy between the student's hard predictions and the true labels. A hyperparameter α balances these two terms. This dual objective ensures the student learns both the teacher's generalization patterns and the ground-truth signal.
Feature-Based Distillation
Beyond matching final outputs, the student can learn from the teacher's intermediate representations. The student is trained to minimize the distance between its own hidden layer activations and the teacher's corresponding feature maps. Techniques include:
- Hint-based training: Aligning feature maps of specific layers.
- Attention transfer: Matching spatial attention maps.
- Relation-based distillation: Preserving relationships between data samples in the feature space.
Online and Self-Distillation
Variants that eliminate the need for a separate pre-trained teacher:
- Online distillation: Teacher and student are trained simultaneously, with the teacher updating from the student's performance.
- Self-distillation: A model acts as its own teacher; deeper layers distill knowledge to shallower layers, or an ensemble of sub-networks within a single model teaches the full network. This improves accuracy without any external teacher model.
Applications in NLP and Vision
Knowledge distillation is widely deployed to compress large models for production:
- BERT → DistilBERT: A 40% smaller model retaining 97% of BERT's language understanding.
- ViT → MobileViT: Distilling vision transformers into mobile-friendly architectures.
- LLM distillation: Compressing models like GPT-4 into smaller, task-specific variants for low-latency inference.
- Ensemble distillation: Compressing an ensemble of diverse models into a single student that captures their collective wisdom.
Knowledge Distillation vs. Other Compression Techniques
A technical comparison of knowledge distillation against other primary methods for reducing neural network size and computational footprint while preserving accuracy.
| Feature | Knowledge Distillation | Weight Pruning | Post-Training Quantization |
|---|---|---|---|
Core Mechanism | Trains a smaller student model to mimic the soft output distribution of a larger teacher model | Removes individual weights or neurons with magnitudes below a threshold | Reduces numerical precision of weights and activations from FP32 to INT8 or INT4 |
Preserves Model Architecture | |||
Requires Original Training Data | |||
Captures Inter-Class Relationships | |||
Typical Compression Ratio | 5x-30x | 2x-10x | 2x-4x |
Accuracy Retention on Complex Tasks | High | Moderate | Moderate |
Training Compute Overhead | High (requires full teacher training plus student training) | Low (post-hoc magnitude analysis) | Low (calibration dataset pass only) |
Hardware-Agnostic Speedup |
Frequently Asked Questions
Clear, technically precise answers to the most common questions about model compression, teacher-student architectures, and the mechanics of transferring knowledge from large models to smaller, deployable ones.
Knowledge distillation is a model compression technique where a compact 'student' model is trained to mimic the behavior and output distribution of a larger, more complex 'teacher' model. The core mechanism involves training the student not just on the ground-truth hard labels, but on the soft labels or soft targets produced by the teacher's final softmax layer. These soft targets contain richer information about inter-class similarities learned by the teacher. The process minimizes a composite loss function that combines the standard cross-entropy loss with the ground truth and a distillation loss—typically the Kullback-Leibler (KL) divergence—between the softened student output and the teacher's output. A temperature parameter T in the softmax function controls the smoothness of the probability distribution, with higher temperatures revealing more granular knowledge about the teacher's internal representations. This technique was formally introduced by Geoffrey Hinton, Oriol Vinyals, and Jeff Dean in their 2015 paper 'Distilling the Knowledge in a Neural Network.'
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Knowledge distillation sits within a broader landscape of techniques for reducing model size and computational cost while preserving performance. These related concepts form the toolkit for deploying efficient AI in production environments.
Teacher-Student Architecture
The foundational framework where a large, high-capacity teacher model generates soft labels—probability distributions over classes—that a compact student model learns to mimic. Unlike hard labels, soft labels capture the teacher's uncertainty and inter-class relationships, providing richer supervisory signals. The student is trained to minimize the Kullback-Leibler divergence between its softened output distribution and the teacher's, often using a temperature parameter to control distribution smoothness.
Temperature Scaling
A hyperparameter T applied to the softmax function that controls the softness of probability distributions during distillation. Higher temperatures (e.g., T=20) produce softer distributions that reveal more information about the teacher's internal representations, exposing subtle class similarities. The same temperature is used for both teacher and student during training, but set to T=1 during inference. This mechanism is critical for transferring dark knowledge—the hidden patterns in the teacher's output that go beyond simple class predictions.
Distillation Loss Functions
The training objective combines multiple loss components:
- Distillation loss: KL divergence between softened teacher and student outputs
- Student loss: Standard cross-entropy with ground-truth hard labels
- A weighted sum balances mimicking the teacher versus learning from data This dual-objective approach ensures the student both replicates the teacher's nuanced behavior and maintains accuracy on the original task. The mixing ratio is a tunable hyperparameter, typically giving more weight to distillation loss.
Feature-Based Distillation
An extension beyond output-level distillation where the student learns to replicate the teacher's intermediate representations. The student is trained to minimize the distance between its hidden layer activations and those of the teacher, often using hint layers and guided layers. This transfers not just what the teacher predicts, but how it internally processes information. Techniques include attention transfer, where the student mimics the teacher's attention maps, and neuron selectivity transfer using maximum mean discrepancy.
Self-Distillation
A variant where the teacher and student share the same architecture, with the student being an earlier checkpoint or a copy of the model. The model is trained iteratively: a trained model becomes the teacher for a new instance of itself. This process can improve generalization without any architectural change. Self-distillation has been shown to reduce overfitting and improve calibration, effectively allowing a model to learn from its own softened predictions in a bootstrapping fashion.
Online Distillation
A dynamic paradigm where teacher and student are trained simultaneously rather than sequentially. Both models learn together, with the teacher updating its parameters alongside the student. This eliminates the need for a pre-trained teacher and allows mutual learning. Common implementations include deep mutual learning, where multiple peer networks teach each other, and co-distillation, where models of the same architecture exchange knowledge during training.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us