通过调控注意力机制提升大模型上下文学习能力,仅需极少数据即可实现高效优化。
Mechanistic Fine-tuning for In-context Learning
- 基于注意力行为设计新训练目标,直接引导模型关注正确标签
- 性能、鲁棒性、公平性全面超越传统方法,数据成本降低至0.01%
- 揭示了上下文学习数据隐含的诱导头形成机制,适合可解释性研究者
上下文学习(ICL)通过结构化示例-查询输入,使未在该类型数据上预训练的语言模型实现少样本学习。为弥合ICL与预训练之间的差距,现有方法采用端到端范式在大规模ICL数据集上微调模型,但计算成本高昂。本文提出注意力行为微调(ABFT),基于对ICL内在机制的研究,不直接优化输出结果,而是构建基于注意力分数的训练目标,强制模型关注上下文中正确的标签词元,抑制错误标签词元的注意力。在9个现代语言模型和8个数据集上的实验表明,ABFT在性能、鲁棒性、无偏性和效率方面均优于以往方法,且仅需约0.01%的数据成本。后续分析发现,端到端训练目标包含ABFT目标,提示ICL风格数据对诱导头出现具有隐含偏差。本工作展示了控制语言模型内部特定模块序列以改善其行为的可能性,为机制可解释性未来应用开辟新路径。
原文摘要 · Abstract (English)
In-context Learning (ICL) utilizes structured demonstration-query inputs to induce few-shot learning on Language Models (LMs), which are not originally pre-trained on ICL-style data. To bridge the gap between ICL and pre-training, some approaches fine-tune LMs on large ICL-style datasets by an end-to-end paradigm with massive computational costs. To reduce such costs, in this paper, we propose Attention Behavior Fine-Tuning (ABFT), utilizing the previous findings on the inner mechanism of ICL, building training objectives on the attention scores instead of the final outputs, to force the attention scores to focus on the correct label tokens presented in the context and mitigate attention scores from the wrong label tokens. Our experiments on 9 modern LMs and 8 datasets empirically find that ABFT outperforms in performance, robustness, unbiasedness, and efficiency, with only around 0.01% data cost compared to the previous methods. Moreover, our subsequent analysis finds that the end-to-end training objective contains the ABFT objective, suggesting the implicit bias of ICL-style data to the emergence of induction heads. Our work demonstrates the possibility of controlling specific module sequences within LMs to improve their behavior, opening up the future application of mechanistic interpretability.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。