统一分析因果与掩码语言模型的上下文学习,揭示其性能本质相似。
A Unified Framework for In-Context Learning with Causal and Masked Language Models

- 用经验分布建模上下文,统一分析自回归与双向预训练
- 理论证明两类模型在相同样本下具有相近的推理误差上界
- 实验验证掩码模型可媲美因果模型,适合研究ICL机制者阅读
上下文学习(ICL)已成为预训练语言模型的核心能力,但其理论分析主要聚焦于以GPT风格为代表的自回归因果语言模型。掩码语言模型通过双向上下文恢复被遮蔽词,其在ICL中的作用仍不清晰。本文构建了一个统计学习框架,将上下文示例表示为经验测度,并将预测建模为上下文与查询的函数。该框架将自回归与掩码预训练目标纳入同一过剩风险分析中。在Wasserstein型正则条件下,将具有T个任务、每任务N个样本的预训练与k-shot推理的过剩风险关联起来,得到掩码与自回归目标的同阶上界。还研究了任务分布偏移问题:预训练任务来自分布P,推理任务来自Q;此时上界包含由提升后的Wasserstein距离控制的额外项。边界进一步表明,在固定预训练数据预算下存在最优分配策略,并在内在低维结构下获得更优速率。在受控函数学习任务上的实验显示,掩码对偶编码器(MPE)性能可媲美GPT-2风格的因果Transformer,表明ICL行为并非仅限于因果语言模型。
原文摘要 · Abstract (English)
In-context learning (ICL) has emerged as a central capability of pretrained language models, yet its theoretical analysis has focused primarily on causal language models trained by left-to-right autoregressive prediction, such as GPT-style models. Masked language models instead recover masked tokens from bidirectional context, and their role in ICL remains less understood. We develop a statistical learning framework that represents the context examples by their empirical measure and models prediction as a function of the context and the query. This formulation places autoregressive and masked pretraining objectives within a common excess-risk analysis. Under Wasserstein-type regularity conditions, we relate pretraining with T tasks and N samples per task to k-shot excess risk at inference, obtaining same-order upper bounds for masked and autoregressive objectives. We also study task-distribution shift, where pretraining tasks are sampled from P and inference tasks from Q; the resulting bound contains an additional term controlled by the lifted Wasserstein distance between P and Q. The bounds further imply an order-optimal allocation under a fixed pretraining data budget and refined rates under intrinsic low-dimensional structure. Experiments on controlled function-learning tasks show that the Masked Pair Encoder (MPE) can achieve performance comparable to GPT-2-style causal Transformers, suggesting that ICL behavior is not specific to causal language models.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。