arXiv:2602.23197cs.CLcs.LG2026-02被引 1

提出线性注意力模型理论,解释微调为何会损害上下文学习能力

Fine-Tuning Without Forgetting In-Context Learning: A Theoretical Analysis of Linear Attention Models

  • 用线性注意力模型分析微调对注意力参数的影响
  • 全参数微调会破坏上下文学习,仅更新值矩阵可兼顾零样本性能
  • 额外加入少量样本损失能提升目标任务表现但影响泛化能力

基于Transformer的大语言模型具备上下文学习能力,可通过少量示例提示实现下游任务适应。实际中常通过微调提升零样本性能,降低推理成本,但微调可能削弱上下文学习能力,导致未见过的任务表现下降。本文利用线性注意力模型进行理论分析,揭示微调目标如何改变注意力参数,并识别出性能退化的条件。结果表明,全参数微调会损害上下文学习,而仅更新值矩阵可在保持上下文学习的同时提升零样本性能。进一步发现,引入辅助的少样本损失可增强目标任务的上下文学习能力,但会降低对未见任务的泛化能力。合成数据和真实数据集上的实验验证了理论预测的定性结论。

原文摘要 · Abstract (English)

Transformer-based large language models exhibit in-context learning, enabling adaptation to downstream tasks via few-shot prompting with demonstrations. In practice, such models are often fine-tuned to improve zero-shot performance on downstream tasks, allowing them to solve tasks without examples and thereby reducing inference costs. However, fine-tuning can degrade in-context learning, limiting the performance of fine-tuned models on tasks not seen during fine-tuning. Using linear attention models, we provide a theoretical analysis that characterizes how fine-tuning objectives modify attention parameters and identifies conditions under which this leads to degraded few-shot performance. We show that fine-tuning all attention parameters can harm in-context learning, whereas restricting updates to the value matrix improves zero-shot performance while preserving in-context learning. We further show that incorporating an auxiliary few-shot loss enhances in-context learning primarily on the target task, at the expense of degraded in-context learning ability on tasks not seen during fine-tuning. We provide empirical evidence from synthetic and real-world datasets consistent with the qualitative predictions of our theory.

微调上下文学习注意力机制理论分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。