Preprint
Large Language Models

An explanation of in-context learning as implicit bayesian inference

January 1, 2111

0

Citations

0

Influential Citations

Venue

2111

Year

Abstract

… what enables in-context learning. In this paper, we study how in-context learning can emerge … At test time, in-context learning occurs when the LM also infers a shared latent concept …

Analysis

Why This Paper Matters

In-context learning (ICL) is one of the most striking capabilities of large language models (LLMs), enabling them to perform new tasks from just a few examples without gradient updates. Despite its practical importance, a rigorous theoretical understanding of why ICL works has been lacking. This paper addresses that gap by proposing that ICL can be understood as a form of implicit Bayesian inference. By framing the problem as the model inferring a shared latent concept from the provided context, the authors offer a principled explanation that connects ICL to well-studied Bayesian reasoning frameworks.

The significance of this work lies in its potential to demystify a key emergent behavior of LLMs. If ICL is indeed Bayesian inference, then many properties of Bayesian models—such as uncertainty quantification, prior sensitivity, and the ability to incorporate new evidence—may apply to LLMs as well. This could lead to more predictable and controllable few-shot behavior, and inform strategies for prompt engineering and model selection.

Technical Contributions

The paper's main innovation is a formal model where in-context learning is treated as posterior inference over a latent variable that represents the task or concept. Key technical points include:

  • Latent variable formulation: The model assumes that each task is characterized by a latent concept, and the LM's pretraining distribution implicitly defines a prior over these concepts.
  • Implicit inference: At test time, the LM uses the context (input-output pairs) to update its belief about the latent concept, effectively performing Bayesian updating without explicit probability calculations.
  • Emergence from pretraining: The authors argue that this inference capability emerges naturally from the pretraining objective, which encourages the model to capture the statistical structure of the data, including latent variables.

Results

The paper is primarily theoretical and does not present experimental results or quantitative metrics. Instead, it provides a conceptual framework that aligns with known empirical phenomena: the ability of LLMs to adapt to new tasks from few examples, the sensitivity to the order and content of examples, and the occasional failure modes when the context is misleading. The analysis suggests that ICL should exhibit properties like Bayesian consistency and sensitivity to prior information, which could be tested in future work.

Significance

This work has the potential to reshape how researchers and practitioners think about in-context learning. By grounding ICL in Bayesian inference, it opens the door to applying Bayesian techniques—such as posterior calibration, prior elicitation, and model comparison—to LLMs. For AI practitioners, understanding ICL as Bayesian inference could lead to more principled prompt design, better handling of ambiguous or conflicting examples, and improved few-shot performance. The paper also provides a foundation for future research into the limits and failure modes of ICL, such as when the model's implicit prior is mismatched with the actual task distribution.