{"id":1645,"date":"2024-10-09T06:18:53","date_gmt":"2024-10-09T04:18:53","guid":{"rendered":"https:\/\/guillaume-guerard.com\/?page_id=1645"},"modified":"2024-10-09T06:31:50","modified_gmt":"2024-10-09T04:31:50","slug":"tree-of-toughts-prompting","status":"publish","type":"page","link":"https:\/\/guillaume-guerard.com\/en\/cours-de-methodologie\/tree-of-toughts-prompting\/","title":{"rendered":"Tree of Thoughts Prompt"},"content":{"rendered":"<div data-elementor-type=\"wp-page\" data-elementor-id=\"1645\" class=\"elementor elementor-1645\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a0a402b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a0a402b\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-5d5d8d1\" data-id=\"5d5d8d1\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-77de3da elementor-align-justify elementor-widget elementor-widget-button\" data-id=\"77de3da\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"button.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-button-wrapper\">\n\t\t\t\t\t<a class=\"elementor-button elementor-button-link elementor-size-sm\" href=\"https:\/\/guillaume-guerard.com\/en\/\">\n\t\t\t\t\t\t<span class=\"elementor-button-content-wrapper\">\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-button-text\">Welcome<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-71ade4c\" data-id=\"71ade4c\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e46971c elementor-align-justify elementor-widget elementor-widget-button\" data-id=\"e46971c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"button.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-button-wrapper\">\n\t\t\t\t\t<a class=\"elementor-button elementor-button-link elementor-size-sm\" href=\"https:\/\/complex-systems-ai.com\/\" target=\"_blank\" rel=\"noopener\">\n\t\t\t\t\t\t<span class=\"elementor-button-content-wrapper\">\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-button-text\">Data Science<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b43366f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b43366f\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-66fb59f\" data-id=\"66fb59f\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-55c8929 elementor-widget elementor-widget-heading\" data-id=\"55c8929\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Page contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Contents\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/guillaume-guerard.com\/en\/cours-de-methodologie\/tree-of-toughts-prompting\/#Tree_of_Toughts_creer_un_arbre_de_chemin\" >Tree of Thoughts, create a path tree<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/guillaume-guerard.com\/en\/cours-de-methodologie\/tree-of-toughts-prompting\/#Exploration_des_chemins\" >Exploring the paths<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/guillaume-guerard.com\/en\/cours-de-methodologie\/tree-of-toughts-prompting\/#Exemple\" >Example<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"Tree_of_Toughts_creer_un_arbre_de_chemin\"><\/span>Tree of Thoughts, create a path tree<span class=\"ez-toc-section-end\"><\/span><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-54862f6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"54862f6\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f96b403\" data-id=\"f96b403\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-81f0766 elementor-widget elementor-widget-text-editor\" data-id=\"81f0766\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The Tree of Thoughts ToT prompting technique in LLM is a <a href=\"https:\/\/guillaume-guerard.com\/en\/cours-de-methodologie\/parfaire-la-methodologie\/\">method<\/a> advanced prompting that uses a structured approach to guide LLMs through their reasoning and response generation processes. It enhances problem solving by exploring multiple paths of reasoning, called \u201cthoughts.\u201d Unlike traditional linear prompts, ToT allows LLMs to consider a variety of possible solutions and strategies, including projecting into the future, backtracking, and self-assessment, making it more interactive and adaptable to the complexity of the task at hand.<\/p><p><img decoding=\"async\" class=\"alignnone wp-image-49 size-full\" src=\"http:\/\/guillaume-guerard.com\/wp-content\/uploads\/2023\/07\/logo_sc.png\" alt=\"Tree of Toughts\" width=\"238\" height=\"203\" \/><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-d075e2d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"d075e2d\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6e2b59e\" data-id=\"6e2b59e\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b84c4ee elementor-widget elementor-widget-heading\" data-id=\"b84c4ee\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"Exploration_des_chemins\"><\/span>Exploring the paths<span class=\"ez-toc-section-end\"><\/span><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4e1edda elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4e1edda\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-64d7901\" data-id=\"64d7901\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f04dab5 elementor-widget elementor-widget-text-editor\" data-id=\"f04dab5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Each thought represents a coherent sequence of language that evolves toward the final solution. This structure allows language models to reason deliberately by evaluating the progress that thoughts generate in solving the problem. ToT integrates the model&#039;s capabilities to generate and evaluate thoughts with algorithms for <a href=\"https:\/\/guillaume-guerard.com\/en\/cours-de-methodologie\/\">research<\/a> such as breadth-first or depth-first search.<\/p><p>This allows for systematic exploration of reasoning chains, with anticipation to expand promising directions and backtracking when solutions are incorrect. ToT excelled in the 24-game tasks, achieving a success rate of 74 %s versus 4 %s for CoT. Furthermore, in word-level tasks, ToT outperformed CoT with a success rate of 60 %s versus 16 %s.<\/p><p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-1651 size-large\" src=\"http:\/\/guillaume-guerard.com\/wp-content\/uploads\/2024\/10\/tree-of-toughts1-1024x520.png\" alt=\"tree of toughts\" width=\"1024\" height=\"520\" srcset=\"https:\/\/guillaume-guerard.com\/wp-content\/uploads\/2024\/10\/tree-of-toughts1-1024x520.png 1024w, https:\/\/guillaume-guerard.com\/wp-content\/uploads\/2024\/10\/tree-of-toughts1-300x152.png 300w, https:\/\/guillaume-guerard.com\/wp-content\/uploads\/2024\/10\/tree-of-toughts1-768x390.png 768w, https:\/\/guillaume-guerard.com\/wp-content\/uploads\/2024\/10\/tree-of-toughts1-18x9.png 18w, https:\/\/guillaume-guerard.com\/wp-content\/uploads\/2024\/10\/tree-of-toughts1.png 1083w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-54ba01d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"54ba01d\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-713cd5a\" data-id=\"713cd5a\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6609833 elementor-widget elementor-widget-heading\" data-id=\"6609833\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"Exemple\"><\/span>Example<span class=\"ez-toc-section-end\"><\/span><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2f73b93 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2f73b93\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0f7b6fe\" data-id=\"0f7b6fe\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-849e297 elementor-widget elementor-widget-text-editor\" data-id=\"849e297\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The example below illustrates the structure of the prompt.<\/p><p>It is important to know that GPT-3.5 does not get the correct answer for the example below with the Chain of Thought prompt, but it does with the ToT prompt (built into GPT-4).<\/p><p>The prompt is:<\/p><pre><em>Imagine three different experts are answering this <a href=\"https:\/\/guillaume-guerard.com\/en\/cours-de-methodologie\/definir-les-questions-scientifiques\/\">question<\/a>. 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 realizes they&#039;re wrong at any point then they leave. The question is...<\/em><\/pre><p>Which gives:<\/p><pre><em>Expert 1: The ball is in the living room. Expert 2: The ball is in the kitchen. Expert 3: The ball is in the bedroom. Expert 1: Bob carries the cup to the bedroom, so the ball must be in the cup. Expert 2: Oh, I see my mistake. Yes, the ball is in the cup. Expert 3: Agreed, the ball is in the cup in the bedroom. Expert 1: Next, Bob turns the cup upside down in the bedroom. Expert 2: After that, Bob walks to the garden and puts the cup down. Expert 3: Therefore, the ball must have fallen out of the cup when Bob turned it upside down in the bedroom. So, the ball is in the bedroom, not in the cup anymore. Expert 1: Oh, you&#039;re right. I made a mistake. The ball is in the bedroom, not in the cup. Expert 2: Agreed, the ball is in the bedroom. Expert 3: Bob then walks to the garage, so the ball remains in the bedroom. It is not in the garden or the garage. Expert 1: Absolutely, the ball is still in the bedroom. Expert 2: Yes, the ball hasn&#039;t moved from the bedroom. Expert 3: Therefore, the ball is in the bedroom, not in the garden or the garage.<\/em><strong><em>\nAll three experts agree that the ball is in the bedroom.<\/em><\/strong><\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Home Data Science Tree of Thoughts, creating a path tree The \u201ctree of thought\u201d incentive technique (Tree \u2026 <\/p>","protected":false},"author":1,"featured_media":0,"parent":47,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"elementor_header_footer","meta":{"footnotes":""},"class_list":["post-1645","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/pages\/1645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/comments?post=1645"}],"version-history":[{"count":7,"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/pages\/1645\/revisions"}],"predecessor-version":[{"id":1657,"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/pages\/1645\/revisions\/1657"}],"up":[{"embeddable":true,"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/pages\/47"}],"wp:attachment":[{"href":"https:\/\/guillaume-guerard.com\/en\/wp-json\/wp\/v2\/media?parent=1645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}