Chain of Thoughts vs Tree of Thoughts for Language Learning Models (LLMs)

Sonal Sareen
4 min readMay 25, 2023

--

Introduction:

Large Language Models (LLMs) have revolutionized natural language processing tasks, enabling machines to understand and generate human-like text. One interesting aspect of LLMs is their ability to generate coherent and contextually relevant responses. Two popular approaches used in generating text are the Chain of Thoughts and Tree of Thoughts techniques. In this blog, we will explore the differences between these approaches and their implications for LLMs.

Image by Freepik https://www.freepik.com

Chain of Thoughts

The “Chain of Thoughts” concept is a linear approach to understanding and generating language. In this model, each new word or idea is linked directly to the one before it, forming a chain. This is similar to how humans often speak or write, with each new sentence building on the last.

For example, consider the sentence: “I went to the store. I bought apples.” Each sentence is a link in the chain, connected by the common subject “I”.

LLMs that use a chain of thoughts approach, such as GPT-3, are often good at generating coherent and contextually relevant text over short spans. However, they can struggle with maintaining coherence over longer texts, as the “chain” can sometimes get lost or tangled.

Tree of Thoughts

The “Tree of Thoughts” concept, on the other hand, is a more complex and hierarchical approach. Instead of a linear chain, ideas are organized into a tree-like structure, with each idea branching off into multiple related ideas.

For example, consider the sentence: “I went to the store and bought apples, oranges, and bananas.” In this case, the main idea (going to the store) branches off into several related ideas (buying different types of fruit).

LLMs that use a tree of thoughts approach, such as Transformer models, are often better at maintaining coherence over longer texts. They can keep track of multiple related ideas at once and understand how they relate to each other. However, these models can be more complex and computationally intensive than chain of thoughts models.

a quick comparison table for Chain of Thoughts and Tree of Thoughts:

Below are the diagrams representing each concept:

In the Chain of Thoughts diagram, you can see that each sentence is a direct continuation of the previous one, forming a linear chain. In the Tree of Thoughts diagram, the main idea (going to the store) branches off into several related ideas (buying different types of fruit).

ChatGPT and approach for thoughts

ChatGPT, developed by OpenAI, primarily uses a “Chain of Thoughts” approach, as it generates text based on the immediate previous context. However, it’s possible to emulate a “Tree of Thoughts” approach by structuring the input in a way that encourages the model to generate more complex, branching responses. Here’s how you can do it:

  1. Provide Detailed Context: Start by providing a detailed context that includes multiple related ideas. This will encourage the model to generate responses that branch off from these ideas.
  2. Ask Open-Ended Questions: Instead of asking direct questions that lead to a single answer, ask open-ended questions that can lead to multiple possible answers.
  3. Use Follow-Up Questions: After the model generates a response, ask follow-up questions that explore different aspects of the response. This will encourage the model to generate more detailed and nuanced responses.
  4. Guide the Conversation: If the model starts to drift off-topic or lose coherence, gently guide it back on track by reiterating the main ideas or asking more specific questions.

Remember, while these strategies can help emulate a “Tree of Thoughts” approach, ChatGPT is fundamentally a “Chain of Thoughts” model. It’s not designed to maintain a complex, branching conversation over a long period of time. However, with careful input and guidance, it can generate surprisingly complex and nuanced responses.

Conclusion

Both the chain of thoughts and tree of thoughts approaches have their strengths and weaknesses, and the choice between them often depends on the specific task at hand. For short, simple texts, a chain of thoughts model may be sufficient. For longer, more complex texts, a tree of thoughts model may be more appropriate.

--

--