The Price of Choosing Examples: Context Overfitting in Adaptive In-Context Learning
Xiaoyu Li, Jiangxuan Long
NeurIPS page · Open on the map
Category: Interpretability & Model Adaptation › Predictive State Estimation in Context · Type: theory · Keywords: in-context learning, context capacity, adaptive data analysis, generalization bounds, PAC-Bayesian retrieval, Bayesian linear in-context regression
Areas: Long Context › Long-context mechanisms › In-context learning
Summary
The paper formalizes adaptive example selection in in-context learning, introduces context capacity as a measure of dependence between data and prompts, and proves finite-sample generalization bounds and PAC-Bayesian retrieval rules, separating context quality from certification.
Explained to a 5-year-old
When we ask a big computer program to learn from examples, we usually think the examples are chosen before we pick the program. But in real life, the examples are picked after we see the question and the data. This can cause the program to overfit to the examples, making it less reliable. We created a new way to measure how much the examples depend on the data, called context capacity. Using this, we proved that if the example selection is stable, longer contexts help, otherwise they can hurt. This helps us build safer computer programs that use examples wisely.
Explained to a 5-year-old, longer
Imagine a computer that learns from examples like a student. Usually we think the examples are picked before we choose the computer’s learning rule. In real systems, the examples are chosen after we see the question and the data. This can make the computer memorize the examples too much, which is called overfitting. Overfitting means the computer works poorly on new, unseen problems. We introduced a measure called context capacity that tells us how much the examples depend on the data. This measure helps us understand how stable the example selection is. If the selection is stable, using more examples can improve performance. If it is unstable, more examples can actually make things worse. We proved a mathematical bound that captures this behavior. The bound shows the risk decreases like the square root of the capacity divided by the number of examples. We also derived two simple rules for picking examples, like a first-order rule and a second-order rule. These rules help the computer choose examples in a safer way. Finally, we applied our theory to a simple learning setting called Bayesian linear in-context regression. The results give guidance for designing reliable prompting systems in real applications.
For a technical reader
We model prompt construction as adaptive data analysis using a conditional stochastic-kernel calculus and quantify the dependence between the data store and the final prompt via context capacity. For any frozen learner and adaptive pipeline with capacity κ, we prove a finite-sample generalization bound of order √(κ/k) and strengthen it to a sub-gamma transport inequality with Bernstein curvature, providing a matching lower bound. Two PAC-Bayesian retrieval rules (first-order Gibbs and self-normalized second-order) are derived, and the theory is instantiated for Bayesian linear in-context regression, illustrating how stable example selection is crucial for leveraging longer contexts.
Problem
In-context learning analyses typically assume prompt examples are sampled before the learner is chosen, but deployed systems adaptively retrieve, filter, and edit examples after seeing the query and data store, leading to potential context overfitting. This gap between analysis and practice needs a formal treatment of how adaptive example selection affects generalization.
Method
The approach treats prompt construction as adaptive data analysis using a conditional stochastic-kernel calculus, defines context capacity as the mutual information between data store and final prompt, proves a finite-sample generalization bound of order √(κ/k), derives sub-gamma transport inequalities and matching lower bounds, and proposes PAC-Bayesian retrieval rules (first-order Gibbs and self-normalized second-order) with an instantiation for Bayesian linear in-context regression.
Results
The approach establishes a finite-sample context generalization bound of order √(κ/k), a sub-gamma transport inequality with Bernstein curvature, a matching lower bound, and two PAC-Bayesian retrieval rules, with an instantiation for Bayesian linear in-context regression.
Contributions
A formal framework for adaptive context selection via stochastic-kernel calculus, the definition of context capacity, finite-sample generalization bounds with matching lower bounds, PAC-Bayesian retrieval rules, and an instantiation for Bayesian linear in-context regression that separates context quality from certification.
Limitations and assumptions
The analysis assumes a frozen in-context learner and that the adaptive pipeline’s capacity κ can be measured; the instantiation focuses on Bayesian linear in-context regression.
Practical relevance
The results guide the design of more reliable retrieval and prompting pipelines by clarifying when longer or more relevant contexts actually improve performance.
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction