Manuscript Offprint

arXiv:2610.12837

COFFEQA: Counterfactual-Guided Few-Shot Distillation for LLM Question Answering

Kavinda Kehelella, Sanghamitra Dutta

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Knowledge distillation aims to train a smaller student model to mimic a larger teacher model for resource-constrained environments. However, the process of distillation is typically data-intensive and computationally expensive, particularly for generative tasks. Few-shot distillation offers an alternative by transferring teacher knowledge using limited training samples. However, we observe that few-shot distillation performance is heavily dependent on the choice of these training samples. In fact, we demonstrate that using more uncertain samples near the teacher's decision boundary can significantly deteriorate distillation performance. Motivated by this observation, we propose Counterfactual-guided Few-shot Distillation in open-book Question Answering (COFFEQA), a novel strategy that aptly uses counterfactuals to provide additional supervision around challenging factual samples. In the generative QA setting, we define a counterfactual as a minimally modified context that induces the teacher to change its response to an alternative answer. We provide geometric insights on how factual-counterfactual pairs can constrain the deviation between the teacher's and student's decision boundaries. We further introduce a new metric, Context Following Difficulty (CFD) that further validates counterfactuals prior to distillation based on agreement with the intended alternative answer and dependence on the modified context. COFFEQA uses CFD-validated factual-counterfactual pairs for few-shot distillation. Experiments across five in-domain and three out-of-domain QA benchmarks using T5 and Qwen2.5 families show that COFFEQA outperforms factual-only distillation baselines under the same few-shot budget. For instance, on TriviaQA, COFFEQA improves over the factual-only baseline by 8.77 average EM points and 9.98 average F1 points under the T5 setting with 32 few-shot pairs.

1 INTRODUCTION

Large language models (LLMs) have achieved remarkable success across a wide range of natural language processing tasks (Achiam et al., 2023; Chung et al., 2024; Gou et al., 2021; Raffel et al., 2020; Fang et al., 2026). However, their increasing size and computational requirements make deployment in resource-constrained environments particularly challenging (Kaplan et al., 2020; Brown et al., 2020; Strubell et al., 2019; Hoffmann et al., 2022). This motivates the need for compact models with low training and inference costs that preserve task-relevant capabilities of larger models (Liang et al., 2023; Saadi & Wang, 2025; Liu et al., 2024; Dissanayake et al., 2024). Knowledge distillation (Hinton et al., 2015) (see surveys Gou et al. (2021); Sanh et al. (2019); Xu et al. (2024b)) seeks to address this challenge by transferring knowledge from a large teacher model to a smaller student model. However, most distillation approaches typically rely on large-scale datasets or extensive supervision from the teacher, thus incurring prohibitive training costs for already resource-intensive language models (Sanh et al., 2019; Sun et al., 2019; Jiao et al., 2020; Wang et al., 2020; Dissanayake & Dutta, 2025; Hamman et al., 2025). This leads to our primary question: How can we perform data-efficient distillation in LLMs?

Towards addressing this question, our work studies few-shot distillation for generative tasks, with a focus on open-book question answering. We find that the performance of few-shot distillation is heavily dependent on the choice of the distillation dataset, consistent with the broader importance

Figure

Figure 1: Counterfactual-guided few-shot distillation framework. We begin with (1) a few-shot factual QA dataset DfD_f and (2) generate a counterfactual candidate for a factual sample. (3) The generated counterfactual is evaluated using the teacher model with (4) our proposed Context Following Difficulty (CFD) metric and accepted if it satisfies the CFD threshold τ\tau. (5) The CFD-validated counterfactuals are then paired with their corresponding factuals and used to distill the student model.

of data selection for efficient LLM training (Fu et al., 2026; Zhou et al., 2023). In particular, samples near the teacher's decision boundary can significantly deteriorate distillation performance (see Fig. 6 in Section C), also consistent with prior findings on knowledge transfer around decision boundaries (Chen et al., 2025). This motivates us to provide additional supervision around these challenging regions while maintaining a limited few-shot budget. To achieve this, we leverage counterfactual examples. Counterfactual-based data augmentation has improved classification performance (Kaushik et al., 2019; Wu et al., 2021; Ross et al., 2021; Gardner et al., 2020; McAleese & Keane, 2024; Bhattacharjee et al., 2024; Egea et al., 2025) by encouraging models to capture causal dependencies and avoid shortcut learning (Guo et al., 2023; Chen et al., 2023b). However, its applicability to few-shot distillation for generative tasks remains largely unexplored. Unlike classification, generative tasks produce free-form outputs, making counterfactuals non-trivial to define. In generative tasks, we define a counterfactual to be a minimally modified input that changes the expected output while preserving overall semantic consistency, such as modifying supporting context in a question to induce a different answer (Guo et al., 2023; Longpre et al., 2021; Paranjape et al., 2022; Köksal et al., 2023; Yu et al., 2023).

In this work, we propose Counterfactual-guided Few-shot distillation in open-book Question Answering (COFFEQA), a novel strategy for few-shot distillation that aptly uses counterfactuals to provide additional supervision around challenging factual samples near the teacher's decision boundary. We demonstrate how selecting high-quality counterfactuals can guide knowledge transfer more effectively using extremely limited few-shot budget. Our main contributions are as follows:

Counterfactual-guided few-shot distillation for generative tasks. We show that few-shot distillation becomes particularly challenging for factuals near the teacher's decision boundary, where the teacher has a smaller margin between its preferred answer and competing alternatives. Motivated by this observation, we propose COFFEQA, a novel framework which leverages counterfactuals for few-shot distillation in open-book QA. Rather than relying solely on factual supervision, COFFEQA pairs challenging factuals with their counterfactuals that expose changes in the teacher's response under minimal modifications to the input context, providing additional supervision around the teacher's decision boundary. This reduces dependence on large factual training corpora and improves training efficiency under limited supervision (see Figure 1 for an overview).

Geometric analysis of counterfactual-guided knowledge transfer. We first introduce a notion of decision boundaries for the teacher and student in the context-embedding space, motivated by the fact that variations in the input context can lead to different answers. Our formulation enables us to analyze distillation in open-book QA from a geometric perspective. Specifically, we show that factual-counterfactual pairs can act as probes for the student to approximate the local geometry of the teacher's decision boundary. To quantify the deviation between the teacher and student, we use the Hausdorff distance (Rockafellar & Wets, 1998), which measures the worst-case deviation between their decision boundaries. We show in Proposition 1 that this deviation is bounded by the magnitude of the counterfactual perturbations and their coverage of the teacher's decision boundary. Importantly, factuals near the teacher's decision boundary can require smaller perturbations to induce a change in the teacher's response, which can lead to tighter teacher-student boundary alignment.

Context Following Difficulty (CFD) for counterfactual validation. Although we generate counterfactuals by perturbing the original input context to induce a targeted alternative answer, not all generated examples are truly valid with respect to the teacher. The teacher may not produce same target answers using the modified context or may still be able to infer them without actually relying on the context. Such cases weaken the intended causal relationship that the student was intended to learn from the teacher and may encourage shortcut learning. To address this issue, we introduce a new metric Context Following Difficulty (CFD) to evaluate generated counterfactuals before distillation. CFD jointly considers whether the teacher produces the intended alternative answer and whether that answer becomes more predictable when conditioned on the modified context. COFFEQA uses CFD-validated counterfactuals, ensuring that the resulting supervision better captures the teacher's context-dependent behavior.

Empirical evaluation. We conduct comprehensive experiments across five in-domain and three out-of-domain benchmarks using the T5 (Raffel et al., 2020) and Qwen2.5 (Bai et al., 2023) model families. The in-domain benchmarks include NaturalQuestions, SQuAD, NewsQA, TriviaQA, and HotpotQA, while the out-of-domain benchmarks include DROP, DuoRC, and RelationExtraction (Fisch et al., 2019). We evaluate COFFEQA with standard knowledge distillation (KD), sequence-level knowledge distillation (SeqKD), and layer-wise distillation (LWD) baselines, under the same few-shot training budget. Across these settings, COFFEQA outperforms factual-only baselines. For instance, on TriviaQA, COFFEQA improves over the KD baseline by 8.77 average EM points and 9.98 average F1 points under the T5 setting with 32 few-shot pairs.

References (82)