Why do we need the Tree of Thoughts in prompting LLMs? Well, we want our AI to wander in a forest, staying close to mother nature. This way, they can truly feel and understand our world, rather than brooding alone in a digital black box until suddenly wake up one day and decide to annihilate the universe.😉
Now, diving into the heart of the matter…
If you’ve been following this series, you might recall our discussion on the Chain of Thought (CoT) prompting method, which was all about giving our AI models the time to ponder and think step by step, rather than rushing to a quick answer. While CoT laid the groundwork, ToT takes this concept to the next level, offering a more intricate and effective approach.
Picture this: you’re piecing together a jigsaw puzzle. Instead of having a complete picture from the get-go, you start with one piece, then find another that fits, and gradually the image takes shape. The ToT method works in a similar fashion. Instead of having a pre-defined roadmap, the AI builds its “tree” of thoughts step by step, exploring different avenues of reasoning as it goes along.
Comparing this with traditional prompting methods:
- IO (Input-Output) Prompts: This is your bread-and-butter approach. You pose a question to the language model and await a direct reply. It’s straightforward and widely adopted.
- Few-Shot Prompts: By providing examples, you’re setting the stage for the kind of response you’re hoping to receive.
- Chain-of-Thought (CoT) Prompts: Here, you’re inviting the AI to ponder, to mull things over step by step. However, it’s typically confined to more linear and uncomplicated logical reasoning.
ToT, however, offers a fresh perspective. It allows the AI to dynamically generate its thought process, branching out and exploring different lines of reasoning. This extended “thinking” time is what makes complex reasoning possible, as highlighted in these two seminal papers( 1 & 2 ). It’s like giving our AI a moment to breathe, reflect, and come up with a well-thought-out response.
Delving Deeper into ToT: A Blend of Theory and Practice
Alright, folks, let’s embark on a journey through the forest of the Tree of Thoughts (ToT) method. Imagine you’re setting out on a hike, and instead of a physical map, you have the ToT guiding you. But here’s the catch: the map isn’t pre-drawn. You create it as you go along, discovering new paths and sometimes retracing your steps when you hit a dead end. Intrigued? Let’s dive in!
Setting Out: The Root Question
Our hike begins with a root question, our starting point. Think of it as the trailhead of our hike. This is the main query or problem we want our AI to ponder upon.
For instance, in the Game of 24, the root question might be: “How can we achieve a total of 24 using basic arithmetic operations with the numbers 4, 9, 10, and 13?”
To clarify the rules, we could incorporate one or more examples into the prompt, as shots.
Exploring the Paths: Generating Candidate Answers
As we move forward, the AI, like a curious hiker, starts exploring different paths. It generates several candidate answers or responses to the root question. Each of these candidates represents a potential direction our hike (or thought process) could take.
The AI might churn out several candidate thoughts like:
“4 + 9 = 13, leaving (10, 13, 13) to work with;”
“10 – 4 = 6, leaving (6, 9, 13);”
“9 – 4 = 5, leaving (5, 10, 13);”
and so on.
The Guiding Compass: Evaluation
Now, with multiple paths ahead, how do we decide which one to take? Enter the evaluator. Acting as our compass, it assesses each candidate answer, weighing their relevance and accuracy. It’s like checking which trail looks promising and which might lead to a dead end.
We could prompt the AI to evaluate each intermediate candidate to ascertain the likelihood of reaching 24 with the remaining numbers.
Each candidate can undergo multiple evaluations.
Democracy in Action: Voting
After evaluation, it’s time for a little democratic process. The AI “votes” on the best candidate answer, choosing the one that seems most promising. This selected answer then becomes the next step in our journey.
Drawing from the paper: “The aim is to elevate correct partial solutions that can be resolved within a few lookahead trials, sideline impossible partial solutions based on ‘too big/small’ commonsense, and retain the ‘maybe’ ones.”
For instance, in our Game of 24 example, the candidate “10 – 4 = 6, leaving (6, 9, 13)” garnered the most votes, while “4 + 9 = 13, leaving (10, 13, 13)” was deemed unfeasible and received none.
The Journey Continues: Iterative Prompting
With our chosen path, we continue our hike. The AI prompts the next set of questions based on the selected answer, diving deeper into the topic. It’s like following a trail, discovering new viewpoints, and occasionally finding hidden gems.
For instance, we might prompt the AI to target 24 using the numbers 6, 9, and 13. The AI would then iterate its inferences, suggesting combinations like:
“9 – 6 = 3, leaving (3, 13);”
“13 – 9 = 4, leaving (4, 6);”
and so forth.The evaluation and voting phases would iterate in tandem until the AI either hits the target of 24 or reaches an impasse.
Oops, a Dead End! Backtracking
Just like any hike, sometimes we might find ourselves at a dead end. Maybe the path is blocked, or it doesn’t lead where we hoped. In such cases, the AI backtracks, revisiting previous steps and exploring alternative paths. It’s all part of the adventure!
If all paths stemming from a prior thought are deemed unfeasible for reaching 24, it’s time to backtrack and explore a different trajectory.
The Beauty of ToT
Now, you might wonder, why all this back and forth? Well, the beauty of the ToT method lies in its dynamic nature. Instead of rushing to a destination, it allows the AI to savor the journey, exploring different avenues and arriving at well-thought-out conclusions.
And the results speak for themselves. In tasks like the Game of 24 and creative writing, ToT has showcased its prowess, outshining other methods.
ToT in Action: A Manual Approach with ChatGPT
While the Tree of Thoughts method can seem intricate in theory, seeing it in action brings a whole new perspective. For those who prefer a visual and hands-on approach, there’s a fantastic YouTube video that showcases the ToT method in a user-friendly manner.
In this video, the ToT process is manually implemented using ChatGPT. Instead of relying on complex algorithms or coding, the presenter guides the AI through the ToT process using natural language in searching for a perfect strategy to approach the boss for a salary bump. This involves guiding the AI through the search and evaluation using natural language. It’s a brilliant demonstration of how the foundational concepts of ToT can be applied in a straightforward and accessible manner.
📌 However, it’s essential to highlight the distinctions between the ChatGPT approach and the API-driven method. With the API, the generation, evaluation, and voting modules operate autonomously. In contrast, with ChatGPT, as demonstrated in the video, all prompts unfold within a single conversation. This means the model is essentially critiquing its own responses, which could influence the outcomes compared to the more compartmentalized API approach.
Insights and Implications: Beyond the Tree
The Tree of Thoughts method not only reshapes our understanding of AI interactions but also brings forth profound insights that transcend mere technicalities.
A Harmonious Blend of Old and New
As the authors of the papers astutely pointed out, current LLMs, for all their prowess, can reliably generate responses to straightforward questions. However, when faced with complex queries that demand intricate thinking, they often falter. This limitation underscores the significance of prompting engineering methods like Chain of Thought (CoT) and Tree of Thoughts (ToT). By generating a dynamic map of thoughts, ToT employs classic search algorithms, such as Breadth-First Search (BFS) and Depth-First Search (DFS), to navigate this map. These age-old algorithms, foundational in computer science, find a renewed purpose in the world of modern AI, bridging the gap between past wisdom and present innovation.
The Power of Abstraction: From Simplicity to Complexity
The marvels of the digital age, from intricate software to AI wonders, all stem from the unassuming operations of zeros and ones. This binary bedrock, though elementary, has birthed vast digital domains. Similarly, while LLMs excel at basic inferences, methods like ToT showcase how abstract structures can be layered atop these foundational capabilities, leading to more sophisticated outcomes.
Expanding on this notion, it mirrors the essence of our universe. The expansive cosmos, teeming with galaxies and celestial wonders, is fundamentally crafted from a limited set of particles. This reflection underscores the universe’s knack for spawning complexity and diversity from rudimentary elements.
Moreover, by affording AI the room to “think” and reflect, as ToT does, we emphasize the essence of abstraction and structure. It’s a more organic methodology, fostering the emergence of complexity and richness from simplicity.
In summation, some prompting methods, including CoT and ToT, transcend technical innovation; they embody a philosophical evolution in our rapport and comprehension of AI. By valuing the potential inherent in simplicity and championing the might of abstraction, we’re envisioning a future where AI evolves as a genuine collaborator.