揭示Transformer在上下文学习中的泛化边界,发现跨任务泛化弱但同任务内泛化强。
Understanding the Generalization of In-Context Learning in Transformers: An Empirical Study
- 构建三维度任务框架,系统评估上下文学习的泛化能力
- 实验证明模型跨任务泛化差,但同任务内泛化优异
- 建议训练时增加任务多样性以提升未知任务表现
大型语言模型如GPT-4和LLaMA-3利用Transformer架构的上下文学习(ICL)能力,在有限示例下实时学习。尽管ICL支撑众多应用,其泛化边界与脆弱性仍不明确。本文提出一个以任务为中心的框架,从跨问题、同问题、同任务三个维度系统研究Transformer在ICL下的泛化能力。通过函数拟合、API调用、翻译等任务的大量模拟与真实实验发现:模型缺乏跨问题泛化能力,但在同任务和同问题内表现出色。当训练数据包含更丰富的混合任务时,其在未见任务乃至简单已知任务上的泛化能力显著增强。因此建议在设计训练数据时最大化任务多样性,并尽可能融合不同任务,而非仅聚焦目标任务。
原文摘要 · Abstract (English)
Large language models (LLMs) like GPT-4 and LLaMA-3 utilize the powerful in-context learning (ICL) capability of Transformer architecture to learn on the fly from limited examples. While ICL underpins many LLM applications, its full potential remains hindered by a limited understanding of its generalization boundaries and vulnerabilities. We present a systematic investigation of transformers' generalization capability with ICL relative to training data coverage by defining a task-centric framework along three dimensions: inter-problem, intra-problem, and intra-task generalization. Through extensive simulation and real-world experiments, encompassing tasks such as function fitting, API calling, and translation, we find that transformers lack inter-problem generalization with ICL, but excel in intra-task and intra-problem generalization. When the training data includes a greater variety of mixed tasks, it significantly enhances the generalization ability of ICL on unseen tasks and even on known simple tasks. This guides us in designing training data to maximize the diversity of tasks covered and to combine different tasks whenever possible, rather than solely focusing on the target task for testing.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。