arXiv:2510.22594cs.AIcs.LG2025-10

揭示预训练与上下文如何共同影响模型的上下文学习能力

A Framework for Quantifying How Pre-Training and Context Benefit In-Context Learning

  • 构建理论框架,量化预训练数据与任务分布差异对学习的影响
  • 发现合理构造的上下文可使输出分布向目标任务分布偏移
  • 给出上下文长度与分布差异间的关系公式,适用于多种场景

预训练大语言模型展现出强大的上下文学习(ICL)能力。尽管相关应用迅速发展,但其理论机制仍不清晰,尤其是预训练过程与上下文构造的作用尚不明确。本文提出一个分析框架,涵盖网络结构、数据编码、数据生成和提示构造等实际设置。首先在单层Transformer中证明:当预训练数据分布与查询任务分布不同时,合理设计的上下文可定量地将输出分布推向目标分布,实现准确预测。随后将结论推广至一般情形,推导出ICL性能、上下文长度与预训练-任务分布间KL散度之间的精确关系。最后通过实验验证了理论结果的有效性。

原文摘要 · Abstract (English)

Pre-trained large language models have demonstrated a strong ability to learn from context, known as in-context learning (ICL). Despite a surge of recent applications that leverage such capabilities, it is by no means clear, at least theoretically, how the ICL capabilities arise, and in particular, what is the precise role played by key factors such as pre-training procedure as well as context construction. In this work, we propose a new framework to analyze the ICL performance, for a class of realistic settings, which includes network architectures, data encoding, data generation, and prompt construction process. As a first step, we construct a simple example with a one-layer transformer, and show an interesting result, namely when the pre-train data distribution is different from the query task distribution, a properly constructed context can shift the output distribution towards the query task distribution, in a quantifiable manner, leading to accurate prediction on the query topic. We then extend the findings in the previous step to a more general case, and derive the precise relationship between ICL performance, context length and the KL divergence between pre-train and query task distribution. Finally, we provide experiments to validate our theoretical results.

上下文学习理论分析预训练分布偏移

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