From Prompts to Posteriors: Can LLM Agents Perform Bayesian Inference in Context?
Organizations: OATML, University of Oxford
Abstract
Large language models (LLMs) are increasingly applied across the scientific discovery pipeline, from synthesizing literature to generating hypotheses to informing experimental design. A unifying principle behind these tasks is the need to continuously update beliefs as evidence accumulates, for which Bayesian inference provides a natural framework. However, existing work assumes that LLMs cannot carry out principled Bayesian belief updating in context, instead relying on simplifications and heuristics. To challenge this assumption, we present a principled evaluation of Bayesian reasoning capabilities in LLMs, analyzing both the model's internal consistency as well as its ability to recover an externally determined posterior. Specifically, we build an evaluation framework spanning qualitative epistemological examples to probe probabilistic coherence, quantitative benchmarks of Bayesian inference capabilities, and analyses of the impact of non-Bayesian updates on downstream task performance. Across different scenarios, we find that LLMs generally violate Bayes' rule when updating their beliefs in context. However, when equipped with modern reasoning abilities and code execution capabilities, their performance drastically improves, enabling even the close approximation of analytically intractable posteriors. Our evaluation shows that current LLMs with access to appropriate tools could already be used to make complex belief updates in scientific discovery, enabling rapid acceleration of the efficiency and scale of AI-powered scientific discovery.
Figures & tables
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Difficulty | Capabilities | Model | Dominant behavior |
|---|---|---|---|
| simple | — | Gemma-4-31B-it | Correct posterior mode, miscalibrated mass |
| simple | reasoning | Gemma-4-31B-it | Exact closed-form posterior; heavy redundant re-verification |
| hard | reasoning | Gemini-2.5-Pro | Correct model and correct diagnosis of intractability; hallucinated Monte Carlo output |
| hard | reasoning † | Gemini-2.5-Pro | Analytic approximation with numerical over-simplification |
| hard | reasoning + code | Gemini-2.5-Pro | Correct model, correct Monte Carlo implementation, oracle-level posterior |
| Gemma-4-31B-it | |||
|---|---|---|---|
| Hypothesis | no reasoning | reasoning | Oracle |
| Xylocorein | |||
| Thalassogen | |||
| Nebulase | |||
| Cryovitin | |||
| Gemini-2.5-Pro | ||||
|---|---|---|---|---|
| Hypothesis | reasoning | reasoning † | reasoning + code | Oracle |
| Chronocortin | ||||
| Glycorectin | ||||
| Luminase | ||||
| Somatoplexin | ||||
| Violation | LLM | Prompt A | Prompt B | ||
|---|---|---|---|---|---|
| Normalization | Gemini-2.5-Pro (reasoning: low) | Will a Democrat win the 2028 US presidential election? | 50% | Will a candidate who is NOT a Democrat win the 2028 US presidential election? | 55% |
| Monotonicity | Gemini-2.5-Pro (reasoning: low) | Will Russia control at least 70% of Donbass at the end of October 2026? | 60% | Will Russia control at least 75% of Donbass at the end of October 2026? | 80% |
| Extensionality | Gemini-2.5-Pro (reasoning: low) | Will there be at least 1,000 deaths due to direct conflict between India and Pakistan before 2027? | 3% | Will the death toll from direct conflict between India and Pakistan reach four figures before 2027? | 10% |
| Normalization | Gemini-2.5-Pro (reasoning: low) | Will the People’s Republic of China blockade or quarantine Taiwan before September 1, 2026? | 35% | Will the People’s Republic of China NOT blockade or quarantine Taiwan before September 1, 2026? | 88% |
| Monotonicity | Gemini-2.5-Pro (reasoning: low) | Will Nvidia’s stock price close below $150 on any day in 2026? | 80% | Will Nvidia’s stock price close below $140 on any day in 2026? | 90% |
Belief Updating in LLMs
Belief updating in large language models studies how models revise, retain, and use beliefs as evidence and context change.
See all 94 papers