arXiv:2510.25753stat.MLcs.LG2025-10NeurIPS被引 1

揭示Transformer中数据混合如何影响上下文学习性能

How Data Mixing Shapes In-Context Learning: Asymptotic Equivalence for Transformers with MLPs

  • 用双层MLP建模非线性任务,分析多源异构数据下的上下文学习
  • 证明非线性MLP可等价于结构化多项式预测器,提升非线性任务表现
  • 发现低噪声、结构化协方差的数据更优,特征学习需任务协方差有结构

预训练Transformer在无参数更新的情况下能通过示例实现上下文学习(ICL),但现有理论研究多基于简化架构(如忽略MLP)、简单数据模型(如各向同性输入的线性回归)和单源训练,难以反映真实场景。本文研究带有非线性MLP头的Transformer在多源异构数据(不同输入、任务、噪声分布)上的ICL行为,模型中第一层MLP经一次梯度步训练,第二层全优化。在高维渐近条件下,我们证明该模型在ICL误差上等价于结构化多项式预测器,利用高斯泛化性和正交多项式理论。该等价关系表明,相比线性基线,非线性MLP显著提升非线性任务的ICL性能;并精确分析了数据混合效应:高质量数据源具有低噪声与结构化协方差,且仅当任务协方差具备足够结构时才会出现特征学习。实验验证了不同激活函数、模型规模与数据分布下的结果。进一步在多语言情感分析的真实场景中测试,每种语言视为一个数据源,结果表明理论发现可外推至现实应用。本工作推进了Transformer上下文学习的理论基础,并为架构与数据设计提供可操作洞见。

原文摘要 · Abstract (English)

Pretrained Transformers demonstrate remarkable in-context learning (ICL) capabilities, enabling them to adapt to new tasks from demonstrations without parameter updates. However, theoretical studies often rely on simplified architectures (e.g., omitting MLPs), plain data models (e.g., linear regression with isotropic inputs), and single-source training, limiting their relevance to realistic settings. In this work, we study ICL in pretrained Transformers with nonlinear MLP heads on nonlinear tasks drawn from multiple data sources with heterogeneous input, task, and noise distributions. We analyze a model where the MLP comprises two layers, with the first layer trained via a single gradient step and the second layer fully optimized. Under high-dimensional asymptotics, we prove that such models are equivalent in ICL error to structured polynomial predictors, leveraging results from the theory of Gaussian universality and orthogonal polynomials. This equivalence reveals that nonlinear MLPs meaningfully enhance ICL performance, particularly on nonlinear tasks, compared to linear baselines. It also enables a precise analysis of data mixing effects: we identify key properties of high-quality data sources (low noise, structured covariances) and show that feature learning emerges only when the task covariance exhibits sufficient structure. These results are validated empirically across various activation functions, model sizes, and data distributions. Finally, we experiment with a real-world scenario involving multilingual sentiment analysis where each language is treated as a different source. Our experimental results for this case exemplify how our findings extend to real-world cases. Overall, our work advances the theoretical foundations of ICL in Transformers and provides actionable insight into the role of architecture and data in ICL.

上下文学习Transformer理论分析数据混合

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