All posts

Tree of Thoughts

/AI/4 min read

Chain-of-thought commits to one line of reasoning; Tree of Thoughts explores several and keeps the best. A three-step problem solved 21.6% of the time in one chain becomes 97.0% with five candidates per step and a perfect judge — and 49.6% with a judge that is right 80% of the time.

Chain-of-thought prompting asks a model to reason step by step before answering. It helps a great deal, but it has a structural weakness: the chain is written once, left to right. If step two goes wrong, every step after it builds on the mistake. There is no going back.

Tree of Thoughts treats reasoning as a search instead. At each step the model proposes several possible next thoughts, evaluates them, keeps the promising ones, and expands those further. Dead ends are abandoned. The answer is the best path found through the tree.

The parts

A Tree of Thoughts system needs four decisions:

  1. What a "thought" is. A unit of progress small enough to evaluate — one equation in a maths puzzle, one line of a plan, one paragraph outline.
  2. How to generate candidates. Sample b different next thoughts from the current state, or ask the model to propose b options in one call.
  3. How to evaluate them. Ask the model to rate each partial solution — "sure / likely / impossible" — or to vote on which is most promising. Sometimes a program can check directly.
  4. How to search. Breadth-first, keeping the best k states at each level (a beam), or depth-first with backtracking when a branch is judged hopeless.

Why it helps: the arithmetic

Suppose a problem needs three steps and the model gets each step right with probability 0.6 when it writes one attempt.

One chain: all three must be right. 0.6³ = 21.6%.

A tree with 5 candidates per step: the chance at least one of five candidates is right is 1 − 0.4⁵ = 98.98%. If the evaluator always recognises the right one, three steps succeed with probability 0.9898³ = 97.0%.

That is the promise: generate several options at each step, and the search almost always contains a correct path even when any single attempt usually fails.

The catch: the judge

But the evaluator is the same model, and it is not perfect. If it picks the correct candidate — when one exists — with probability e:

judge accuracyper stepthree steps
perfect0.99097.0%
0.90.89170.7%
0.80.79249.6%
0.70.69333.3%

With an 80%-accurate judge, the tree solves the problem about half the time — still more than double the single chain, but nowhere near 97%. The generation side is almost never the bottleneck; recognising the good branch is. Tree of Thoughts works best where evaluation is easier than generation, or where a program can verify partial answers outright.

PROPOSE, JUDGE, PRUNE, REPEAT answer 5 per step judge keeps best one chain: 21.6% · tree + perfect judge: 97.0% · tree + 80% judge: 49.6% the good branch is nearly always generated; the question is whether it is chosen
Search turns a weak generator into a strong one only if the evaluator is strong.

What it costs

A beam search keeping k = 5 states, generating b = 5 candidates from each, over d = 3 levels, makes:

  • 3 × 5 × 5 = 75 generation calls
  • 75 evaluation calls

150 model calls where chain-of-thought made one. Batching and asking for several candidates in one call reduce this, but Tree of Thoughts is fundamentally a way of spending much more inference compute for better answers on hard problems.

The original paper's showcase was the Game of 24 — combine four numbers with arithmetic to make 24 — where GPT-4 with chain-of-thought solved 4% of puzzles and with Tree of Thoughts 74%. That task is close to ideal: each step is one equation, partial states are easy to judge ("can 10 and 14 still make 24? yes"), and errors early are fatal to a single chain.

Where it fits now

Reasoning models trained with reinforcement learning do a version of this internally: they explore, notice mistakes and backtrack within one long chain of thought, without an external search harness. For many problems that has replaced explicit Tree of Thoughts.

The explicit version is still useful when:

  • a program can verify partial work — tests for code, a checker for a puzzle, a solver for constraints;
  • the search should be inspectable — every branch and every judgement is logged;
  • you want to control the budget — width and depth are parameters, not something the model decides.

What to take away

Tree of Thoughts turns reasoning into search: propose several next steps, judge them, keep the best, repeat. Generating five candidates per step makes it very likely the right path exists — 97% versus 21.6% for a single chain on a three-step problem with a perfect judge.

The judge is the limit. At 80% accuracy the same tree solves about half the problems, at roughly 150 calls instead of one. Use it where evaluating a step is much easier than producing it, ideally with a program doing the checking.