Chain-of-thought, tree-of-thought and self-consistency decoding
Welcome to the second edition of the prompt guide! π This time, weβll take you on a tour of three high-level strategies for tricky requests to large language models (LLMs): Chain-of-Thought (CoT), Tree-of-Thought (ToT) and self-consistency decoding. π
Imagine youβre on a quiz show and the question is so complicated youβd love to excuse yourself for a thinking break. This is where the three prompting methods come in: they make your prompt more effective and help the AI make smart decisions. Weβll show you which method fits when β and how to apply it easy-peasy to your next prompt.
Get comfortable, grab a coffee β or whatever inspires you β and dive into the magic of clever prompting! Before we turn to the advanced prompting methods, hereβs a quick refresher on what prompting actually means:
In classic prompting, we ask a direct question and the LLM gives a quick, simple answer β perfect for clear, straightforward requests.
But with more complex questions or tasks that require more brainpower and structure, this approach quickly reaches its limits. Thatβs exactly where advanced methods such as Chain-of-Thought, Tree-of-Thought and Self-Consistency come in.
Chain-of-Thought (CoT)
Imagine youβre explaining a complicated question to a friend β instead of blurting out the answer in one sentence, you go step by step so everything stays easy to follow. Thatβs exactly what CoT does! This method gets the AI to lay out its thoughts in a structured way instead of jumping straight to the result.
How to do it: Phrase your prompt so that the AI breaks the task down into small, logical steps. A typical opener would be: βLetβs think this through step by stepβ¦β or βGo through the individual steps.β This gives the AI a kind of blueprint for creating a clear, systematic answer.
Benefits: CoT prompting produces an answer that is easy to follow and that you can go through step by step. Ideal for complex problems that require a clear thought process β for example, when you expect a calculation, an argument or a detailed analysis.
CoT shines at tasks that require a clear sequence β whether a tricky math calculation, a detailed argument or a step-by-step explanation. When a direct answer isnβt enough, CoT is the method for letting the AI βthink out loudβ and getting results you can follow.
Tree-of-Thought (ToT)
Making decisions isnβt always easy, especially when there are several options. ToT goes a step further and has the AI explore different options at the same time. This method helps weigh up the best approaches by laying out all the possibilities in a logical structure β a true pro at strategic thinking!
Benefits: With ToT, the AI can apply parallel thinking β it tries out different approaches and weighs them against each other. This is super helpful when there are several possible solutions and you want to pick the best one. That way, you get answers based on a thorough consideration of different scenarios.
When it comes to playing through different options and finding the best solution, ToT is unbeatable. Whether for scenario analyses, strategic decisions or complex problem-solving with multiple approaches β ToT helps you capture every possibility and choose the optimal path.
Self-consistency decoding
Sometimes weβre not sure whether an answer is really right, so we ask several people to find a consensus. Thatβs exactly what self-consistency decoding does! This method gets the AI to solve a task several times independently and pick the answer that comes up most often. That way, you get the most consistent solution β ideal when precision matters.
How to do it: Have the AI work through the same task several times. Then look at the results and choose the answer that appears most often β it counts as the βtrueβ solution. You can instruct this directly in the prompt, for example by saying: βSolve this task several times and give the most frequent answer.β
Benefits: This method increases reliability and precision, especially for complex tasks that might otherwise lead to fluctuating or unclear answers. The most frequent answer across several runs is usually the most stable β ideal when the AI tends to produce inconsistent results.
For demanding, ambiguous or error-prone tasks, self-consistency decoding offers the perfect safeguard. Whether diagnoses, strategic decisions or tasks with numerous variables β this method delivers reliable results by ensuring you get the most frequent answer across several runs.