Foundations to Frontier
Tests
F. NLP and Large Language Models › F12 Reasoning Models

Search over reasoning: tree of thoughts and MCTS

A chain of thought commits to each step as it is written. Search treats reasoning as a tree instead: propose several next steps, evaluate partial solutions, keep the promising ones, and back up from dead ends. Tree of thoughts (ToT) does this with the language model proposing and evaluating 'thoughts'; Monte Carlo tree search (MCTS) balances exploring new branches with exploiting good ones using rollouts and value estimates. In the exercises you write beam search, pruned depth-first search and the UCT selection rule. You then solve 200 Game-of-24 puzzles with a simulated model whose proposed step keeps the puzzle solvable 35% of the time beyond chance, and whose self-evaluation is wrong 15% of the time. A single chain solved 9%, and up to ten chains checked at the end solved 67%. Breadth-first ToT with a beam of 5 solved 92% using 85 model calls, and depth-first ToT with backtracking solved 87% using 17. With a poor evaluator (45% errors) the beam-5 search fell to 67%.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Exploring a maze instead of walking straight

Solving a puzzle in one go is like walking through a maze without ever turning back. Searching means trying a few directions, judging which look promising, and backing up from dead ends. Tree-of-thoughts methods let a language model do this: it proposes several next steps, rates how promising each partial solution looks, and continues from the best. The demo shows how keeping several candidates and a reliable judge of progress turn a weak step-by-step solver into a strong one.

Reasoning lab
Greedy chain: 43%; beam search with width 4 and a 80%-accurate step scorer: 85%. Search helps only as much as the scorer can tell good steps from bad.
Why engineers care

Search over reasoning steps is how game-playing systems like AlphaGo got superhuman; reasoning models apply related ideas to maths, code and planning.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Tree of thoughts treats reasoning as…
  2. 2. Backtracking means…
  3. 3. Search needs a way to…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Thoughts: coherent intermediate steps (an equation, a plan step, a paragraph) that the model proposes.
  • Proposal: sample k next thoughts, or ask for k distinct options in one call.
  • Evaluation: the model rates each state (‘sure / likely / impossible’), votes across states, or a trained value model or PRM scores it (F12-2).
  • Search algorithms: BFS / beam search (keep the best b per level), DFS with pruning and backtracking, MCTS (select by UCT, expand, roll out or evaluate, back up).
  • Results: ToT solved 74% of Game-of-24 puzzles with GPT-4 vs 4% for chain of thought (Yao et al., 2023); MCTS-style search powers systems like AlphaProof and rStar-Math.
  • Costs: many model calls per problem; search quality is bounded by the evaluator.
  • Relation to RL: search produces better trajectories that can be distilled back into the policy (expert iteration).
📝 Quick check (Level 1)
0/3 answered
  1. 1. MCTS selects children by…
  2. 2. ToT on Game of 24 reached…
  3. 3. Search quality is bounded by…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Exercise 1.

  • Generic beam search.
  • Depth-first search with pruning and a budget.
  • The UCT selection score.

Practice.

  • Libraries: the original tree-of-thought code, LLM Reasoners, LangGraph for custom loops; or a few dozen lines around an API.
  • Use exact checkers where they exist (arithmetic, unit tests, constraint solvers) instead of model self-evaluation.
  • Cache states; deduplicate equivalent states.
  • Budget calls per problem; prefer DFS when evaluation is reliable, beams when it is noisy.
  • Log the explored tree to see where search fails.
def solve(problem, k=5, beam=5):
    frontier = [problem]
    for depth in range(MAX_DEPTH):
        cands = [t for s in frontier for t in llm_propose(s, k)]
        scored = [(llm_value(c), c) for c in cands]          # e.g. "sure / likely / impossible" -> 1 / 0.5 / 0
        frontier = [c for _, c in sorted(scored, reverse=True)[:beam]]
        done = [c for c in frontier if is_solution(c)]
        if done: return done[0]
🐍 Exercise 1: search primitives
Write beam search, depth-first search with pruning and a budget, and the UCT score.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Prefer over self-evaluation where possible:
  2. 2. Avoid re-exploring by…
  3. 3. With reliable evaluation, a cheap choice is…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why search helps. A chain succeeds only if every step is good: with per-step success q over d steps, about q^d. Search keeps several candidates per level, so a level fails only if no kept candidate is good; with a decent evaluator the per-level success approaches 1 − (1 − q)^k.

Evaluator errors. False ‘impossible’ judgements prune the only good branches; false ‘possible’ ones waste budget. Beam search tolerates some errors by keeping several states; DFS relies on each pruning decision and backtracks only after wasted descents.

Exploration in MCTS. UCT picks the child maximising mean value + c·√(ln N / n): unvisited or rarely visited children get a bonus. This balances trying new branches against exploiting good ones and has regret guarantees for bandits.

Cost accounting. BFS with beam b, k proposals and depth d costs about k + 2(d − 1)·b·k calls (proposals and evaluations); DFS cost depends on how often it must backtrack.

📝 Quick check (Level 3)
0/3 answered
  1. 1. A chain's success over d steps is about…
  2. 2. False 'impossible' judgements…
  3. 3. UCT's bonus favours…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How much do repeated chains, breadth-first and depth-first tree of thoughts improve a weak step-by-step solver, and how much does the evaluator matter?

History.

  • S. Yao et al., “Tree of thoughts: deliberate problem solving with large language models” (NeurIPS 2023).
  • L. Kocsis and C. Szepesvári, “Bandit based Monte-Carlo planning” (UCT, 2006); D. Silver et al., AlphaGo (2016).
  • X. Guan et al., “rStar-Math” (2025); DeepMind AlphaProof (2024).

Exercise 2. 200 solvable Game-of-24 puzzles (four numbers from 1 to 13); an exact solver gives ground truth.

  • Proposals: a simulated model proposes a step that keeps the puzzle solvable with probability 0.35 (if one exists), otherwise a random legal step.
  • Evaluation: the model judges whether a state is solvable, wrong 15% of the time.
  • Methods: one chain; up to 10 chains with an exact check at the end; BFS ToT (5 proposals per state, beam 1 or 5); DFS ToT (5 proposals, prune ‘impossible’, budget 60 calls).
method solved model calls
one chain 0.085 3
up to 10 chains 0.665 19.1
ToT BFS, beam 1 0.555 25
ToT BFS, beam 5 0.920 85
ToT DFS with backtracking 0.870 16.8
ToT BFS, beam 5, evaluator wrong 45% 0.670 85
  • Search turned a 9% solver into a 92% one, similar in shape to Yao et al.’s 4% → 74% with GPT-4.
  • Repeated chains needed an exact final check to be useful and still fell well short.
  • Beam width mattered: one kept state was fragile to a single bad evaluation.
  • DFS found most solutions at a fifth of BFS’s cost because a reliable evaluator let it prune early.
  • A poor evaluator cost 25 points: search amplifies whatever the value signal says.
  • Seeds 1 and 2: beam 5 0.885 and 0.920; DFS 0.870 and 0.840; one chain 0.090 and 0.080.
  • Caveat: the proposal and evaluation models are simulated with fixed error rates; real model errors are correlated with puzzle difficulty.
🐍 Exercise 2 (research): how much do repeated chains, breadth-first and depth-first tree of thoughts improve a weak step-by-step solver, and how much does the evaluator matter?
Solve Game-of-24 puzzles with a simulated model using single chains, repeated chains, breadth-first and depth-first tree of thoughts.

Reasoning search in AI, robotics and aerospace

  • Task and motion planning: tree search over symbolic actions with feasibility checks is the classical analogue; language models now propose actions inside such searches.
  • Mission planning: search with constraint checkers (power, thermal, visibility windows) evaluating partial plans.
  • Design exploration: proposing and evaluating design variants with simulators as value functions.

References

  1. S. Yao et al. (2023). “Tree of thoughts: deliberate problem solving with large language models.” NeurIPS.
  2. L. Kocsis and C. Szepesvári (2006). “Bandit based Monte-Carlo planning.” ECML.
  3. D. Silver et al. (2016). “Mastering the game of Go with deep neural networks and tree search.” Nature.
  4. X. Guan et al. (2025). “rStar-Math: small LLMs can master math reasoning with self-evolved deep thinking.” arXiv:2501.04519.