$git clone https://github.com/dave1010/tree-of-thought-promptingTree-of-Thought (ToT) Prompting, a fresh technique borrowing ideas from the Tree-of-Thoughts framework, broadens and enhances the well-established Chain-of-Thought prompting concept, thereby enabling Large Language Models, like ChatGPT, to exhibit superior reasoning abilities. Th
| 1 | # Using Tree-of-Thought Prompting to boost ChatGPT's reasoning |
| 2 | |
| 3 | [](https://doi.org/10.5281/zenodo.10323452) |
| 4 | |
| 5 | |
| 6 | ## Abstract |
| 7 | |
| 8 | Tree-of-Thought (ToT) Prompting, a fresh technique borrowing ideas from the Tree-of-Thoughts framework, broadens and enhances the well-established Chain-of-Thought prompting concept, thereby enabling Large Language Models, like ChatGPT, to exhibit superior reasoning abilities. This Tree-of-Thought Prompting technique permits Large Language Models to rectify their errors autonomously while progressively accumulating knowledge. |
| 9 | |
| 10 | In one example, a ToT prompt improves ChatGPT 3.5's reasoning ability to answer a question that could previously only be answered by ChatGPT 4. |
| 11 | |
| 12 | ## Complex questions for LLMs |
| 13 | |
| 14 | Large Language Models (LLMs) often struggle to answer certain types of complex questions. Here's a representative example: |
| 15 | |
| 16 | Bob is in the living room. |
| 17 | He walks to the kitchen, carrying a cup. |
| 18 | He puts a ball in the cup and carries the cup to the bedroom. |
| 19 | He turns the cup upside down, then walks to the garden. |
| 20 | He puts the cup down in the garden, then walks to the garage. |
| 21 | Where is the ball? |
| 22 | |
| 23 | The correct answer is that the ball is in the bedroom. Although LLMs are non-deterministic, the responses I received during several attempts were as follows: |
| 24 | |
| 25 | * ChatGPT 3.5: The ball is in the garden. ❌ |
| 26 | * ChatGPT 4: The ball is in the bedroom. [followed by an explanation] ✅ |
| 27 | |
| 28 | ## Chain-of-Thought prompting |
| 29 | |
| 30 | A widely recognized concept known as "Chain-of-Thought prompting" (CoT for short) exists, which encourages Large Language Models (LLMs) to elucidate their thought process, thereby increasing the likelihood of a correct response. The roots of this concept can be traced back to a paper from January 2022 titled: [Chain-of-Thought Prompting Elicits Reasoning in Large Language Models](https://arxiv.org/abs/2201.11903). |
| 31 | |
| 32 | At its core, the CoT technique can be implemented by adding something akin to the following to a prompt: |
| 33 | |
| 34 | Think carefully and logically, explaining your answer. |
| 35 | |
| 36 | This approach enhances the performance of LLMs in answering many questions, although its effectiveness varies. |
| 37 | |
| 38 | Here's an example of ChatGPT 3.5's response: |
| 39 | |
| 40 | Based on the given sequence of events, we can logically determine the location of the ball. Let's analyze each step: |
| 41 | 1. Bob is in the living room. |
| 42 | - No mention of the ball in the living room. |
| 43 | 2. Bob walks to the kitchen, carrying a cup. |
| 44 | - No mention of the ball in the kitchen yet. |
| 45 | 3. Bob puts a ball in the cup. |
| 46 | - The ball is now inside the cup. |
| 47 | 4. Bob carries the cup to the bedroom. |
| 48 | - The ball is still inside the cup. |
| 49 | 5. Bob turns the cup upside down. |
| 50 | - If the ball was inside the cup, it would have fallen out when Bob turned it upside down. |
| 51 | 6. Bob walks to the garden. |
| 52 | - Bob left the cup in the garden, but there is no mention of the ball being removed from the cup. |
| 53 | 7. Bob puts the cup down in the garden. |
| 54 | - The ball, if it was in the cup, would still be in the cup in the garden. |
| 55 | 8. Bob walks to the garage. |
| 56 | - No mention of the ball being taken to the garage. |
| 57 | Based on the given information, we can conclude that the ball is still inside the cup in the garden. |
| 58 | |
| 59 | * ChatGPT 3.5 CoT: The ball is in the garden. ❌ |
| 60 | |
| 61 | You can see how ChatGPT realised the ball fell out at step 5 but still didn't get the answer correct. |
| 62 | |
| 63 | Can we do any better, without resorting to ChatGPT 4? |
| 64 | |
| 65 | ## Tree-of-Thought Framework |
| 66 | |
| 67 | Recent weeks have seen the emergence of several papers and Python repositories introducing the concept of Tree-of-Thoughts (ToT): |
| 68 | |
| 69 | * [Large Language Model Guided Tree-of-Thought](https://arxiv.org/abs/2305.08291), 15 May 2023. [Github](https://github.com/jieyilong/tree-of-thought-puzzle-solver). |
| 70 | * [Tree of Thoughts: Deliberate Problem Solving with Large Language Models](https://arxiv.org/abs/2305.10601), 17 May 2023. [Github](https://github.com/ysym |