Learn With Nathan
  • AI Chat Tools
    • ChatGPT - OpenAI
      • Start with ChatGPT
      • Account Settings
      • ChatGPT Free Plan
      • ChatGPT Account Settings
    • Claude - Anthropic
      • Signup for Claude
      • User Interface
    • Gemini - Google
  • AI Concepts
    • Context
    • Tokenization
    • Prompt Engineering
    • Temperature
    • Max Tokens
    • Fine-Tuning
    • System Prompt
    • Persona
    • Memory
    • Hallucination
    • Model Bias
    • Embedding
    • Latency
    • User Intent
    • Multimodal AI
    • Safety Layers
    • Chain of Thought
    • Prompt Templates
    • Retrieval-Augmented Generation (RAG)
  • Introduction to Prompting
    • Beginner's Prompting Strategies
      • Understanding the Purpose of a Prompt
      • Be Specific and Clear
      • Using Contextual Information
      • Direct vs. Open-Ended Prompts
      • Step-by-Step Instructions
      • Role-Based Prompts
      • Sequential Prompts
      • Multi-Step Questions
      • Incorporating Examples
    • Common Prompting Mistakes to Avoid
      • Being Too Vague or Ambiguous
      • Overloading with Multiple Questions
      • Ignoring Context Limitations
      • Not Specifying the Desired Output
      • Lack of Iteration and Refinement
      • Neglecting to Set the Right Tone or Role
      • Using Jargon or Complex Language Unnecessarily
      • Ignoring Feedback from the AI
      • Overly Long or Short Prompts
      • Page 6
      • Page 5
      • Page 4
      • Page 3
      • Page 2
      • Page 1
    • Output Formatting Techniques
      • Using Headings and Subheadings
      • Bulleted and Numbered Lists
      • Paragraph Structure
      • Tables and Charts
      • Direct Answers vs. Detailed Explanations
      • Incorporating Summaries and Conclusions
    • Leveraging Formatting for Clarity
      • Highlighting Key Points
      • Guiding the AI on Tone and Style
      • Requesting Examples or Case Studies
      • Formatting for Different Audiences
      • Using Questions to Clarify Information
      • Prompting for Step-by-Step Guides
      • Customizing Responses for Presentation or Reports
      • Avoiding Over-Complicated Formatting
  • Types of Prompts
    • Direct Prompts
    • Instructional Prompts
    • Conversational Prompts
    • Contextual Prompts
    • Example-Based Prompts
    • Reflective or Feedback Prompts
    • Multi-Step Prompts
    • Open-Ended Prompts
    • Role-Based Prompts
    • Comparative Prompts
    • Conditional Prompts
    • Summarization prompts
    • Exploratory Prompts
    • Problem-Solving Prompts
    • Clarification Prompts
    • Sequential Prompts
    • Hypothetical Prompts
    • Ethical or Judgment-Based Prompts
    • Diagnostic Prompts
    • Instructional design prompts
    • Page 8
    • Page 7
  • Advanced Prompting Techniques
    • Zero-Shot
    • Few-Shot
    • Chain-of-Thought
    • Meta Prompting
    • Self-Consistency
    • Generated Knowledge
    • Prompt Chaining
    • Tree of Thoughts (ToT)
    • Retrieval-Augmented Generation (RAG)
    • Automatic Prompt Engineer (APE)
    • Active Prompt
    • Directional Stimulus
  • Live Examples
    • Legal
      • Non-Disclosure Agreement (NDA)
      • Employment Contract
      • Lease Agreement
      • Service Agreement
      • Sales Agreement
    • Zero-Shot Prompting
    • Few-Shot Prompting
Powered by GitBook
On this page
  1. Advanced Prompting Techniques

Tree of Thoughts (ToT)

PreviousPrompt ChainingNextRetrieval-Augmented Generation (RAG)

Last updated 5 months ago

Understanding Tree of Thoughts (ToT)

What is Tree of Thoughts (ToT)? Tree of Thoughts (ToT) is a prompting strategy designed to enable AI to explore multiple pathways of reasoning, akin to branching in decision trees. This method allows the AI to generate and evaluate various possibilities for solving a problem, ultimately selecting the most optimal solution based on logical progression or predefined criteria. Each "thought" represents a step or idea in the reasoning process, with the potential to branch out into alternative solutions or deeper analysis.

ToT is particularly effective for complex, multi-step problems or creative tasks where multiple approaches need to be considered before arriving at a final answer.

Game of 24, while GPT-4 with chain-of-thought prompting only solved 4% of tasks, our method achieved a success rate of 74%.

Tree of Thoughts: Deliberate Problem Solving with Large Language Models Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L. Griffiths, Yuan Cao, Karthik Narasimhan


Examples

  1. Mathematical Problem Solving Prompt: "Solve the equation 2x + 5 = 15. Generate different approaches to solving it, and identify the most efficient method." Expected Response:

    • Thought 1: Subtract 5 from both sides → 2x = 10 → Divide by 2 → x = 5.

    • Thought 2: Divide everything by 2 first → x + 2.5 = 7.5 → Subtract 2.5 → x = 5. Final Answer: Thought 1 is more straightforward, so the solution is x = 5.

  2. Creative Writing Prompt: "Write a story about a mysterious island. Brainstorm three possible plotlines before choosing the most compelling one to develop." Expected Response:

    • Thought 1: A scientist discovers a hidden ecosystem of prehistoric creatures.

    • Thought 2: A shipwrecked crew uncovers a treasure guarded by supernatural beings.

    • Thought 3: A traveler finds an island where time moves differently. Final Answer: Thought 3 is chosen, and the story is developed further.

  3. Business Decision Making Prompt: "Your company must choose between three marketing strategies: influencer partnerships, SEO optimization, or paid advertising. Explore the pros and cons of each before deciding." Expected Response:

    • Thought 1: Influencer partnerships reach a younger audience but can be costly.

    • Thought 2: SEO optimization has long-term benefits but requires significant time.

    • Thought 3: Paid advertising is quick but expensive and has diminishing returns. Final Answer: SEO optimization is chosen for its sustainable impact.

  4. Educational Explanation Prompt: "Explain why the Earth’s seasons change. Explore multiple ways to explain this concept to a middle school audience." Expected Response:

    • Thought 1: Use a globe and flashlight to demonstrate Earth's tilt and orbit.

    • Thought 2: Create a diagram showing how sunlight hits different parts of Earth.

    • Thought 3: Relate seasons to real-life examples like summer vacation and winter holidays. Final Answer: Thought 1 is chosen for its visual and interactive appeal.


Applications

Where and When to Use Tree of Thoughts (ToT)

  1. Problem Solving and Analysis

    • Useful for breaking down and evaluating complex problems with multiple possible solutions. Example: Debugging code, planning strategies, or analyzing historical events.

  2. Creative Tasks

    • Ideal for brainstorming ideas for stories, marketing campaigns, or artistic projects. Example: Generating alternative character arcs for a screenplay.

  3. Decision Making

    • Helps weigh pros and cons across multiple options before making a choice. Example: Choosing between different investment opportunities.

  4. Educational Scenarios

    • Offers alternative ways to teach or explain a concept for different audiences. Example: Teaching mathematical concepts through various problem-solving techniques.

  5. Iterative Refinement

    • Enables exploration of alternative approaches before refining and combining the best elements. Example: Designing a product prototype by evaluating multiple design ideas.


Troubleshooting

If Things Don’t Work as Expected

  1. Branches Are Redundant or Irrelevant What to Do:

    • Refine the initial prompt to specify the need for diverse and relevant branches. Example Fix: Change "Explore ways to improve customer retention" to "Explore three distinct strategies for improving customer retention, focusing on technology, communication, and incentives."

  2. No Clear Evaluation Criteria What to Do:

    • Add explicit evaluation criteria to guide the selection of the best branch. Example Fix: "Evaluate each approach based on cost, time efficiency, and long-term impact."

  3. The Tree Becomes Too Complex What to Do:

    • Limit the depth of exploration or the number of branches. Example Fix: Specify: "Generate two branches per step, and evaluate after three steps."

  4. Output Does Not Converge on a Solution What to Do:

    • Ask the AI to summarize and justify the final choice based on logical reasoning. Example Fix: Add: "Summarize the reasoning and justify why this option is the best."


Best Practices

  1. Define a Clear Objective

    • Start with a concise description of the task and the expected output. Example: "Explore three solutions for reducing energy consumption, then select the most feasible one."

  2. Limit Branches to Manage Complexity

    • Set a cap on the number of branches and depth of exploration to keep outputs concise and relevant. Example: "Generate up to three branches per thought, and stop after two levels."

  3. Specify Evaluation Criteria

    • Include factors like feasibility, efficiency, or creativity to guide the selection process. Example: "Choose the best solution based on cost and environmental impact."

  4. Iterative Exploration

    • Use follow-up prompts to refine the chosen branch or explore further if needed. Example: "Develop Thought 2 into a detailed plan with actionable steps."

  5. Encourage Divergent Thinking

    • Prompt for diverse ideas at each branching point to maximize creativity. Example: "Generate three entirely different approaches to marketing a new product."


Additional Section: Advantages and Limitations

Advantages:

  • Encourages thorough exploration of possibilities.

  • Helps identify optimal solutions through logical evaluation.

  • Enhances creativity and critical thinking.

  • Reduces the risk of missing alternative approaches.

Limitations:

  • Can become overly complex if not well-structured.

  • May require significant user intervention to refine branches.

  • Relies on the AI’s ability to generate diverse and relevant thoughts.


Tree of Thoughts (ToT) is a powerful tool for tackling complex tasks, fostering creative brainstorming, and ensuring robust problem-solving. By systematically exploring and evaluating multiple pathways, learners can enhance both the depth and quality of their AI interactions.

Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsarXiv.org
GitHub - princeton-nlp/tree-of-thought-llm: [NeurIPS 2023] Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsGitHub
Logo
Logo