Introduction
Large Language Models (LLMs) have demonstrated remarkable In-Context Learning (ICL) capabilities, allowing them to solve novel tasks using only a few demonstration examples provided in the prompt. However, the computational cost of these massive models remains a significant barrier to widespread deployment. While knowledge distillation is a common technique to transfer capabilities to smaller "student" models, traditional approaches focus primarily on output matching—aligning the student's token probability distribution with the teacher's.
This paper argues that output matching alone is insufficient for capturing the full scope of ICL. ICL performance is notoriously sensitive to the selection and ordering of demonstration examples. A teacher model possesses an inherent "preference" for specific contexts that provide better cues for a given task. If a student model fails to share these preferences, its ability to leverage context remains limited, regardless of how well it mimics the final output tokens. To address this, the authors introduce BiAlign, a framework that aligns a student's input preferences with its teacher's.
Methodology: Bidirectional Alignment
The BiAlign framework employs a dual-supervision strategy to teach the student both "what to output" and "which context to value."
The process consists of two main components:
- Token-level Output Alignment: This is the standard distillation objective where the student minimizes the KL divergence between its output distribution and the teacher's for a given sequence.
- Input Preference Alignment: This novel component teaches the student the teacher's underlying strategy for context utilization. The authors sample various subsets of demonstration examples and calculate "preference scores" for each based on the probability of generating the correct answer. A ranking loss function is then used to ensure the student ranks these input subsets in the same order of preference as the teacher.
Experimental Setup
The framework was trained using CrossFit, a collection of over 160 few-shot tasks, resulting in a training set of 12,000 ICL examples. To evaluate generalization, the models were tested on five "held-out" benchmarks that were not seen during training: MMLU (general knowledge), BBH (reasoning), GSM8K (math), LogiQA (logic), and HumanEval (coding).
Results and Key Insights
BiAlign consistently outperformed vanilla models, standard fine-tuning, and output-only distillation across all benchmarks. The method proved particularly effective for reasoning tasks, achieving a 20.4% relative improvement on GSM8K and a 17.8% improvement on LogiQA when using a Llama 2-7B student and a 70B teacher.
Key findings from the study include:
- Context as Strategy: Expertise in LLMs involves identifying relevant information within a prompt. BiAlign successfully transfers this strategic "logic" from teacher to student by matching how they weight evidence.
- The Importance of Similarity: The authors found that sampling subsets based on their similarity to the test query was crucial for providing a clear training signal for preference alignment.
- Scaling Benefits: The effectiveness of BiAlign increases with the size of the teacher model, suggesting that richer preference signals from larger models lead to better student alignment.
- Robustness and Generalization: BiAlign improved performance across different model families (e.g., Llama 3, Phi-3) and enhanced generalization on coding tasks (HumanEval), where standard distillation often fails.
Conclusion
BiAlign represents a significant step forward in model distillation by moving beyond simple output mimicry. While the training process is approximately 2.3 times more computationally expensive than standard distillation due to the need to evaluate multiple input subsets, it incurs no additional cost at inference time. The resulting student models are inherently more effective at utilizing their prompt context, bridging the gap between small models and their massive teachers.
Summary updated