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

Bingqing Song, Jiaxiang Li, Rong Wang, Songtao Lu, Mingyi Hong
10/26/2025
cs.AIcs.LG

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{song2025framework,
  title  = {A Framework for Quantifying How Pre-Training and Context Benefit In-Context Learning},
  author = {Bingqing Song and Jiaxiang Li and Rong Wang and Songtao Lu and Mingyi Hong},
  year   = {2025},
  eprint = {2510.22594},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.22594v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.22594.svg)](https://codeofpaper.com/paper/2510.22594)

Discussion