The surge in Large Language Models (LLMs) has revolutionized natural language processing, but fine-tuning them for specific tasks often encounters challenges in balancing performance and preserving general instruction-following abilities. In this paper, we posit that the distribution gap between task datasets and the LLMs serves as the primary underlying cause. To address the problem, we introduce Self-Distillation Fine-Tuning (SDFT), a novel approach that bridges the distribution gap by guiding fine-tuning with a distilled dataset generated by the model itself to match its original distribution. Experimental results on the Llama-2-chat model across various benchmarks demonstrate that SDFT effectively mitigates catastrophic forgetting while achieving comparable or superior performance on downstream tasks compared to the vanilla fine-tuning. Moreover, SDFT demonstrates the potential to maintain the helpfulness and safety alignment of LLMs. Our code is available at https://github.com/sail-sg/sdft.
翻译:大型语言模型(LLMs)的兴起彻底改变了自然语言处理领域,但针对特定任务对其进行微调时,常面临平衡性能与保持通用指令遵循能力之间的挑战。本文认为,任务数据集与LLMs之间的分布差距是导致该问题的主要根源。为解决此问题,我们提出了自蒸馏微调(SDFT),这是一种通过模型自身生成的、与其原始分布匹配的蒸馏数据集来指导微调,从而弥合分布差距的新方法。在Llama-2-chat模型上进行的多基准实验表明,与原始微调方法相比,SDFT能有效缓解灾难性遗忘,同时在下游任务上取得相当或更优的性能。此外,SDFT展现出保持LLMs助益性与安全对齐性的潜力。我们的代码公开于 https://github.com/sail-sg/sdft。