Tree of Thoughts (ToT)

For complex tasks that require exploration or strategic lookahead, traditional or simple prompting techniques fall short. These research papers explain more on Tree of Thought.

ToT maintains a tree of thoughts, through coherent language sequences that serve as intermediate steps that the model can use to self evaluate the progress through intermediate thoughts. The Large Language Model (LLM) ability to generate and evaluate thoughts in then combined with search algorithms to enable systematic exploration of thoughts with lookahead and backtracking.

The ToT framework is illustrated below

When using ToT, different tasks require defining the number of candidates and the number of thoughts/steps.

Game of 24 is used as a mathematical reasoning task which requires decomposing the thoughts into 3 steps, each involving an intermediate equation. At each step, the best b=5 candidates are kept.
To perform Breadth First Search (BFS) in ToT for the Game of 24 task, the LM is prompted to evaluate each thought candidate as “sure/maybe/impossible” with regard to reaching 24. As stated by the authors, “the aim is to promote correct partial solutions that can be verdicted within few lookahead trials, and eliminate impossible partial solutions based on “too big/small” commonsense, and keep the rest “maybe"". Values are sampled 3 times for each thought. The process is illustrated below:


Source: promptingguide.ai

From the results reported we can see that ToT has improved results when compared to the other techniques in Prompt Engineering to complete complex tasks.

A sample prompt for ToT would be

Imagine three different experts are answering this question.
All experts will write down 1 step of their thinking,
then share it with the group.
Then all experts will go on to the next step, etc.
If any expert realises they're wrong at any point then they leave.
The question is...

Tree of Thoughts was benchmarked on a larger scale which introduced us to PanelGPT an idea of prompting with Panel discussions among LLMs.

References