In-Context Learning Distillation for Efficient Few-Shot Fine-Tuning
Yifei Duan, Liu Li, Zirui Zhai, Jinxia Yao
TL;DR
Context Distillation addresses memory and token-context limitations of in-context learning by transferring context information into a compact 125M student distilled from a 1.3B teacher. The approach blends fine-tuning and ICL with parameter-efficient training (LoRA/BitFit) and a KL–CE loss balance, achieving notably better out-of-domain generalization and substantial memory savings on MNLI. Key findings include approximately a 50% gain in out-of-domain accuracy and up to a 60% reduction in peak memory compared with pattern-based fine-tuning, while enabling on-device, few-shot adaptation without consuming input token budgets. These results suggest context distillation as a practical pathway to scalable, memory-efficient deployment of LLMs for long-context tasks and on-device applications, with promising variants like CD+LoRA for faster training and robust performance.
Abstract
We applied few-shot in-context learning on the OPT-1.3B model for the natural language inference task and employed knowledge distillation to internalize the context information, reducing model parameter from 1.3B to 125M and achieving a size reduction from 2.5GB to 0.25GB. Compared to using in-context learning alone on similarly sized models, this context distillation approach achieved a nearly 50% improvement in out-of-domain accuracy, demonstrating superior knowledge transfer capabilities over prompt-based methods. Furthermore, this approach reduced memory consumption by up to 60% while delivering a 20% improvement in out-of-domain accuracy compared to conventional pattern-based fine-tuning.
