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

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Song, Bingqing, Li, Jiaxiang, Wang, Rong, Lu, Songtao, Hong, Mingyi
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911232009699328
author Song, Bingqing
Li, Jiaxiang
Wang, Rong
Lu, Songtao
Hong, Mingyi
author_facet Song, Bingqing
Li, Jiaxiang
Wang, Rong
Lu, Songtao
Hong, Mingyi
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2510_22594
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle A Framework for Quantifying How Pre-Training and Context Benefit In-Context Learning
Song, Bingqing
Li, Jiaxiang
Wang, Rong
Lu, Songtao
Hong, Mingyi
Artificial Intelligence
Machine Learning
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.
title A Framework for Quantifying How Pre-Training and Context Benefit In-Context Learning
topic Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2510.22594