cs.CC — Computational Complexity
The Price of Bayes-Optimal In-Context Learning
In-context learning is often explained as implicit Bayesian inference: given labeled examples of a task drawn from a prior, the learner predicts like the posterior. We determine the computational price of this explanation for task families whose labels depend on few bits of the task description, such as quantized models on sparse data, and we compare it with the price of merely learning. The comparison uses the recent refutations of the Exponential Time Hypothesis by OpenAI and Anthropic. Bayesian inference in context is counting. For -local task families with -bit descriptions under the uniform prior, the posterior predictive and posterior sampling reduce to -SAT. Without label noise they run in time on contexts of every length when , and label noise is handled by error profiles. A two-variable gadget gives contexts that are always consistent and whose posterior predictive is for a CNF . So approximating the posterior predictive within needs time at locality under CNF-SETH, and time at locality under a length form of ETH. At constant locality, Bayesian inference in context is SAT parameterized by formula length. Learning in context is cheap. The Bayes risk of any class with -bit descriptions is at most after examples. For binarized perceptrons and literal disjunctions on sparse data, the very families of the lower bounds, a linear program is a polynomial-time in-context learner with essentially the same sample efficiency. Every -local family is linear over local Fourier features, so regression in context learns it from examples, in time polynomial in and the inverse accuracy. The average case. For Goldreich's random local functions, the Bayes risk is at most , while every in-context learner yields a distinguisher for Goldreich's generator, with the same running time up to a linear term, whose advantage is minus the risk. Under a local pseudorandom generator hypothesis with polynomial stretch, polynomial-time in-context learners need polynomially more examples than the Bayes predictor. Under its length form at linear stretch, which the new algorithms refute below rate , the Bayes predictor of the refutations is optimal up to polylogarithmic factors in the exponent. For transformers, these bounds limit the length of a chain of thought that computes the posterior predictive, and they separate Bayes-optimal in-context learning from the regression-type in-context learning that transformers are known to implement.