Table of Contents
Fetching ...

Few-Shot Knowledge Distillation of LLMs With Counterfactual Explanations

Faisal Hamman, Pasan Dissanayake, Yanjun Fu, Sanghamitra Dutta

TL;DR

This work tackles the data scarcity challenge in task-aware KD for LLMs by introducing CoD, which augments few-shot training with counterfactual explanations to better capture the teacher’s decision boundary. It provides statistical and geometric guarantees to motivate the use of CFEs and describes a practical CFE-generation pipeline that leverages LLMs. Empirically, CoD improves distillation performance across multiple datasets and model families in few-shot settings, often halving the required real labeled data while maintaining or boosting accuracy. The approach offers a data-efficient, explainability-driven path to deploying task-focused, smaller LLMs in resource-constrained environments, with potential extensions to generative models.

Abstract

Knowledge distillation is a promising approach to transfer capabilities from complex teacher models to smaller, resource-efficient student models that can be deployed easily, particularly in task-aware scenarios. However, existing methods of task-aware distillation typically require substantial quantities of data which may be unavailable or expensive to obtain in many practical scenarios. In this paper, we address this challenge by introducing a novel strategy called Counterfactual-explanation-infused Distillation CoD for few-shot task-aware knowledge distillation by systematically infusing counterfactual explanations. Counterfactual explanations (CFEs) refer to inputs that can flip the output prediction of the teacher model with minimum perturbation. Our strategy CoD leverages these CFEs to precisely map the teacher's decision boundary with significantly fewer samples. We provide theoretical guarantees for motivating the role of CFEs in distillation, from both statistical and geometric perspectives. We mathematically show that CFEs can improve parameter estimation by providing more informative examples near the teacher's decision boundary. We also derive geometric insights on how CFEs effectively act as knowledge probes, helping the students mimic the teacher's decision boundaries more effectively than standard data. We perform experiments across various datasets and LLMs to show that CoD outperforms standard distillation approaches in few-shot regimes (as low as 8-512 samples). Notably, CoD only uses half of the original samples used by the baselines, paired with their corresponding CFEs and still improves performance.

Few-Shot Knowledge Distillation of LLMs With Counterfactual Explanations

TL;DR

This work tackles the data scarcity challenge in task-aware KD for LLMs by introducing CoD, which augments few-shot training with counterfactual explanations to better capture the teacher’s decision boundary. It provides statistical and geometric guarantees to motivate the use of CFEs and describes a practical CFE-generation pipeline that leverages LLMs. Empirically, CoD improves distillation performance across multiple datasets and model families in few-shot settings, often halving the required real labeled data while maintaining or boosting accuracy. The approach offers a data-efficient, explainability-driven path to deploying task-focused, smaller LLMs in resource-constrained environments, with potential extensions to generative models.

Abstract

Knowledge distillation is a promising approach to transfer capabilities from complex teacher models to smaller, resource-efficient student models that can be deployed easily, particularly in task-aware scenarios. However, existing methods of task-aware distillation typically require substantial quantities of data which may be unavailable or expensive to obtain in many practical scenarios. In this paper, we address this challenge by introducing a novel strategy called Counterfactual-explanation-infused Distillation CoD for few-shot task-aware knowledge distillation by systematically infusing counterfactual explanations. Counterfactual explanations (CFEs) refer to inputs that can flip the output prediction of the teacher model with minimum perturbation. Our strategy CoD leverages these CFEs to precisely map the teacher's decision boundary with significantly fewer samples. We provide theoretical guarantees for motivating the role of CFEs in distillation, from both statistical and geometric perspectives. We mathematically show that CFEs can improve parameter estimation by providing more informative examples near the teacher's decision boundary. We also derive geometric insights on how CFEs effectively act as knowledge probes, helping the students mimic the teacher's decision boundaries more effectively than standard data. We perform experiments across various datasets and LLMs to show that CoD outperforms standard distillation approaches in few-shot regimes (as low as 8-512 samples). Notably, CoD only uses half of the original samples used by the baselines, paired with their corresponding CFEs and still improves performance.
Paper Structure (17 sections, 8 theorems, 35 equations, 6 figures, 9 tables, 1 algorithm)

This paper contains 17 sections, 8 theorems, 35 equations, 6 figures, 9 tables, 1 algorithm.

Key Result

Theorem 1

Let $\mathbf{w}_s$ and $\mathbf{w}_s^{\mathrm{(cf)}}$ be the student parameters obtained via MLE on $\mathcal{D}$ (standard) and $\mathcal{D}_{\mathrm{cf}}$ (CFE-infused). Assuming the teacher’s parameters $\mathbf{w}_t$ capture the true data-generating distribution, that CFEs lie near the decision

Figures (6)

  • Figure 1: Intuition behind our approach: (a) Teacher trained on the full dataset with true decision boundary. (b–c) With few-shot supervision, many classifiers can fit the sparse points; the resulting student boundaries (dashed lines) can vary and do not always align with the teacher's boundary (unfaithful distillation). (d) Pairing each point with its CFE (×, linked to originals) during distillation makes the student match the teacher's soft predictions at these points. CFEs act as boundary-near pegs that clamp the student to the teacher’s decision surface, producing a more faithful distillation even under few-shot budgets.
  • Figure 2: Overview of our framework: Counterfactual Explanation-Infused Distillation (CoD).
  • Figure 3: Decision boundaries for teacher and two students trained on synthetic data under few-shot setting. The teacher (a) is trained on the full dataset and serves as the distillation target. Student (b) is distilled using 20 randomly sampled data points, and results in a poorly aligned decision boundary with the teacher. Student (c) is also trained on 20 total samples, 10 original data points and their 10 CFEs. This student learns a better decision boundary that aligns more closely with the teacher. This is because the CFEs lie close to the teacher's decision boundary and the KD loss encourages the student to match the teacher's soft predictions at the CFEs, clamping the student's boundary to the teacher's boundary.
  • Figure 4: Hausdorff Distance.
  • Figure 5: Intuition for \ref{['thm:alpha+eps']}
  • ...and 1 more figures

Theorems & Definitions (23)

  • Definition 1: Closest CFE $\mathcal{C}(\mathbf{x}, f_t)$
  • Remark 1: Data Manifold Counterfactual Explanations
  • Definition 2: Fisher Information Matrix lehmann1998theory
  • Theorem 1: CFEs Improve Model Parameter Estimation
  • Definition 3: Hausdorff Distance
  • Lemma 1: Existence of Boundary Crossing for Counterfactual Pairs
  • Theorem 2: Teacher–Student Boundary Proximity
  • Definition 4: Positive Semi-definite Matrices
  • Definition 5: Löwner Order
  • Lemma 2: Trace Inequality for Positive Semi-definite Matrices
  • ...and 13 more