whatisgithub

What is tree-of-thoughts?

kyegomez/tree-of-thoughts — explained in plain English

Analysis updated 2026-06-26

4,575PythonAudience · researcherComplexity · 3/5LicenseSetup · easy

In one sentence

Tree of Thoughts is a Python package that makes AI reason better by exploring many lines of thinking at once, scoring them, and focusing on the most promising path, like a decision tree for thought.

Mindmap

mindmap
  root((tree-of-thoughts))
    What it does
      Multi-path AI reasoning
      Branch and prune search
      Better accuracy
    How to use
      Python package
      Paste-in prompts
      OpenAI API
    Core objects
      TotAgent
      ToTDFSAgent
    Use cases
      Math puzzles
      Complex reasoning
      Research experiments
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Solve complex reasoning problems (like math puzzles) more accurately by having AI explore multiple solution paths.

USE CASE 2

Improve AI answer quality on hard questions without writing complex code, just paste a prompt template into ChatGPT.

USE CASE 3

Run parallel AI reasoning agents that debate a problem and prune weak arguments automatically.

What is it built with?

PythonOpenAI API

How does it compare?

kyegomez/tree-of-thoughtshuggingface/autotrain-advancedpythonguis/pythonguis-examples
Stars4,5754,5744,573
LanguagePythonPythonPython
Setup difficultyeasymoderateeasy
Complexity3/52/52/5
Audienceresearcherdatadeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Requires an OpenAI API key set in an environment file before running any reasoning agents.

Apache 2.0, use freely for any purpose including commercial, with attribution, no warranty.

So what is it?

Tree of Thoughts is a Python package that implements a reasoning technique for large language models developed by researchers at Princeton University and Google DeepMind. The idea is that instead of asking an AI to answer a question in one straight pass, you have it generate and evaluate multiple chains of reasoning simultaneously, like a tree with many branches. The system scores each branch and prunes weak ones, focusing effort on the most promising lines of thought. The repository's description claims this improves reasoning accuracy by up to 70%. To use it, you install the package with pip and provide an OpenAI API key through an environment file. The core objects are TotAgent, which manages the language model calls, and ToTDFSAgent, which runs a depth-first search through the reasoning tree. You set parameters for how strictly to prune low-quality branches, how many reasoning agents to run in parallel, and how many loops to allow. The README shows an example solving a classic puzzle: combine four numbers with basic arithmetic to reach 24. For people who do not want to write code, the README also lists plain prompt templates you can paste into any chat interface. These prompts instruct the AI to behave as three experts debating a problem step by step, which approximates the tree-of-thoughts approach without any programming. The project is an independent open-source implementation based on the original academic paper. The README notes it is still in progress: breadth-first search and Monte Carlo search variants are listed as to-do items, and a visualization feature for the reasoning tree is also planned. The license is Apache 2.0.

Copy-paste prompts

Prompt 1
Using the tree-of-thoughts Python package, write code that solves a logic puzzle by setting up TotAgent with my OpenAI key and running ToTDFSAgent on this problem: [describe your problem]
Prompt 2
Show me the ready-made 'three experts debating' prompt template from tree-of-thoughts that I can paste into ChatGPT to get better reasoning without any code.
Prompt 3
I want to use tree-of-thoughts to answer a multi-step business strategy question. How do I configure the pruning threshold and number of parallel agents?
Prompt 4
Explain how tree-of-thoughts differs from plain chain-of-thought prompting and when I should use each approach.

Frequently asked questions

What is tree-of-thoughts?

Tree of Thoughts is a Python package that makes AI reason better by exploring many lines of thinking at once, scoring them, and focusing on the most promising path, like a decision tree for thought.

What language is tree-of-thoughts written in?

Mainly Python. The stack also includes Python, OpenAI API.

What license does tree-of-thoughts use?

Apache 2.0, use freely for any purpose including commercial, with attribution, no warranty.

How hard is tree-of-thoughts to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is tree-of-thoughts for?

Mainly researcher.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.