liveBook · Manning

Tree-of-thought

As explained in Introduction to Generative AI, Second Edition

Tree of thought is a prompting technique that explores multiple branching sequences of intermediate reasoning before selecting a solution.

Tree-of-thought (ToT) is a prompting technique that asks a language model to explore several intermediate reasoning paths instead of following one sequence from start to finish. It then compares the options and selects the most promising direction. section 7.4

A ToT prompt typically does the following:

  • Generates several candidate strategies or hypotheses in parallel. section 7.4
  • Evaluates the benefits, trade-offs, or promise of each candidate. section 7.4
  • Selects a direction rather than committing immediately to the first reasoning chain. section 7.4

Customer-retention strategies

A prompt might ask for three ways to improve customer retention, request the potential benefits of each, and then require a recommendation. Possible branches include subscription models, loyalty programs, and personalized offers. The model compares these options before converging on one approach. section 7.4

Unlike chain-of-thought prompting, which produces one step-by-step sequence, ToT maintains multiple possible paths at each stage. This branching can help with logic puzzles, scientific problem-solving, and search-heavy tasks where divergent thinking matters. Its benefits are not automatic: prompting approaches still require evaluation, and post-training or hybrid methods may be more suitable in some cases. section 7.4 section 7.13

Table 7.3 Common advanced prompting techniques

Technique

Description

Example prompt

Chain-of-thought

Generate step-by-step reasoning before answering

“Let’s think step by step. John has 3 apples . . .”

Tree-of-thought

Explore multiple reasoning paths in parallel

“List three strategies, evaluate each, then choose the best.”

Self-consistency

Generate multiple reasoning chains and aggregate

“Generate five solutions, then select the most common answer.”

Reflexion

Critique and revise output iteratively

“Review your answer for errors and revise if needed.”

Verification

Add a final self-check before finalizing the response

“Double-check your answer for accuracy before submitting.”

Decomposition

Break the problem into subtasks executed sequentially

“Step 1: Extract metrics. Step 2: Summarize trends. Step 3: Write summary.”

Least-to-most

Solve easier subproblems first, then build up

“First, list known variables. Then calculate step by step.”

Pyramid priming

Build knowledge gradually in layers

“Step 1: Define carbon neutrality. Step 2: List targets. Step 3: Analyze impact.”

Generated knowledge

Surface key facts before answering

“List key concepts related to quantum entanglement before answering.”

Role-based prompting

Assign a role or persona to guide behavior

“You are an experienced employment lawyer advising a client.”

Prompt chaining

Connect multiple prompts into a pipeline

“Extract relevant quotes → Summarize → Generate final answer.”

Conversational context

Summarize prior dialogue to preserve coherence

“Summarize the student’s understanding before proceeding.”

Compare tree-of-thought with chain-of-thought, self-consistency, reflexion, verification, decomposition, and other advanced prompting techniques. section 7.4

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Explains the branching-and-selection mechanism and gives one worked example, but does not provide implementation details or systematic search procedures.
Examples
Uses customer-retention strategies, logic puzzles, scientific problem-solving, and search-heavy applications as examples.
What you can do after
Apply it via prompting to generate, compare, and select multiple candidate solutions.
How it connects
Connects tree-of-thought with chain-of-thought prompting, self-consistency prompting, prompt engineering, and 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 Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.