LATS: Language Agent Tree Search

Research & Resources 💻 Python ⚖️ MIT 🔴 No recent commits
859 stars

LATS (Language Agent Tree Search) is an official implementation of the ICML 2024 paper that unifies reasoning, acting, and planning in language models using Monte Carlo tree search. It solves complex tasks like question answering, programming, and decision-making by exploring multiple reasoning paths. It is for researchers and developers working with LLM agents.

✨ Key features

  • Unifies reasoning, acting, and planning in LLMs
  • Uses Monte Carlo tree search for decision-making
  • Supports HotPotQA, programming, and WebShop tasks
  • Includes prompts and model outputs from the paper
  • Provides scripts to run paper experiments
  • Trajectories for programming experiments included

🎯 Use cases

  • Answering multi-hop questions like HotPotQA
  • Solving programming challenges with iterative refinement
  • Decision-making in interactive environments like WebShop
  • Research on LLM agent search strategies

📦 Installation

🧰 Requirements: Python environment with dependencies from requirements.txt, OpenAI API key, and for WebShop a local WebShop instance.

For HotPotQA:

git clone https://github.com/andyz245/LanguageAgentTreeSearch && cd LanguageAgentTreeSearch/hotpot
pip install -r requirements.txt
export OPENAI_API_KEY=<your key>

For programming:

git clone https://github.com/andyz245/LanguageAgentTreeSearch && cd LanguageAgentTreeSearch/programming
pip install -r requirements.txt
export OPENAI_API_KEY=<your key>

For WebShop:

git clone https://github.com/andyz245/LanguageAgentTreeSearch && cd LanguageAgentTreeSearch/webshop
Install WebShop from source (see README)
pip install -r requirements.txt
export OPENAI_API_KEY=<your key>

🚀 Usage

For HotPotQA:

sh lats.sh

For programming:

sh run_lats.sh

For WebShop:

sh lats.sh

Adjust parameters like --n_generate_sample, --n_evaluate_sample, and --iterations in the scripts.

⚠️ Good to know

The repository is the official implementation for the paper and may not be actively maintained; WebShop logs are not uploaded due to size.

❓ FAQ

What are the main parameters for the scripts?

The scripts accept --n_generate_sample (number of times to prompt during expansion/sampling), --n_evaluate_sample (number of times to prompt for state evaluation), and --iterations (maximum number of trajectories to sample).

How do I get the accuracy from the programming trajectories?

Use get_acc.py with the log path to compute the actual accuracy from the trajectories in programming/root/.

Is there a more general implementation available?

Yes, there are LangChain and LlamaIndex implementations linked in the README for broader AI applications.

What is the citation for LATS?

The paper is cited as: Andy Zhou, Kai Yan, Michal Shlapentokh-Rothman, Haohan Wang, Yu-Xiong Wang. 'Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Models.' 2023. arXiv:2310.04406.

📊 Repository

Stars★ 859
Forks🍴 92
Open issues🐛 8
Last commit🕒 Jul 30, 2024
Created📅 Oct 2023
Language💻 Python
License⚖️ MIT

🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.