揭示大模型在提示中持续学习时的遗忘与泛化机制
Understanding Generalization and Forgetting in In-Context Continual Learning

- 构建首个上下文持续学习理论框架,分析注意力机制如何处理多任务序列
- 发现标准注意力会因历史信息均匀或因果聚合导致任务间干扰,引发系统性偏差
- 提出误差分解模型,解释长提示下性能下降和顺序敏感性的根本原因
上下文学习(ICL)使大语言模型仅通过提示推理即可适应新任务,无需参数更新。现有理论多聚焦单任务场景,而真实提示常包含异构任务序列,导致对大模型是否在推理中隐式执行持续学习的理解不足。本文首次提出上下文持续学习的理论框架,建模预训练Transformer如何通过共享注意力机制处理单个提示中的多个顺序任务。针对线性和掩码线性自注意力,推导出任务序列提示下的预测误差表达式,并分析其泛化与遗忘行为。结果表明,标准注意力机制不可避免地通过均匀或因果方式聚合历史上下文,引发任务间干扰,导致系统性偏差。进一步提供偏差-方差-干扰分解,刻画历史上下文何时带来正向迁移或可证明的负向迁移。该分析揭示了基于注意力的持续推理的根本局限,并为长提示中的顺序敏感性与性能退化提供了理论解释。
原文摘要 · Abstract (English)
In-context learning (ICL) derives its power from enabling Large Language Models to adapt to new tasks via prompt-based reasoning alone, entirely bypassing the need for parameter updates. Existing theories primarily study ICL in single-task settings, while real-world prompts often contain sequences of heterogeneous tasks, leaving a gap in understanding whether Large Language Models implicitly perform continual learning during inference. To bridge this gap, we propose the first theoretical framework for in-context continual learning, modeling how a pretrained Transformer processes multiple sequential tasks within a single prompt through shared attention mechanisms. Focusing on linear and masked linear self-attention, we derive error expressions for model predictions under sequential task prompts and analyze their generalization and forgetting behavior. Our results reveal that standard attention mechanisms inevitably induce intertask interference by uniformly or causally aggregating historical contexts, leading to systematic bias. We further provide a bias-variance-interference decomposition of prediction error, characterizing when historical in-context information yields positive transfer or provable negative transfer. This analysis exposes fundamental limits of attention-based continual inference and offers theoretical explanations for order sensitivity and performance degradation in long prompts.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。