Tree of Thoughts (ToT): A Detailed Project Introduction
The "Tree of Thoughts" (ToT) project is an innovative approach designed to tackle complex problem-solving tasks using Large Language Models (LLMs). Developed by a team of researchers, including Shunyu Yao and Karthik Narasimhan, the project aims to enhance the capabilities of AI by employing a systematic method for exploring and evaluating numerous thought pathways, akin to how humans deliberate over multiple potential solutions before reaching a conclusion.
Project Overview
The core idea behind ToT is to integrate structured deliberation into LLMs, enabling them to perform better in areas that require deep reasoning and foresight. The project's framework facilitates the generation and evaluation of multiple "thoughts" or paths, akin to nodes on a tree, which are then refined to derive the most viable solution. This methodology is applied to various problem-solving scenarios, making the AI's approach more nuanced and human-like.
Setup Instructions
To get started with the Tree of Thoughts project, follow these steps:
-
First, ensure you have an OpenAI API key, which should be stored in your environment variable
OPENAI_API_KEY
. This step is crucial for accessing the capabilities of LLMs like GPT-4. -
Install the
tot
package by choosing one of the following methods:- Install from PyPI: Run
pip install tree-of-thoughts-llm
in your command line. - Install from Source:
- Clone the repository:
git clone https://github.com/princeton-nlp/tree-of-thought-llm
- Navigate into the directory:
cd tree-of-thought-llm
- Install requirements:
pip install -r requirements.txt
- Install the package:
pip install -e .
- Clone the repository:
- Install from PyPI: Run
Quick Start Guide
Here's a brief example using the ToT framework to solve a mathematical puzzle known as the "Game of 24." This game requires generating the number 24 using a given set of numbers and basic arithmetic operations:
import argparse
from tot.methods.bfs import solve
from tot.tasks.game24 import Game24Task
args = argparse.Namespace(backend='gpt-4', temperature=0.7, task='game24', naive_run=False, prompt_sample=None, method_generate='propose', method_evaluate='value', method_select='greedy', n_generate_sample=1, n_evaluate_sample=3, n_select_sample=5)
task = Game24Task()
ys, infos = solve(args, task, 900)
print(ys[0])
The output exemplifies a non-deterministic approach, producing different plausible solutions on each run.
Experiments and Paper Contributions
The Tree of Thoughts framework is evaluated through various experiments documented in the paper. To replicate these experiments, scripts are provided for tasks like the Game of 24 and crosswords, among others. Users can explore different sampling methods and implement the BFS algorithm to observe how the model navigates decision trees.
Adding New Tasks
For users interested in extending the framework, new tasks can be added by following these steps:
- Create a task class and data files within
tot/tasks/
andtot/data/
. - Define task-specific prompts in
tot/prompts/
.
Conclusion
The Tree of Thoughts project stands as a significant advancement in AI technology, leveraging complex models to mimic human deliberation and problem-solving processes. It reflects a significant leap towards more intelligent and intuitive AI systems capable of tackling increasingly complex problems.
Citation
If you find the ToT project useful or intersting, please cite it in your work:
@misc{yao2023tree,
title={{Tree of Thoughts}: Deliberate Problem Solving with Large Language Models},
author={Shunyu Yao and Dian Yu and Jeffrey Zhao and Izhak Shafran and Thomas L. Griffiths and Yuan Cao and Karthik Narasimhan},
year={2023},
eprint={2305.10601},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
The Tree of Thoughts project invites AI enthusiasts and researchers to explore new dimensions in problem-solving strategies, promising an exciting avenue for future developments in artificial intelligence.