liveBook · Manning

Tree-of-thought

As explained in Transformers in Action

Tree-of-thought prompting explores and evaluates multiple branching intermediate reasoning paths before producing an answer.

Tree-of-thought (ToT) prompting guides an LLM through multiple coherent intermediate reasoning paths instead of relying on one linear chain. It combines thought generation, evaluation, and systematic tree search for complex, exploratory, or strategic tasks. section 4.2.7

A ToT workflow progressively narrows candidate solutions:

  • Generate coherent text units that represent possible intermediate decisions or reasoning steps. section 4.2.7
  • Search the resulting tree with breadth-first search (BFS) or depth-first search (DFS), depending on whether level coverage or branch depth matters. section 4.2.7
  • Evaluate each intermediate thought and discard impossible partial solutions, retaining candidates rated likely or sure. section 4.2.7

Game of 24

Given 4, 9, 10, and 13, ToT evaluates alternative equations while preserving viable branches. One successful path is 13 − 9 = 4, 10 − 4 = 6, and 4 × 6 = 24, yielding 4 × (10 − (13 − 9)) = 24. A GPT-4 implementation uses the tree-of-thoughts-llm package, the Game24Task task definition, generated candidates, value evaluation, and greedy selection. section 4.2.7

Figure 4.10 Illustration of how ToT can be used, where (a) corresponds to the thought generation and (b) to the evaluation of the thought. Image is taken from [4].
figure

Use the diagram to inspect the separation between thought generation and thought evaluation, the two central stages of ToT. section 4.2.7

How Transformers in Action covers it

How deep it goes
Explains generation, evaluation, BFS, DFS, pruning, and a GPT-4 implementation rather than only defining the technique.
Examples
Demonstrates Game of 24 with arithmetic branches, candidate labels, a GPT-4 workflow, and a final valid equation.
What it assumes
Assumes basic prompting and LLM concepts while introducing search-based reasoning through BFS, DFS, and intermediate-thought evaluation.
What you can do after
Apply it via a tree-search implementation that generates, evaluates, prunes, and selects intermediate reasoning paths.
How it connects
Connects chain-of-thought prompting with search algorithms, BFS, DFS, prompt engineering, and language-model evaluation.

Also explained in

Compare how 6 books explain Tree-of-thought →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Transformers in Action. The section links point to the parts of the book it draws on.