The Tree-of-Thought or TOT makes it possible to simulate human reflection to solve a problem by following a chain of parallel thoughts. It is possible to reproduce the TOT by adding some instructions to your prompt.
After the Chain of Thought (COT), the Tree-Of-Thought (TOT) has been democratizing for a few months. The technique makes it possible to reason an LLM on several different thought paths to obtain a more relevant response to a given problem. The technique also makes it possible to obtain precision rates much higher than COT. Operation, implementation, limits … We explain everything to you.
Reasoning inspired by the human brain
When we think about a problem, our brain does not follow a single linear trajectory, but generates and tests mentally different hypotheses. The Tree of Thoughts, developed by researchers from Deepmind (yes, again) and Princeton, aims to simulate this operation: the LLM generates several “thoughts” or potential reasoning paths, evaluates them, prunes the least promising branches and continues to explore the most promising paths. Unlike the Chain-of-Thought, the TOT allows the LLM not to freeze on a first potentially erroneous idea which would then arrive at a bad result. The TOT allows the model to maximize its chances of finding the best solution.
More concretely, the Tree of Thoughts breaks down a problem into several intermediate stages. For each step, the model generates several potential solutions. These are then evaluated according to predefined criteria and the most promising paths are only kept. The evaluation of the most relevant ideas of ideas is carried out, in the original technique, using width research algorithms (we explore all immediate options) or in depth (we dig a track before exploring another). Finally, once n branches developed, the model selects the most relevant to deduce the final solution.
The two major use techniques
There are two techniques for using TOT. The first is to be reserved for complex problem solving and uses several LLM calls (via an API, for example) until the final resolution. The second is a prompting method directly inspired by the original TOT which uses only one prompt.
The first method therefore consists in cutting the TOT process into five stages: the cutting of a problem in N different reasoning (Thought Decomposition), the launch of the reflection in parallel of each branch (Thought Generation), the evaluation of the results of each branch (State Evaluation), the decision to continue the process or not, and finally, when a coherent result, is found to be the global synthesis by evaluating most promising branches.
The complex method in 5 steps
1. Decomposition of the problem into sub-approaches
For the first step, just ask the LLM to break down a problem in n stages.
Example of a prompt:
Problème : (INSÉRER_PROBLÈME) Identifiez (NOMBRE_PENSEE) angles d'approche différents pour résoudre ce problème. Pour chaque approche, fournissez votre réponse au format XML suivant :(Nom de l'approche) (Description brève de cette méthode) (Pourquoi cette approche pourrait être efficace) (Nom de l'approche) (Description brève de cette méthode) (Pourquoi cette approche pourrait être efficace)
2. Generation of different approaches
We are now launching the generation of the N different thought paths. Example of a prompt to launch the generation of an approach:
Pour l'approche "(NOM_APPROCHE)" identifiée précédemment, développez maintenant un raisonnement complet. Contexte :** (RAPPEL_DU_PROBLÈME) Approche à développer : (DESCRIPTION_APPROCHE) Développez cette approche étape par étape en utilisant le format XML suivant :(Que faites-vous à cette étape) (Pourquoi cette étape est nécessaire) (Résultat ou conclusion de cette étape) (Que faites-vous à cette étape) (Pourquoi cette étape est nécessaire) (Résultat ou conclusion de cette étape) (Solution finale de cette approche) (Élevé/Moyen/Faible) (Limites identifiées de cette approche)
3. Evaluation of different approaches
We will now assess the different approaches generated by the model. We can for example give a relevance score of 1 to 10.
Example of prompt:
(LISTE_DES_APPROCHES_AVEC_LEURS_SOLUTIONS) Pour chaque approche, fournissez une évaluation structurée :(Commentaire sur la faisabilité) (La solution traite-t-elle tous les aspects ?) (Résistance aux cas limites) (Efficacité de la solution) (Moyenne des scores) (Point fort 1) (Point fort 2) (Point faible 1) (Point faible 2) (Recommander/Écarter/Améliorer)
4. Stop or?
This step allows you to completely automate the TOT. We will analyze the results previously obtained in step 3 and assess the relevance of relaunching a generation of the remaining paths. We will then simply apply basic conditions (If / Else) to determine if it is relevant to continue. For example: if the score of a branch is greater than 8/10, it can be estimated that it is useless to relaunch and we go to stage 5 of summary.
5. Summary of optimal solutions
To synthesize the different optimal solutions found by the model, you can apply a summary prompt and offer a unique output. Example of prompt:
"Problème original : (PROBLÈME) Approches prometteuses : (LISTE_APPROCHES_SCORES_ÉLEVÉS) Analysez ces approches et fournissez la ou les solutions optimales. Fournissez ensuite une synthèse globale de réponse au problème initial."
The simple method in a step
To avoid having to implement a complex framework (like the one offered above), you can invite the model to use an approach inspired by the TOT via a unique prompt. The result will not be as effective but however makes it possible to obtain good results.
Simple prompt example:
Vous allez résoudre ce problème en utilisant la méthode tree of thoughts. Explorez plusieurs chemins de raisonnement en parallèle avant de choisir la meilleure solution. PROBLÈME À RÉSOUDRE : (INSÉRER_VOTRE_PROBLÈME_ICI) INSTRUCTIONS : PHASE 1 : EXPLORATION INITIALE (Génération de branches) Identifiez n approches complètement différentes pour aborder ce problème. Pour chaque approche : Donnez-lui un nom descriptif Expliquez la logique en 1-2 phrases Identifiez le type de solution qu'elle produirait PHASE 2 : DÉVELOPPEMENT PARALLÈLE (Exploration des branches) Pour chaque approche prometteuse, développez le raisonnement en 2-3 étapes : Décrivez les actions concrètes à chaque étape Évaluez la viabilité : "Impossible" / "Incertain" / "Prometteur" Identifiez les obstacles potentiels Continuez seulement les branches "Prometteuses" ou "Incertaines" avec du potentiel PHASE 3 : ÉVALUATION CRITIQUE (Sélection) Pour chaque approche viable, donnez : Score de faisabilité (1-10) : Peut-on vraiment l'implémenter ? Score d'efficacité (1-10) : Résoudra-t-elle bien le problème ? Score de ressources (1-10) : Coût/effort raisonnable ? Score global et justification PHASE 4 : OPTIMISATION FINALE (Synthèse) Choisissez la meilleure approche OU combinez les meilleures idées Détaillez la solution optimisée en étapes concrètes Anticipez les difficultés et préparez des solutions de contournement FORMAT DE RÉPONSE : Structurez votre réponse en montrant clairement votre processus de pensée arborescent. Utilisez des sections, des sous-points, et indiquez vos choix de continuer/abandonner certaines branches.
Precision has a price
The different prompting techniques that have emerged since the arrival of LLMs on the market all demonstrate: with generative AI, precision always has a price. The more a model is invited to think or reconsider his answers, the more he will generate tokens. Its operating cost to inference will therefore be more important, whether via an API or using an inferred model locally. And the case of the TOT does not escape it. Deepmind and Princeton researchers estimate that the TOT requires 5 to 100 times more tokens generated than COT.
However, the results of the TOT approach will be much more relevant. In the game of 24 (reaching the figure of 24 using the four numbers available), GPT-4 with prompting chain-of-thought only solved 4% of the problems, while with the TOT, the success rate jumped at 74%. The TOT is therefore to be favored for use cases which require either planning (a complex agent) or the resolution of a very complex task (requiring a multitude of steps to reach the final result).




