Knowledge distillation is a model compression technique where a smaller, more efficient 'student' model is trained to mimic the predictive behavior or output distributions of a larger, more complex 'teacher' model. The core objective is to transfer the teacher's generalized 'knowledge'—its ability to map inputs to outputs—into a compact form suitable for on-device inference optimization. This is achieved by training the student not only on ground-truth labels but also on the teacher's softened probability outputs, which contain richer relational information than hard labels.
Glossary
Knowledge Distillation

What is Knowledge Distillation?
A technique for creating efficient, deployable models by transferring capabilities from a larger model.
The process enables the creation of highly capable small language models that retain much of the teacher's accuracy at a fraction of the computational cost. It is a foundational technique within edge artificial intelligence architectures, often used in conjunction with other compression methods like quantization and pruning. The student model's architecture is typically designed for efficiency, making knowledge distillation a key strategy for deploying performant AI on hardware with constrained memory and power profiles.
Key Characteristics of Knowledge Distillation
Knowledge distillation is a model compression technique where a smaller, more efficient 'student' model is trained to mimic the behavior or output distributions of a larger, more complex 'teacher' model.
Teacher-Student Paradigm
The core framework involves two models: a large, accurate Teacher Model (e.g., BERT-Large, GPT-4) and a compact Student Model (e.g., TinyBERT, DistilBERT). The student is trained not just on the original hard labels (e.g., 'cat' vs. 'dog') but primarily on the teacher's softened output probabilities, known as logits. This transfer of 'dark knowledge' from the teacher's internal representations enables the student to achieve higher accuracy than if trained on the original data alone.
Soft Targets & Temperature Scaling
A key mechanism is the use of soft targets. The teacher's final layer logits are passed through a softmax function with a temperature parameter (T). A higher T (e.g., T=10) creates a softer probability distribution, revealing the teacher's relative confidence across all classes, not just the top prediction. For example, an image of a 'husky' might yield probabilities: dog (0.7), wolf (0.25), fox (0.05). This inter-class relationship is invaluable knowledge. The student is trained to match this soft distribution, and the loss is calculated using the Kullback-Leibler (KL) Divergence.
Distillation Loss Function
The student's training objective combines two losses:
- Distillation Loss (L_soft): Measures the KL divergence between the student's and teacher's softened output distributions.
- Student Loss (L_hard): A standard cross-entropy loss between the student's predictions (at T=1) and the ground-truth labels. The total loss is a weighted sum: L_total = α * L_soft + (1 - α) * L_hard. This hybrid objective ensures the student learns both the teacher's nuanced reasoning and the correct task-specific labels. The hyperparameters α (weight) and T (temperature) are critical for performance.
Forms of Distilled Knowledge
Knowledge can be transferred at different levels of the neural network:
- Response-Based Distillation: Mimics the final output layer logits (most common).
- Feature-Based Distillation: Aligns intermediate hidden states or attention matrices from the teacher and student, often using a Mean Squared Error (MSE) loss. This is central to methods like TinyBERT.
- Relation-Based Distillation: Preserves relationships between different layers or data samples, such as the Flow of Solution Process (FSP) matrix. This captures the teacher's internal feature transformations.
Primary Use Cases & Benefits
Knowledge distillation is primarily used for model compression and efficiency gains.
- Edge/On-Device Deployment: Creates tiny models that run on smartphones, IoT sensors, or microcontrollers with limited memory and compute.
- Inference Acceleration: Smaller student models have drastically lower latency and higher throughput.
- Privacy & Security: A distilled model can capture a large model's capability without containing its original, potentially sensitive, training data.
- Model Standardization: Distill multiple specialized teachers into a single, generalist student model for unified deployment.
Related & Contrasting Techniques
Knowledge distillation is one of several model compression techniques:
- Contrast with Quantization: Quantization reduces numerical precision (e.g., FP32 to INT8) but keeps the same architecture. Distillation creates a fundamentally smaller, often different, architecture.
- Contrast with Pruning: Pruning removes weights from an existing model. Distillation trains a new, dense model from scratch.
- Complementary Use: These techniques are often combined. A model can first be distilled to a smaller architecture, then quantized and pruned for maximum efficiency.
- Self-Distillation: A variant where the teacher and student are the same model architecture, often used as a regularization technique to improve the original model's performance.
Knowledge Distillation vs. Other Compression Techniques
A feature comparison of Knowledge Distillation against other primary model compression and optimization techniques used for on-device inference.
| Feature / Metric | Knowledge Distillation | Quantization | Pruning | Neural Architecture Search (NAS) |
|---|---|---|---|---|
Primary Compression Mechanism | Mimics output distributions of a teacher model | Reduces numerical precision of weights/activations | Removes redundant weights or neurons | Automates search for optimal network structure |
Typical Model Size Reduction | 50-90% | 75% (FP32 to INT8) | 50-90% | Varies (task & constraint dependent) |
Primary Inference Speedup Source | Smaller, simpler student model | Lower-bit arithmetic & memory bandwidth | Fewer FLOPs & parameters | Hardware-aware architecture design |
Requires Retraining / Fine-Tuning | ||||
Preserves Original Model Accuracy | High (via teacher guidance) | Moderate to High (with PTQ/QAT) | Moderate (requires careful fine-tuning) | High (optimized for target metric) |
Output Interpretability | High (behavioral mimicry) | High (deterministic mapping) | High (structural simplification) | Low (black-box search process) |
Common Use Case | Creating compact, general-purpose models | Maximizing throughput on fixed hardware | Reducing footprint of a known architecture | Designing novel, efficient architectures from scratch |
Combines with Other Techniques |
Common Variants and Advanced Techniques
Beyond the basic teacher-student paradigm, knowledge distillation has evolved into a sophisticated family of techniques for model compression, specialization, and efficiency. These advanced methods address specific deployment challenges, from hardware constraints to data privacy.
Response-Based Distillation
The foundational and most common form of distillation. The student model is trained to mimic the final output layer (logits or softmax probabilities) of the teacher model. A temperature parameter (T) is applied to the teacher's softmax to create a softer probability distribution, which contains richer 'dark knowledge' about inter-class relationships than hard labels. The student's loss is a weighted combination of the distillation loss (e.g., KL divergence) and the standard cross-entropy loss with ground-truth labels.
- Key Insight: The teacher's softened outputs act as a more informative training signal than one-hot labels.
- Use Case: General-purpose compression of large classifiers into smaller, faster versions.
Feature-Based Distillation
Also known as hint learning or intermediate representation matching. This technique forces the student to replicate the teacher's activations at intermediate layers of the network, not just the final output. Since the student's architecture is typically shallower or narrower, a projection layer (or 'adapter') is often used to align the dimensions of the student's feature maps with the teacher's.
- Key Insight: Intermediate features contain structural knowledge about how the teacher transforms data, guiding the student's internal representations.
- Common Loss: Mean Squared Error (MSE) or cosine similarity between normalized feature maps.
- Use Case: Compressing very deep convolutional networks (e.g., ResNet) where intermediate spatial features are critical.
Relation-Based Distillation
This advanced variant focuses on transferring the relationships between data samples or between layers, rather than individual outputs or features. The student learns to mimic the teacher's learned similarity structure. Common approaches include:
-
Sample Relation: Using a distance metric to match the teacher's and student's pairwise similarity matrices across a batch of samples.
-
Layer Relation: Matching the Gram matrices (correlations between feature channels) or the flow of information between layers.
-
Key Insight: Captures the teacher's higher-order understanding of the data manifold and internal feature correlations.
-
Use Case: Tasks where relational reasoning is paramount, such as metric learning or fine-grained classification.
Self-Distillation
A paradigm where the teacher and student are the same model architecture, or even the same instance. Knowledge is transferred from deeper sections of the network to shallower ones, or from the model's own predictions at a later training stage. Common forms include:
-
Multi-Exit Distillation: Training early 'exit' classifiers in a cascaded network to match the final classifier's predictions.
-
Temporal Self-Distillation: Using an exponential moving average (EMA) of the model's own weights as the teacher.
-
Key Insight: Leverages a model's own capacity to provide a consistent, refined training signal, often improving generalization and calibration.
-
Use Case: Creating efficient early-exit models for dynamic inference or stabilizing training.
Online Distillation
In contrast to the traditional two-stage process (train teacher, then distill student), online distillation trains an ensemble of peer student models simultaneously. Each student learns from both the ground truth and the averaged predictions of its peers. A key architecture is Deep Mutual Learning, where a cohort of models trains collaboratively.
- Key Insight: Eliminates the need to pre-train and store a large, static teacher model, reducing total training time and computational cost.
- Benefit: The student cohort can outperform a single model trained independently, as they learn diverse yet complementary representations.
- Use Case: Resource-constrained training environments where training a giant teacher is prohibitive.
Distillation for Specific Architectures
Specialized distillation techniques have been developed for dominant model families:
-
Transformer Distillation (e.g., DistilBERT, TinyBERT): Involves distilling the embedding layer outputs, attention matrices (to transfer the teacher's focus patterns), and hidden states, in addition to the final logits. This is critical for compressing large language models.
-
Cross-Modal Distillation: Transferring knowledge from a model in one modality (e.g., a large image-text model) to a student in another (e.g., a small text-only model), enabling efficient specialization.
-
Distillation for Reinforcement Learning: The teacher's policy (action distribution) or value function is distilled into a smaller, more efficient student policy for deployment.
-
Use Case: Creating efficient variants of state-of-the-art architectures like Transformers for on-device deployment.
Frequently Asked Questions
Knowledge distillation is a core model compression technique for creating efficient, deployable AI. This FAQ addresses common technical questions about its mechanisms, applications, and relationship to other optimization methods.
Knowledge distillation is a model compression technique where a smaller, more efficient 'student' model is trained to mimic the behavior or output distributions of a larger, more complex 'teacher' model. The process works by using the teacher's soft labels—the probability distributions over classes produced by its final softmax layer—as a richer training signal than the standard hard labels (one-hot encoded ground truth). A distillation loss (e.g., Kullback-Leibler divergence) measures the difference between the student's and teacher's output distributions, and is often combined with a standard cross-entropy loss against the true labels. This teaches the student to capture the teacher's nuanced 'dark knowledge,' such as inter-class relationships and prediction confidence, enabling the smaller model to achieve higher accuracy than if trained on hard labels alone.
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 is a core technique in model compression. These related concepts define the broader ecosystem of methods used to create efficient, high-performance models for on-device deployment.

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