English
Share
Sign In
🌳

Tree of Thought (ToT) Technique

Tree of Thoughts is a language model prompting technique proposed by Yao and Long in their 2023 paper <Tree of Thoughts (ToT): A Framework for Advanced Problem Solving>, and is an approach particularly suitable for complex tasks that require strategic thinking and exploration. ToT extends the concept of Chain-of-Thought (CoT) prompts by utilizing the tree-like structure of thoughts combined with a search algorithm for systematic problem solving.
How ToT works
To put it simply, the Tree of Thoughts (ToT) technique is a tree-like structure that represents the process of exploring multiple possibilities and finding the optimal solution when solving a problem. This allows the language model to consider multiple directions like a human, and if necessary, to go back to the previous step and try a different method.
Why ToT is getting attention
Tree Structure: ToT explores the problem-solving process as a tree with various paths, each 'branch' representing a single idea or step toward problem-solving. (Think of the folder structure we commonly see in Explorer.)
Idea generation and evaluation: Just as a person thinks of several ideas to solve a problem and evaluates which one is the best, a language model generates several solutions and finds the best one among them.
Exploration and backtracking: Explore multiple paths to solve a problem, going back to previous steps and rethinking in a different direction if necessary.
Practical Applications
The problem with CoT is that you can't do regression. If you have to go all the way, see the result, and then chain, the biggest charm of ToT is that you can do regression in the middle and correct it. As mentioned earlier, let's assume that you are solving a math problem that LLM finds difficult. For example, let's say there is a quiz like the one below.
"4x4 스도쿠 퍼즐의 빈 칸을 채워 넣으시오."
General method
Progress: The usual way is to find the missing numbers one by one in each row, column, and 2x2 grid and fill in the blanks.
Result: Complete the puzzle by filling in the blanks sequentially.
🤖
The 4x4 Sudoku puzzle I created has all the squares blank. So the completed Sudoku board for solving this puzzle would look like this:
1 2 3 4
3 4 1 2
2 1 4 3
4 3 2 1
ToT technique
Add ToT Process Prompt
Step 1: The language model suggests a number to fill the first blank space.
Step 2: Consider the numbers that will go in the following blank spaces.
Backtracking: If at any step the puzzle is determined to be unsolvable, the language model goes back to a previous step and tries a different number.
Final Output: Complete the puzzle by correctly filling in all the blanks.
🤖
I went through the process of solving a 4x4 Sudoku puzzle step by step, and after a total of 14 steps, I filled in all the blanks correctly. The final completed Sudoku puzzle looks like this:
1 2 3 4
3 4 2 1
4 3 1 2
2 1 4 3
Actually, if you look at it this way, you can't really feel the difference. But if you look at the code that this guy solved, you can understand it.
General prompt mode
ToT method
If we ran this in GPT-3.5, we could see the following:
As you can see from the results, we can say that techniques that utilize these prompts are enough to reproduce what we can do in GPT-4 in GPT-3.5 or LLaMA2. (Even in the case of GPT-4, it is simply solved by coding.
🧊
📖
ⓒ 2023. Haebom, all rights reserved.
It may be used for commercial purposes with permission from the copyright holder, provided the source is cited.