Enough Coin Flips Can Make LLMs Act Bayesian

ACL 2025

Berkeley AI Research, UC Berkeley

When LLMs are prompted to flip a biased coin (P(heads) = 60%), they are unable to do so without being shown examples of flips from that distribution. As the amount of biased coin flips shown to the LLM via in-context learning (ICL) increases, the LLMs converge to the true distribution in a manner consistent with Bayesian updating. In this case, the true Bayesian update converges to θ=0.70 which all LLMs also eventually converge to.

Abstract

Large language models (LLMs) exhibit the ability to generalize given few-shot examples in their input prompt, an emergent capability known as in-context learning (ICL). We investigate whether LLMs utilize ICL to perform structured reasoning in ways that are consistent with a Bayesian framework or rely on pattern matching. Using a controlled setting of biased coin flips, we find that: (1) LLMs often possess biased priors, causing initial divergence in zero-shot settings, (2) in-context evidence outweighs explicit bias instructions, (3) LLMs broadly follow Bayesian posterior updates, with deviations primarily due to miscalibrated priors rather than flawed updates, and (4) attention magnitude has negligible effect on Bayesian inference. With sufficient demonstrations of biased coin flips via ICL, LLMs update their priors in a Bayesian manner.

Interactive Coin Flip ICL Visualization

BibTeX

@misc{gupta-corona-ge-coinflips2025,
        Author = {Ritwik Gupta and Rodolfo Corona and Jiaxin Ge and Eric Wang and Dan Klein and Trevor Darrell and David M. Chan},
        Title = {Enough Coin Flips Can Make LLMs Act Bayesian},
        Year = {2025},
        Eprint = {arXiv:2503.04722},
        }