Tree of Thoughts Prompting: Branch, Judge, Then Commit
What tree of thoughts (ToT) is, how it differs from chain of thought, when it's worth the extra calls, and copy-ready prompts to run it in one message or as a step-by-step search.

Ask a model a hard question and it commits to the first idea it writes down. Every sentence after that builds on the opening move, good or bad. If the first step was wrong, the answer is wrong, however careful the reasoning looks.
Tree of thoughts prompting fixes that by making the model behave more like a person solving a puzzle: sketch a few possible approaches, judge which look promising, drop the dead ends and only then go deeper. This guide explains where the idea comes from, when it's worth the extra effort and how to use it in ChatGPT, Claude or Gemini, from a single prompt to a proper step-by-step search.
What tree of thoughts prompting is
Tree of Thoughts (ToT) was introduced in a May 2023 paper by Shunyu Yao and colleagues at Princeton University and Google DeepMind. Their starting point: language models generate text left to right, one token at a time, so they struggle with tasks where "exploration, strategic lookahead" or an early decision matters.
The framework breaks a problem into thoughts, short coherent chunks of text that each move the solution one step forward: an equation, a paragraph plan, a candidate answer to one clue. At each step the model does three things:
- Generate: propose several possible next thoughts instead of one.
- Evaluate: judge each candidate, for example as "sure", "maybe" or "impossible".
- Search: keep the most promising candidates, expand them, and backtrack when a branch turns out to be a dead end.
The result is a tree rather than a line. The headline result comes from the Game of 24, a maths puzzle where you combine four numbers with +, −, × and ÷ to reach 24. GPT-4 with chain-of-thought prompting solved 4% of the puzzles; with Tree of Thoughts it solved 74%. The paper also tested creative writing and mini crosswords, with smaller but clear gains.
Two things to keep in mind from the start. The original method runs as code, making many separate calls to the model. And the gains are task-specific: a jump on one maths puzzle says little about your project plans.
Tree of thoughts vs chain of thought
If you've used chain-of-thought prompting, you already know half the idea. The difference is the shape of the reasoning.
- Chain of thought: one line of reasoning, step by step, to one answer. Cheap and often enough, but it never questions its first step.
- Self-consistency: several independent chains for the same question, then a majority vote on the final answer (Wang et al., 2022). More reliable, but the chains don't help each other and nothing gets judged halfway.
- Tree of thoughts: several options at each step, judged before the model goes further. Bad branches are cut early and the model can go back to an earlier step.
A simple way to remember it: chain of thought is one person thinking aloud; self-consistency is ten people working alone and voting; tree of thoughts is a small team comparing drafts after every step.
The cost follows the same order. Chain of thought adds a few sentences. A full tree can mean dozens of model calls for one problem, so it pays only when a wrong first move is expensive.
When a tree is worth the effort
Most everyday prompts don't need it. A summary, an email or a factual question has no real branching point. ToT helps when a problem has these features:
- Several plausible starting points, and choosing badly early is hard to undo: a project plan, an architecture choice, a negotiation strategy.
- Partial progress you can judge: you can tell whether an intermediate step is promising before you see the final answer.
- Hard constraints that rule options out: a budget, a deadline, a word limit, a timetable that has to fit.
- Search-like puzzles: scheduling, allocation, crosswords, maths puzzles with many combinations.
It's the wrong tool for facts the model either knows or doesn't (branching won't create knowledge), for short writing tasks and for anything where a quick first draft you can edit is good enough. If a couple of good examples already gets you there, start with that.
The one-prompt version: a panel of experts
In 2023, developer Dave Hulbert squeezed the idea into a single prompt. Instead of code that runs a search, the model imagines several experts who reason in parallel and drop out when they spot their own mistake. His version, slightly adapted:
It's a useful upgrade on "think step by step" for logic questions and tricky word problems. But it is a role-play of a search, not a real one: the model writes all three experts in one pass, so it can still talk itself into a wrong answer. You get better results by making the generate, evaluate and choose steps explicit:
"Genuinely different" matters: without it, models offer three versions of the same plan with different wording. Asking why the losers lost also gives you something to check. Clear role prompting helps too: experts with named, different viewpoints (a finance lead, an operations lead, a sceptical customer) produce more distinct branches than three anonymous experts.
Running a real tree across several messages
The single prompt is quick, but the model grades its own ideas while still writing them. Splitting the steps into separate messages gives you something much closer to the original method, and you become the search algorithm. It's a form of prompt chaining with a loop in it.
Step 1: generate branches. Ask only for options, with no evaluation yet.
Step 2: evaluate them, ideally in a new chat, so the model judges the options without defending ideas it has just written.
Step 3: expand and backtrack. Take the surviving branches back to the first chat and go one level deeper.
Repeat until a branch reaches a full solution or every branch is dead. In practice two or three levels are enough for most business problems; the paper's puzzles needed more because each step was tiny. Keep a short log of the dead ends, because the reasons they died are often the most useful part of the exercise.
A worked example: growing a bakery without new staff
Here's what the loop looks like on a realistic problem. A small bakery wants 15% more monthly revenue within six months, with no new staff and the same oven.
Generate. The model proposes four strategies: longer opening hours, wholesale bread for local cafés, a pre-order weekend box, and price rises on the best sellers.
Evaluate. In a fresh chat, with the constraints listed, longer hours comes back "impossible": it needs staff the bakery doesn't have. Wholesale is "maybe": it uses spare early-morning oven time, but margins are thin. The pre-order box is "sure": it uses existing products and lets the bakery bake to order. Price rises are "maybe": quick, but risky on their own.
Expand. The model develops the box and wholesale one level further. Wholesale hits a wall when it checks delivery: nobody is free to drive at 7 am. So the tree backtracks, and the final plan combines the pre-order box with a small price rise on two items.
A single chain-of-thought answer would very likely have started with longer hours, the most obvious idea, and spent its whole answer making it work. The tree spotted the staffing problem before any detailed planning. That's the real value: cheap early judgement on several options, not a smarter model.
Automating the search in code
If you work with the API, you can run the tree without copying and pasting. The original implementation does exactly this:
- A proposal prompt asks for candidate next thoughts.
- A value prompt scores each candidate. In the Game of 24, the model judged whether the remaining numbers could still reach 24, and each value was sampled three times.
- A search strategy decides what to keep: breadth-first search keeps the best few candidates at every level (five in the Game of 24), depth-first search follows one branch until it fails and then backtracks.
A parallel 2023 paper by Jieyi Long used a similar tree but let a controller trained with reinforcement learning decide when to backtrack. For most teams, a simple breadth-first loop with a strict value prompt is the place to start.
Watch the bill. Every node is at least one call, and evaluation calls multiply fast: three levels, five branches and three evaluations each already means dozens of requests. Measure your prompt sizes with a token counter before running a tree over hundreds of problems.
Limits worth knowing
Tree of thoughts is a useful pattern, not a guarantee. Be honest about what it can't do.
- The evaluator is the same model: it has the same blind spots as the generator, and models tend to rate their own ideas generously. A separate chat, strict criteria and a "be critical" instruction help, but they don't make the judge independent.
- It can't add knowledge: if no branch contains the right fact, comparing branches won't find it. Check facts against sources.
- It costs time and tokens: a full tree can take ten times longer than a direct answer. For most daily tasks, a good single prompt wins.
- The one-prompt version is a simulation: it often helps, but the model isn't really exploring and pruning; it's writing text that looks like it is.
- Reasoning models narrow the gap: models that think at length before answering already do some exploring and self-checking internally, so a hand-built tree adds less on top. It still helps when you want to see and steer the options yourself.
- The results are from puzzles: the 4% vs 74% figure is one task with one model in 2023. Test it on your own problems before assuming the same jump.
Used where it fits, tree of thoughts prompting turns "give me the answer" into "show me the options, kill the weak ones, then go deep". Try the explicit one-prompt version on your next decision with real constraints, and if you want more techniques in the same family, our guide to advanced prompt engineering is the natural next step.



