Apply to my task
arXiv:2610.29331 ★ 78 Oct 21, 2026

Reasoning + Code for Bayesian Updating: How to Get an LLM to Correctly Recompute Probabilities as New Data Arrives

Key result

Finding: without reasoning mode, LLMs produce confident numbers that don't match a correct probability update. The method lets you honestly update hypothesis estimates as new facts arrive (it was 30%, we saw a fact, now it's 55%) and stay on track over 10+ steps. The model only estimates the likelihood of a fact; Python code does the multiplying and normalizing. It stops generating truthy-looking numbers and starts computing by the formula. Precise updates instead of chaotic jumps: one moment it buries a hypothesis after a single fact, the next it ignores strong evidence.

01

TL;DR

The study tests whether an LLM can recompute the probabilities of hypotheses as new data comes in (Bayes' rule: "it was 30% → we saw a fact → now it's 55%"). The verdict: in normal mode, without "thinking," the model gets it wrong. Turn on reasoning mode and give it code execution, and it computes precisely, stays on track over 10+ steps and even approximates probabilities you couldn't compute by hand.

The pain point: the model produces plausible-looking numbers, but they don't match the correct update. Sometimes it "buries" a hypothesis too abruptly after a single fact, sometimes it ignores strong evidence. A separate trap: ask about related events in different chats and the estimates contradict each other (in more than half of cases in most scenarios). In a single conversation, the same estimates are almost always consistent. The reason is simple: the model has no "shared brain" across chats, while within a conversation it sees its own previous answers.

The practical method: keep all estimates in one conversation, turn on reasoning mode and ask it to compute with code, not "eyeball it." State the prior probabilities and the likelihood of the data under each hypothesis explicitly.

Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.

02

Method Blueprint

RULE 1: all related estimates go in ONE conversation (not in new chats)
RULE 2: turn on reasoning mode (thinking / reasoning)
RULE 3: for the math — a code tool (Python), not "in your head"

Update loop (in one prompt or one fact per message):
STEP 1: List of hypotheses + prior probabilities (sum = 100%)
STEP 2: New fact → for each hypothesis: "how likely is it to see this fact if the hypothesis is true"
STEP 3: Code: multiply the prior by the likelihood → normalize to sum to 100%
STEP 4: Show a "before → after" table; the new estimate becomes the prior for the next fact
03

Example in Action

Task: An Amazon seller notices that sales of the "Travel Mug 16 oz" listing dropped 40% in two weeks. There are four hypotheses: the listing slipped in search rankings, a competitor is undercutting on price, the season ended, the reviews got worse. Data arrives one piece at a time: first the ranking export, then competitor prices, then the review trend. The goal is not to flail around, but to honestly recompute what's more likely.

Prompt (reasoning mode on, code allowed):

We're working in a single conversation. Keep all estimates consistent with the previous ones.

<Hypotheses>
H1: the listing dropped in Amazon search rankings
H2: a competitor is undercutting (price 15%+ lower)
H3: the season ended (demand for travel mugs falls after January)
H4: reviews got worse (rating below 4.6)
</Hypotheses>

<Prior>
H1: 30%, H2: 25%, H3: 30%, H4: 15%
</Prior>

<Evidence_1>
Ranking for the main keyword "travel mug": was #12, now #34.
</Evidence_1>

For each hypothesis, estimate the likelihood: how likely it is to see
this ranking drop if the hypothesis is true (a number from 0 to 1) 
and briefly justify it. Then CALCULATE WITH CODE (Python): multiply the prior
probability by the likelihood, normalize so the sum is 100%.
Output a "before → after" table. These numbers become the priors
for the next fact. Don't round until you've finished the calculation.

Result: The model returns a likelihood table with a justification for each hypothesis, then runs the code and shows the recomputed probabilities (summing to exactly 100%). In your next message you feed in the second fact (competitor prices), and the model updates from the numbers it already has, not from the original priors. By the end of the chain you can see which hypothesis gained weight and after which fact.

04

Why It Works

The weakness. Without reasoning, the model "feels" its way to an answer. It doesn't multiply or normalize; it generates plausible numbers. So its update drifts from the mathematically correct one and the error compounds with each new fact. Across different chats it has no shared picture of the world and rates the same set of events differently.

The strength. The model is good at judging qualitative things: "how typical is this fact for this hypothesis." It can also write and run code, and reasoning mode lets it work through the calculation step by step. Within a single conversation it sees its previous answers and keeps them consistent.

How the method exploits this. It splits the work: the model supplies likelihood estimates (what it's good at), and code does the arithmetic (what it's unreliable at "in its head"). A single conversation provides shared memory.

Control knobs: - Reasoning mode → turn it off for simple questions to save money, but keep it on for updating probabilities. - Code instead of "in your head" → drop the code requirement for 2–3 hypotheses you can check by hand. Keep it for 6+ hypotheses or complex dependencies. - Number of hypotheses → in the study the working size was about 8. More than that, split them into groups. - One conversation → don't open a new chat for the next fact. If you have to, paste the previous table into it.

05

Prompt Template

The paper has no ready-made prompt. The template below follows the design of their experiment: the model receives hypotheses, priors and observations and outputs an updated distribution. The calculation is handed off to code.

We're working in a single conversation. All estimates must be consistent
with the previous ones. Use code (Python) for calculations; don't compute in your head.

<Task>{what we're figuring out}</Task>

<Hypotheses>
{H1: ...}
{H2: ...}
{H3: ...}
</Hypotheses>

<Prior>
{H1: X%, H2: Y%, H3: Z%} (sum 100%)
</Prior>

<Evidence_{number}>
{new fact or observation result}
</Evidence_{number}>

<ReasoningLogic>
1. For each hypothesis, estimate the likelihood: how likely it is
   to see this fact if the hypothesis is true (0–1). Briefly justify it.
2. In code: new_estimate = prior × likelihood, then normalize to sum to 100%.
3. Check: sum = 100%, no estimate zeroed out without a strong reason.
4. Output a "before → after" table and one sentence: what moved the estimates.
5. New estimate = prior for the next fact.
</ReasoningLogic>

What to fill in: {what we're figuring out} — the question you're answering. {H1...} — mutually exclusive hypotheses, ideally with an "other" in case you missed something. {X%...} — your starting estimate from experience, or split evenly. {new fact} — one observation at a time.

🚀 Quick start — paste into a chat:

Here is a template for Bayesian updating of estimates. Adapt it to my task: [your task].
Ask me questions to fill in the fields.

[paste the template above]

The LLM will ask what your hypotheses are, what your priors are and what facts you already have. It needs this so the calculation rests on your data, not on something the model made up. It will map the task onto the template fields itself.

06

Limitations

⚠️ "No reasoning" mode hurts: without reasoning mode, models don't make accurate updates in either of the two test environments. A quick "eyeballed" answer gives confident but wrong numbers.

⚠️ Separate chats break consistency: when you ask in different conversations, estimates of related events contradict each other in most scenarios. In a single conversation it's much better, but not perfect.

⚠️ The model still "estimates" the likelihoods: in the test worlds it was given exact probabilities. In real life you ask it to guess "how likely is this fact under this hypothesis," and that part stays subjective. Code guarantees the arithmetic, not the correctness of your starting assumptions.

⚠️ Tested on mid-size open models and one large model with code: the conclusions about code rest on an experiment with a single model (Gemini 2.5 Pro). It's reasonable to expect similar results for Claude and ChatGPT, but the paper didn't test that.

⚠️ Synthetic worlds and a game of 20 questions: the tests are artificial. Transfer to business tasks with noisy data isn't proven.

⚠️ The available excerpt of the paper cuts off midway through the results. The quantitative effect sizes come from the authors' abstract, without tables.

07

How They Tested It

The authors framed the question like this: everyone says LLMs can't honestly update probabilities, so "AI scientists" get rigid scaffolding and fine-tuning. But has anyone actually tested that premise? They tested it along three axes.

Consistency. They took forecasting questions from ForecastBench and built "Dutch books" (a set of bets guaranteed to lose if the estimates violate the axioms of probability). They tested 3 models and 3 types of violations with 10 scenarios each. Result: across separate chats, violations occurred in more than half of the 30 scenarios for almost every model-axiom pair. In a single conversation, violations drop to 10% for Gemini and to 1 scenario out of 30 for Gemma. The authors' conclusion: the problem isn't an inability to compute, it's that there's no shared "store" of beliefs across chats.

Update accuracy. Two environments. In the first, "20 questions" (40 animals, 20 turns each), the reference was the model's own estimates. In the second, ProteinWorld, the authors generated fictional protein "worlds" with made-up names so the model couldn't lean on prior knowledge. There were 5 worlds, 8 classes, 6 experiments, 40 runs in total; the reference was the exact calculation. They compared 5 models with and without reasoning. Without reasoning, all of them failed. With reasoning, the results were much better: the models compute the reference distribution precisely and don't drift from it over 10+ observations. In the "hard" version of the world, where an exact formula isn't available, Gemini 2.5 Pro with Python code approximates the answer well.

The cost of error. The authors compared how well the model ultimately identifies the hidden hypothesis when it makes decisions based on its own estimates, versus a reference Bayesian agent. This showed that inaccurate updates hurt outcomes, not just deviate from theory.

The surprise was that rigid scaffolding and fine-tuning aren't needed: reasoning mode and a code tool are enough. Practical insight: "thinking" and "code" aren't decoration; they're a prerequisite for handling probabilities correctly.

08

Adaptations and Extrapolations

🔧 Technique: add a consistency self-check → catch contradictions before decisions

The idea comes from the "Dutch book" method, but the prompt is mine. Before an important decision, ask for related probabilities in one conversation and check that they add up.

Estimate in a single answer:
A) the probability that we hit the Q3 sales target;
B) the probability that we DON'T hit it;
C) the probability that we reach at least 90% of the target;
D) the probability that we reach at least 100% of the target.
Check with code: A + B = 100%? C ≥ D? If not, fix the estimates and explain what you corrected.

The effect: complementary probabilities must sum to 100%, and "≥90% of target" can't be less likely than "≥100% of target." Violations of these rules are exactly what the paper treats as a sign of bad estimates.

Extrapolation: updating with a "red team"

This combination isn't from the paper; test it yourself.

After the "before → after" table, take on the role of a skeptic: find the fact that
could change the estimates the most, and say at what likelihood value 
the leading hypothesis would lose first place. Recompute with code under that scenario.
09

Resources

  • From Prompts to Posteriors: Can LLM Agents Perform Bayesian Inference in Context?
  • Authors: Linus Filbry, Luckeciano C. Melo, Yarin Gal (OATML, University of Oxford)
  • Key references: Choudhury et al. (2026) — the "20 questions" protocol; ForecastBench (Karger et al., 2025); ProteinWorld — the authors' own environment

Research digest

Key result

Finding: without reasoning mode, LLMs produce confident numbers that don't match a correct probability update. The method lets you honestly update hypothesis estimates as new facts arrive (it was 30%, we saw a fact, now it's 55%) and stay on track over 10+ steps. The model only estimates the likelihood of a fact; Python code does the multiplying and normalizing. It stops generating truthy-looking numbers and starts computing by the formula. Precise updates instead of chaotic jumps: one moment it buries a hypothesis after a single fact, the next it ignores strong evidence.

Principle

The work splits into three parts, like an assembly line. 1. You set the hypotheses and starting probabilities (sum 100%). 2. The model answers, for each hypothesis: how likely is it to see this fact if the hypothesis is true (a number from 0 to 1). 3. Code multiplies the starting probability by that number and brings the sum back to 100%. The new estimate becomes the starting point for the next fact. All steps happen in one conversation. Who does what follows from their strengths. The model is good at judging whether a fact is typical for a hypothesis. It's bad at arithmetic in its head. Leave the judgment to the model and hand the arithmetic to code. Like an accountant and a calculator: the accountant decides what goes where, and the calculator does the math.

Why it works

Without reasoning, the model doesn't multiply or normalize. It "feels" the answer and writes plausible numbers. With each new fact, the deviation from the right figure piles up. The authors checked this in two test environments: without reasoning mode there were no accurate updates in either. There's a second trap too. Ask about related events in different chats and the estimates contradict each other, in most scenarios. The model has no shared picture of the world across chats. Within one conversation it sees its own previous answers, so the estimates are almost always consistent. With reasoning mode and code execution, the model computes precisely and stays on track over 10+ steps. It even approximates probabilities you couldn't compute by hand.

When to apply

Root-cause analysis and diagnostics → when you have 3-8 mutually exclusive hypotheses and facts arrive one at a time. For example: why sales dropped, where a system error came from, which version of events is more likely. Especially useful with 6 or more hypotheses, or when they depend on each other. At that point you can't check it by hand. NOT needed when there are 2-3 hypotheses and you can easily check the math yourself. Then you can skip the code. And don't expect miracles from noisy business data: the model still estimates likelihoods subjectively. Code guarantees the arithmetic, not the correctness of your assumptions.

Mini recipe

1. Turn on reasoning mode and allow code execution. Without this the method doesn't work. 2. Open one conversation and stay in it. A new chat for the next fact breaks consistency. If you have to, paste the previous table into it. 3. Set the hypotheses: up to 8, mutually exclusive. Add an "other" item in case you missed something. 4. Give starting probabilities: from experience or split evenly. Sum 100%. 5. Feed facts one at a time. One fact, one message. 6. Require the calculation in code: `Estimate a likelihood from 0-1 for each hypothesis and briefly justify it. Then CALCULATE WITH CODE: multiply by the prior, normalize to 100%. Don't round until the calculation is done.` 7. Check the table: sum exactly 100%, no hypothesis zeroed out without a strong reason. 8. Carry the result forward: the new estimate becomes the starting point for the next fact.

Examples

[BAD]: `Travel mug sales dropped 40%. The search ranking was #12, now it's #34. Which cause is more likely?` [GOOD]: `We're working in a single conversation. Keep estimates consistent with the previous ones. Hypotheses: H1 search ranking dropped, H2 a competitor is undercutting (price 15%+ lower), H3 the season ended, H4 reviews got worse (rating below 4.6). Priors: H1 30%, H2 25%, H3 30%, H4 15%. Fact 1: for the keyword "travel mug" the ranking was #12, now #34. For each hypothesis, estimate the likelihood: how likely this fact is if the hypothesis is true (from 0 to 1), and briefly justify it. Then CALCULATE WITH CODE in Python: multiply the prior by the likelihood, normalize to 100%. Output a "before → after" table. These numbers become the priors for the next fact.` Next message: `Fact 2: a competitor cut their price by 18% ten days ago. Update the estimates from the latest table.` As the chain goes on, you can see which hypothesis gained weight and after which fact.

In plain words

When it comes to math, a regular language model is like a tipsy English major. Ask it to update probabilities using Bayes' theorem (it was 30%, a new fact came in — what is it now?) and it doesn't calculate anything at all. The model just guesses a number that sounds convincing in the context of the conversation. Instead of objective analysis you get a pretty hallucination, with the error snowballing with every new fact.

It's like the detective in a cheesy TV show who finds a cigarette butt and immediately yells, "It was the butler!" He ignores alibis, doesn't connect the clues and just goes with his gut. In standard chat mode the model behaves exactly the same: it doesn't update prior probabilities, it bounces chaotically between theories and draws polar-opposite conclusions from the same inputs.

The cure for this dumbness is a combo of two things: reasoning mode and code execution. When the model is banned from answering off the cuff and handed a Python interpreter, magic happens. It stops "feeling" probabilities in its gut, honestly normalizes the distributions and keeps its mathematical rigor over 10 or more steps, producing exact numbers even where a human would get buried in formulas.

The study walked through a marketplace seller with a 40% revenue drop, but the principle is universal. The same setup is vital for hunting server bugs, assessing risk or scoring customers. Anywhere data arrives in batches — first the traffic chart, then the error logs, then user reviews — an agent without Bayesian updating will just blow the budget on false hypotheses.

The moral is simple: never ask a bare model to assess risk with questions like "how likely is this". Without code execution tools and step-by-step reasoning, it'll give you a random forecast with a straight face. If you're building autonomous agents for real business, hook the model up to code and make it compute probabilities strictly by the formulas.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on Reasoning + Code for Bayesian Updating: How to Get an LLM to Correctly Recompute Probabilities as New Data Arrives arXiv:2610.29331

Sign in to apply this study New accounts get 50 free credits.