HackerPapers

arXiv:2111.02080cs.CL

An Explanation of In-context Learning as Implicit Bayesian Inference

Sang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu Ma

Early discovery. Linked by one identifiable commenter. This paper is outside the main ranking; a mention is not an endorsement.

Abstract

Large language models (LMs) such as GPT-3 have the surprising ability to do in-context learning, where the model learns to do a downstream task simply by conditioning on a prompt consisting of input-output examples. The LM learns from these examples without being explicitly pretrained to learn. Thus, it is unclear what enables in-context learning. In this paper, we study how in-context learning can emerge when pretraining documents have long-range coherence. Here, the LM must infer a latent document-level concept to generate coherent next tokens during pretraining. At test time, in-context learning occurs when the LM also infers a shared latent concept between examples in a prompt. We prove when this occurs despite a distribution mismatch between prompts and pretraining data in a setting where the pretraining distribution is a mixture of HMMs. In contrast to messy large-scale datasets used to train LMs capable of in-context learning, we generate a small-scale synthetic dataset (GINC) where Transformers and LSTMs both exhibit in-context learning. Beyond the theory, experiments on GINC exhibit large-scale real-world phenomena including improved in-context performance with model scaling (despite the same pretraining loss), sensitivity to example order, and instances where zero-shot is better than few-shot in-context learning.

arXiv comments
ICLR 2022
Journal reference
DOI
Subjects
cs.CLComputation and Language cs.LGMachine Learning

On Hacker News

Linked by 1 identifiable commenter in 1 comment across 1 thread, from Aug 2023 to Aug 2023. Found in 1 HN submission from Feb 2026 to Feb 2026. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments1 thread

    • Examples from a quick search: What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalization, https://arxiv.org/abs/2305.19420 An Explanation of In-context Learning as Implicit Bayesian Inference, https://arxiv.org/abs/2111.02080 A…

      naaskingView on HNParent context

Submitted to Hacker News

  • Ask HN: Vibe Studying?

    I was reading the papers listed at https://www.cs.princeton.edu/courses/archive/fall22/cos597G/ to learn about LLMs. My background’s in physics, not ml/cs, so while I able to understand the mathematics for the most part, I was getting hung up on the jargon at times. I found myself repeatedly taking screenshots of a page and uploading it on gemini, asking it to simplify the language. Doing that so many times manually sucks for more than one reason, so I ended up writing something which does that…

Connected through shared HN threads, not inferred similarity or a recommendation.