Inferensys

Glossary

Soft Targets

Soft targets are the softened probability distributions output by a teacher model after temperature scaling, providing a richer training signal than hard labels for a student model in knowledge distillation.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
KNOWLEDGE DISTILLATION

What are Soft Targets?

In knowledge distillation, soft targets are the probability distributions output by a teacher model, which provide a richer training signal than simple one-hot labels.

Soft targets are the probability distributions produced by a teacher model after applying temperature scaling to its logits. Unlike hard targets (one-hot encoded labels), which only indicate the correct class, these softened probabilities reveal the teacher's relative confidence across all classes, encapsulating dark knowledge about class similarities and decision boundaries. This richer supervisory signal allows a student model to learn a more nuanced and generalizable representation.

The primary use of soft targets is in knowledge distillation for retention within continual learning systems. Here, the current model's predictions on data from previous tasks serve as soft targets, creating a distillation loss (e.g., KL Divergence) that regularizes training on new data. This technique, as seen in algorithms like Learning without Forgetting (LwF), is a core method for mitigating catastrophic forgetting by preserving the plasticity-stability trade-off.

KNOWLEDGE DISTILLATION

Key Characteristics of Soft Targets

Soft targets are the probability distributions output by a teacher model after temperature scaling. Unlike hard labels, they provide a richer, more nuanced training signal for a student model.

01

Probabilistic vs. Deterministic

A hard target is a one-hot encoded vector (e.g., [0, 0, 1, 0]) assigning all probability to a single class. A soft target is a probability distribution (e.g., [0.05, 0.15, 0.70, 0.10]) across all classes. This distribution encodes the teacher's relative confidence and class similarities, known as dark knowledge. For instance, an image of a 'husky' might yield high probability for 'dog' but also small, non-zero probabilities for related classes like 'wolf' or 'malamute', which a one-hot label would discard.

02

Temperature Scaling (τ)

Temperature scaling is the core operation that generates soft targets. A temperature parameter (τ) is applied to the teacher's logits (pre-softmax activations) within the softmax function:

softmax(z_i, τ) = exp(z_i / τ) / Σ_j exp(z_j / τ)

  • τ = 1: Standard softmax, producing the model's native confidence distribution.
  • τ > 1: 'Softens' the distribution, increasing the entropy and making probabilities more uniform. This amplifies the relative differences between non-true classes, making the dark knowledge more accessible for the student to learn from.
  • τ → ∞: All classes approach uniform probability (1/N).
  • τ < 1: Sharpens the distribution, making it more peaky, approaching a one-hot encoding.
03

Information-Theoretic Richness

Soft targets provide a denser training signal by preserving inter-class relationships and the teacher's uncertainty. This richness offers several benefits:

  • Regularization: The smoother label distribution acts as a regularizer, preventing the student from overfitting to potentially noisy hard labels.
  • Gradient Variance Reduction: Provides more stable, lower-variance gradients compared to the sparse, high-variance signal from hard targets.
  • Transfer of Generalization: The student learns the teacher's internal representation of similarity between concepts, often leading to better generalization on unseen data than training on hard labels alone.
04

Loss Function: KL Divergence

Training a student model with soft targets typically uses the Kullback-Leibler (KL) Divergence loss, which measures how one probability distribution diverges from a second, reference distribution. The student's softened outputs (using the same τ as the teacher) are matched to the teacher's soft targets.

L_KD = τ^2 * KL( P_teacher(τ) || P_student(τ) )

The τ^2 term is used to ensure the magnitude of the gradient remains roughly constant when changing the temperature. This is often combined with a standard cross-entropy loss with true hard labels in a weighted sum: L_total = α * L_CE + β * L_KD.

05

Role in Mitigating Catastrophic Forgetting

In continual learning, soft targets are a key tool for knowledge retention. When learning a new task (Task B), the model's predictions on data from the old task (Task A) are used as soft targets. By applying a distillation loss between the current model's outputs on old data and its past outputs (or a saved copy of the old model's outputs), the model is penalized for changing its behavior on previous tasks. This technique, central to algorithms like Learning without Forgetting (LwF), helps anchor the model's parameters to preserve old knowledge while adapting to new data.

06

Contrast with Logits and Features

Soft targets are one form of knowledge transferred from teacher to student. Other forms include:

  • Logit Distillation: Directly matching the teacher's logits (pre-softmax activations), often using Mean Squared Error loss. This is closely related to soft target distillation but operates on the unscaled logits.
  • Feature/Activation Distillation: Matching intermediate representations (e.g., hidden states or feature maps from convolutional layers). Techniques like FitNets use this to guide the student's internal layers.
  • Attention Distillation: Matching the attention maps of transformer-based models.

Soft target distillation is often the most straightforward and effective method for transferring the teacher's final predictive knowledge.

CORE MECHANISM

How Soft Targets Work in Knowledge Distillation

Soft targets are the probability distributions output by a teacher model after temperature scaling, which contain relative class similarities and serve as a richer training signal than hard, one-hot encoded labels for the student model.

A soft target is the softened probability distribution output by a teacher model after applying temperature scaling to its logits. Unlike a hard, one-hot label that only indicates the correct class, this distribution encodes the teacher's relative confidence across all classes, including its understanding of inter-class similarities—a concept known as dark knowledge. This richer supervisory signal allows a student model to learn a more nuanced and generalizable decision boundary.

During training, the student model is optimized to match these soft targets, typically using a Kullback-Leibler (KL) Divergence loss. This process, central to logit distillation, transfers not just the teacher's final predictions but its implicit knowledge of data relationships. In continual learning, a model can generate soft targets for past tasks to serve as a regularization signal, a technique used in algorithms like Learning without Forgetting (LwF) to mitigate catastrophic forgetting.

KNOWLEDGE DISTILLATION

Soft Targets vs. Hard Targets

A comparison of the two primary supervisory signal types used when training a student model in the teacher-student framework.

FeatureSoft TargetsHard Targets

Definition

The probability distribution output by a teacher model after temperature scaling (T > 1).

One-hot encoded vectors where the true class is 1 and all others are 0.

Information Content

Rich, containing relative class similarities and 'dark knowledge'.

Sparse, containing only the identity of the single correct class.

Primary Use Case

Knowledge distillation for model compression and continual learning.

Standard supervised training of classification models.

Training Signal

Provides a smoother, more informative gradient by indicating 'this is somewhat like that'.

Provides a sharp, high-variance gradient focused solely on the correct class.

Effect on Generalization

Typically improves student model generalization and robustness by transferring the teacher's internal representations.

Can lead to overconfidence and poorer calibration if not regularized.

Loss Function

Kullback-Leibler (KL) Divergence between softened teacher and student distributions.

Cross-Entropy between student predictions and the one-hot label.

Label Smoothing Relation

Inherently performs a form of adaptive, learned label smoothing.

Often combined with static label smoothing (e.g., epsilon=0.1) as a regularization technique.

Role in Forgetting Mitigation

Core to distillation-based methods (e.g., LwF); the old model's soft predictions on new data act as targets to preserve knowledge.

Not directly applicable; replaying hard labels from old data is the primary method.

SOFT TARGETS

Frequently Asked Questions

Soft targets are a core concept in knowledge distillation, providing a richer training signal than traditional labels. These FAQs address their technical definition, application, and role in modern machine learning systems.

Soft targets are the probability distributions output by a teacher model after applying temperature scaling to its logits, which contain relative class similarities and serve as a richer, more informative training signal than hard, one-hot encoded labels for a student model.

Unlike a hard target (e.g., [0, 0, 1, 0] for class 3), a soft target looks like [0.05, 0.1, 0.7, 0.15]. This distribution encodes the teacher's dark knowledge—its understanding of which incorrect classes are more or less similar to the correct one. For instance, in image classification, a model classifying a 'Siamese cat' might assign higher probabilities to 'Tabby cat' and 'Egyptian Mau' than to 'truck,' information lost in a one-hot label. The student model is trained using a loss function like Kullback-Leibler (KL) Divergence to match this softened distribution, leading to better generalization and often higher accuracy than training on hard labels alone.

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.