Knowledge distillation is a machine learning paradigm where a compact student model is trained to mimic the output distribution of a larger, pre-trained teacher model. Rather than training the student on hard labels alone, the student learns from the teacher's softened logits, capturing inter-class similarities and nuanced patterns that a one-hot label cannot provide. This process transfers the teacher's generalization capability into a significantly smaller architecture.
Glossary
Knowledge Distillation

What is Knowledge Distillation?
Knowledge distillation is a model compression technique where a smaller, efficient 'student' model is trained to replicate the behavior of a larger, complex 'teacher' model, transferring dark knowledge through soft probability distributions.
The technique is critical for deploying models in latency-sensitive or resource-constrained environments, such as distilling a cross-encoder into a bi-encoder for fast retrieval. The student minimizes a composite loss function combining the standard task loss with a distillation loss, typically Kullback-Leibler divergence, weighted by a temperature parameter that controls the softness of the teacher's output distribution.
Key Characteristics of Knowledge Distillation
The core mechanisms and architectural patterns that enable a compact student model to approximate the generalization capabilities of a computationally expensive teacher model.
Teacher-Student Architecture
The foundational setup where a large, pre-trained teacher model generates soft probability distributions over outputs. A smaller student model is trained not just on the hard labels but on these soft targets, which capture the teacher's nuanced decision boundaries and inter-class similarities. This transfers dark knowledge that is not present in the one-hot ground truth.
Response-Based Distillation
The most common form of distillation, focusing solely on the final output layer. The student minimizes the divergence between its predicted probability distribution and the teacher's distribution. A temperature parameter (T) in the softmax function softens the probabilities, revealing the relative confidence the teacher assigns to incorrect classes. Key loss components include:
- Kullback-Leibler divergence between softened student and teacher outputs
- Cross-entropy loss against the ground truth hard labels
Feature-Based Distillation
Instead of matching only final outputs, the student learns to mimic the intermediate feature representations of the teacher. A regression loss minimizes the distance between the student's hidden layer activations and the teacher's corresponding layers. This is critical when the student has a different depth or width, requiring a projection layer to map the student's feature space to the teacher's dimensionality.
Relation-Based Distillation
Transfers the structural relationships learned by the teacher. Instead of matching individual examples, the student learns to preserve the mutual relations between data samples in the teacher's embedding space. Techniques include:
- Similarity-preserving loss: Matching the Gram matrices of activations within a batch
- Relational Knowledge Distillation (RKD): Preserving distance-wise and angle-wise relations between triplet samples
Distillation for Bi-Encoder Efficiency
A critical application in retrieval systems where a computationally heavy cross-encoder (which processes query-document pairs jointly) acts as the teacher. The student is a bi-encoder that encodes queries and documents independently for fast ANN search. The bi-encoder is trained to mimic the cross-encoder's relevance scores, enabling low-latency semantic search without sacrificing the precision of joint attention mechanisms.
Online vs. Offline Distillation
Offline distillation uses a frozen, pre-trained teacher to guide a student in a standard two-phase process. Online distillation trains both models simultaneously in a single phase, where the teacher and student co-evolve. A variant, self-distillation, uses the same architecture for both roles, where a deeper network's predictions guide a shallower instance of itself, often improving generalization without an external teacher.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about transferring knowledge from large teacher models to compact, efficient student models.
Knowledge distillation is a model compression technique where a compact student model is trained to replicate the behavior of a larger, more powerful teacher model. Instead of training the student solely on hard labels from a dataset, the student learns from the teacher's output probability distribution—often called soft targets. These soft targets contain rich information about inter-class similarities that hard labels lack. For example, a teacher classifying an image of a car might assign a 0.7 probability to 'car,' 0.2 to 'truck,' and 0.1 to 'bus,' revealing the semantic relationship between these vehicles. The student is trained to minimize the Kullback-Leibler (KL) divergence between its own softened output distribution and the teacher's, using a temperature parameter to control the softness of the probability distribution. This process effectively transfers the teacher's generalization capabilities into a model that is often orders of magnitude smaller and faster at inference time.
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 latency. These related concepts are essential for deploying performant models in resource-constrained environments.
Teacher-Student Architecture
The foundational framework of knowledge distillation. A large, high-capacity teacher model generates soft probability distributions over output classes. A compact student model is trained not just on hard labels, but to mimic these soft targets, capturing the teacher's nuanced generalization and inter-class relationships. The student often learns from the teacher's logits before the final softmax layer.
Weight Pruning
A complementary compression technique that removes redundant parameters from a trained network. Unstructured pruning zeroes out individual weights with small magnitudes, leading to sparse matrices. Structured pruning removes entire neurons, channels, or attention heads, yielding models that are physically smaller and faster on standard hardware without specialized sparse computation libraries.
Post-Training Quantization
Reduces a model's memory footprint and accelerates inference by converting high-precision 32-bit floating-point weights and activations to lower-precision formats like INT8 or FP16. This process can be applied directly after training without retraining. Quantization is often combined with distillation to recover any accuracy lost during the precision reduction step.
TinyML Model Compression
The extreme application of compression techniques for deployment on microcontrollers. This combines distillation, aggressive int8 quantization, and pruning to fit models into sub-100KB memory footprints. The goal is to run inference on devices with milliwatt power budgets, enabling on-device keyword spotting and sensor analytics without cloud connectivity.
Cross-Encoder to Bi-Encoder Distillation
A specific distillation pattern for information retrieval. A high-precision cross-encoder teacher scores query-document pairs with full attention. Its knowledge is distilled into a bi-encoder student that encodes queries and documents independently. This yields a model suitable for fast ANN search while approaching the accuracy of the computationally prohibitive cross-encoder.

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