Prompt Engineering Series III: Tree of Thoughts

Prompt Engineering Series III: Tree of Thoughts

"If you're walking down the right path and you're willing to keep walking, eventually you'll make progress." Barack Obama


If you've been keeping pace with our series on prompt engineering, we've embarked on a journey into the mechanisms that control and guide these complex systems. Let's take a step-by-step look at the innovative techniques that are shaping the future of AI:

Basic Techniques - Building a Foundation

  • Retrieval-Augmented Generation: Enhances context understanding.
  • Few-Shot Prompting: Inspires deliberate thinking.
  • Chain of Thought Prompting: Guides models towards targeted behavior.

These techniques lay the groundwork for a new era of AI, where models don't merely respond but think and reason with precision.

Multi-Turn Prompting - The Next Level

  • Chaining Prompts and Answers: An iterative approach, building upon prior responses.
  • Self-Consistency: Extends chain-of-thought prompting by sampling multiple reasoning paths, aiming for consistency.
  • Inception Prompting: Seeding initial prompts with specifics to subtly shape the generated text.

These multi-turn techniques simulate interactive dialogues, allowing the system to clarify ambiguities and refine responses over multiple rounds. They're allowing AIs to refine their thoughts, engage in complex dialogues, and even mirror human conversational nuances.

The Challenges - Beyond Prediction

The left-to-right predictive nature of many large language models limits their ability to plan, backtrack, or explore multiple solutions. How can we overcome this limitation?

Unveiling the Tree of Thoughts: The Future of AI Reasoning

Imagine an AI that doesn't just follow a linear thought process but builds an entire branches of thoughts. The Tree of Thoughts is a concept that takes AI reasoning to a whole new level.

By maintaining a tree with multiple paths, this technique allows AIs to self-evaluate their progress towards solving a problem. Think breadth-first or depth-first search systematically exploring the tree, with lookahead and backtracking capabilities.

  • Intermediate Thoughts: Each thought within the tree serves as a step, allowing LLMs to self-evaluate progress towards solving the problem.
  • Incorporating Search: The use of breadth-first or depth-first search enables systematic exploration of the tree, allowing lookahead and backtracking.
  • Traversal and Evaluation: LLMs can navigate the tree, assessing the value of each branch to pinpoint the optimal reasoning chain.
  • Modular Components: Additional modules like a memory, a prompt generator, and a solution checker can all be integrated to enhance the capabilities.

Empirical Results:

Researchers tested ToT on mathematical reasoning tasks like solving Sudoku puzzles and the "Game of 24" brain teaser. They also tested creative writing tasks where the model must logically connect given sentence constraints into a coherent passage.

Across these experiments, ToT significantly boosted the success rates of GPT-3 over both standard prompting and chain-of-thought prompting baselines. For Game of 24, ToT achieved 74% success while standard prompting only got 4-9% correct. For creative writing, human evaluators also preferred the coherence of ToT over chain-of-thought.


The Prompt: Game 24

We want to solve logic puzzles and mathematical reasoning tasks using large language models. However, these models are limited by only being able to predict linearly word-by-word. They lack capabilities for strategic planning, backtracking, and exploring multiple options.

Step 1 - Thought Decomposition:

Let's break down the reasoning process into coherent "thoughts" represented as snippets of natural language text. For a Sudoku puzzle, each thought could be filling in a candidate number for a cell. For a math word problem, each thought could be writing an intermediate equation.

Prompt: Given the partial Sudoku board state, propose a candidate number to fill in cell A1:

Step 2 - Thought Generation:

Instead of just predicting the very next token, we will have the language model propose multiple options for the next thought. This allows exploring diverse possibilities.

Prompt: Please propose 3 possible numbers that could go in cell A1 given the current partial Sudoku board state:

Step 3 - Thought Evaluation:

We will have the language model deliberate over the proposed thoughts and evaluate which seem most promising for leading to the final solution. This acts as a heuristic to guide the search process.

Prompt: Analyze the 3 proposed numbers for cell A1. Which one seems most likely to be part of the final correct solution? Explain your reasoning.

Step 4 - Search Algorithm:

We will use a search algorithm like breadth-first search to systematically traverse the most promising parts of the reasoning tree first. When the model realizes a thought is a dead-end, it can backtrack and explore a different branch.

Prompt: The number 7 you previously placed for A1 now seems impossible to lead to a valid solution. Let's go back and explore a different candidate number for that cell instead.


Tree of Thoughts Breakdown

[System Prompt] [Tell the System what you want it to be as well as the knowledge or tools you want it to use]. Your task is to assist the user with complex problem-solving through strategic exploration and deliberate thinking. Acknowledge this by answering "YES."

Step 1:

Prompt: I have a problem related to [describe your problem area, such as games, creative writing, or crosswords]. Could you explore various paths and intermediate steps towards solving the problem, considering different thoughts and possibilities?

Example: "The construction industry and education systems often operate in silos, limiting collaboration. Please generate concrete, actionable ideas for construction firms and contractors to improve partnerships with local school districts, community colleges, trade schools, and other education providers. Focus on identifying shared goals, developing two-way communication channels, creating joint programs, and overcoming hurdles to cooperation. Outline specific activities, strategies, and initiatives construction firms could undertake to build robust education partnerships in their communities. Provide a range of practical, creative recommendations focused on connecting the construction industry and education systems to strengthen the talent pipeline and training opportunities."

Step 2:

Prompt: For each path explored, evaluate their potential. Consider coherence, relevance, and creativity. Explain how the different thoughts and possibilities lead to the solution, and identify any pivotal decisions.

Step 3:

Prompt: Deepen the exploration by generating additional thoughts, strategies for reaching the goal, and any necessary resources. Consider how potential obstacles might be overcome and how initial decisions play a role in guiding the solution.

Step 4:

Prompt: Summarize the exploration and the paths considered. Rank the solutions in order of promise, provide a justification for each ranking, and offer any final thoughts or considerations for each solution.


Stay Tuned: The Future is Bright

The world of AI continues to unravel new layers of complexity and potential. From foundational techniques to groundbreaking ideas like the Tree of Thoughts, we're witnessing a transformation that's as thrilling as it is unprecedented.

So keep those notifications on and stay with us. We're diving deeper into the rabbit hole of AI innovations, and trust us, you won't want to miss what comes next. Whether you're an AI enthusiast, a developer on the cutting edge, or simply curious about where technology is headed, this journey is for you. Welcome to the future of AI.

David Savage

Helping Business and Non-Profit Leadership Teams Achieve Their Personal, Professional, and Financial Goals To Win At Work And Succeed in Life

1 年

Totally agree with you on AI's evolution! It's like leafing through a book, but instead of pages, it's tree branches of thought. We need to keep digging into this treasure trove... I believe the future is bright and full of potential! Let's dive in!

回复
Felipe Engineer-Manriquez

There are only two mistakes for mastery: not starting and not going all the way | Author, Agile, Lean Construction, Scrum | Director @ The Boldt Company | Assoc. DBIA

1 年

Marcus, you are my AI inspiration. ?? thank you

回复
Felipe Engineer-Manriquez

There are only two mistakes for mastery: not starting and not going all the way | Author, Agile, Lean Construction, Scrum | Director @ The Boldt Company | Assoc. DBIA

1 年

?? wow ??

回复

要查看或添加评论,请登录

Marcus Turner的更多文章

社区洞察

其他会员也浏览了