Inferensys

Glossary

Soft Targets

Soft targets are the class probability distributions produced by a teacher model, typically softened by a high temperature parameter, which provide richer information about inter-class similarities than hard labels.
ML engineer managing model versions on laptop, version history visible, technical Git-like workflow.
KNOWLEDGE DISTILLATION

What is Soft Targets?

Soft targets are the class probability distributions produced by a teacher model, typically smoothed by a high temperature parameter, which provide richer information about inter-class similarities than hard labels.

In knowledge distillation, a soft target is the output probability vector from a teacher model after applying a high temperature scaling parameter to the softmax function. Unlike a one-hot hard label that only identifies the correct class, a soft target distributes probability mass across all classes, revealing the teacher's learned similarities—for example, assigning a higher probability to 'truck' than to 'apple' when the true label is 'car'. This inter-class relational information is the dark knowledge that a student model must absorb.

The soft target serves as the supervisory signal in the distillation loss, where the Kullback-Leibler divergence between the teacher's and student's softened distributions is minimized. By matching these rich probability vectors rather than sparse ground-truth labels, the student model learns a smoother, more generalizable decision boundary that captures the teacher's inductive biases, often achieving higher accuracy with fewer parameters than training on hard targets alone.

DARK KNOWLEDGE

Key Characteristics of Soft Targets

Soft targets are the probability distributions produced by a teacher model, typically softened by a high temperature parameter. Unlike hard labels, they encode rich information about inter-class similarities and the teacher's internal uncertainty.

01

Probability Distributions Over Classes

A soft target is a vector of probabilities over all possible classes, not just the correct one. For a three-class problem, a teacher might output [0.85, 0.12, 0.03] instead of the hard label [1, 0, 0]. The non-zero probabilities on incorrect classes encode dark knowledge—the teacher's learned similarity structure. For example, an image of a cat might have a 0.03 probability for 'dog' and 0.001 for 'airplane', revealing that cats are more similar to dogs than to airplanes. This relational information is the core value of soft targets.

02

Temperature Scaling

A hyperparameter T applied to the softmax function that controls the softness of the output distribution:

  • T = 1: Standard softmax, producing sharp, confident distributions
  • T > 1: Softens the distribution, amplifying the relative probabilities of incorrect classes
  • T → ∞: Produces a uniform distribution where all classes are equally likely

The softened distribution reveals the dark knowledge hidden in the teacher's logits. A typical distillation temperature ranges from 2 to 20, depending on the complexity of the task and the capacity of the student model.

2–20
Typical Temperature Range
03

Rich Supervisory Signal

Soft targets provide significantly more information per training example than hard labels. A hard label for a 1000-class problem conveys exactly log₂(1000) ≈ 10 bits of information. In contrast, a soft target distribution conveys the full covariance structure between classes, effectively providing orders of magnitude more supervision. This is why a student model trained on soft targets can often match teacher performance with far fewer examples, and why distillation is sometimes called model compression through rich supervision.

04

Distillation Loss Integration

Soft targets are used in the Kullback-Leibler (KL) divergence term of the distillation loss function. The total loss is typically:

code
L = α * L_CE(student_logits, hard_labels) + (1-α) * T² * L_KL(student_softmax/T, teacher_softmax/T)
  • L_CE: Standard cross-entropy with ground truth
  • L_KL: KL divergence between temperature-scaled student and teacher distributions
  • T² multiplier: Compensates for the gradient scaling effect of temperature
  • α: Weighting hyperparameter balancing the two objectives
05

Ensemble Knowledge Encoding

When the teacher is an ensemble of models, soft targets encode the collective uncertainty and diversity of the ensemble members. The resulting distribution represents a Bayesian model average over the ensemble's predictions. A single student trained on these ensemble-derived soft targets can capture the generalization benefits of the entire ensemble—including reduced overfitting and calibrated uncertainty estimates—without the inference cost of running multiple models. This is one of the most powerful applications of distillation.

06

Gradient Information Content

The gradient of the cross-entropy loss with respect to the logits for a soft target is proportional to (p_teacher - p_student). This means the student receives a directional correction signal for every class, not just the target class. Even when the student correctly predicts the top class, it continues to learn from the teacher's relative probabilities on all other classes. This dense gradient signal explains why distillation often converges faster and to better minima than training on hard labels alone.

SOFT TARGETS

Frequently Asked Questions

Clear answers to common questions about the probability distributions that transfer 'dark knowledge' from teacher to student models during the distillation process.

Soft targets are the probability distributions over all possible classes produced by a teacher model's softmax layer, typically smoothed using a high temperature parameter (T > 1). Unlike hard targets—which are one-hot encoded ground-truth labels assigning 100% probability to the correct class and 0% to all others—soft targets assign non-zero probabilities to incorrect classes. These relative probabilities encode the teacher's learned similarities between classes, revealing that, for example, a handwritten '3' is more similar to an '8' than to a 'cat'. This rich inter-class relational information, termed dark knowledge, provides significantly more information per training sample than a hard label, enabling a compact student model to generalize better by learning not just the correct answer, but the structure of the teacher's errors.

Prasad Kumkar

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.