百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

tree-of-thought-llm

> AI 编程
开源

[NeurIPS 2023] Tree of Thoughts:利用大型语言模型进行深思熟虑的问题求解

6.0K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

[NeurIPS 2023] Tree of Thoughts:利用大型语言模型进行深思熟虑的问题求解

Tree of Thoughts (ToT) 官方仓库

</a>
<a href="https://www.python.org/">
    
</a>
<a href="https://copyright.princeton.edu/policy">
    
</a>
<a href="https://zenodo.org/badge/latestdoi/642099326">
    
</a>

论文 Tree of Thoughts: Deliberate Problem Solving with Large Language Models 的官方实现,包含代码、提示词和模型输出。 也可以在 1 分钟内查看其推文串。

设置

  1. 设置 OpenAI API 密钥并存储在环境变量 OPENAI_API_KEY 中(参见这里)。

  2. 通过两种方式安装 tot 包:

  • 方式 1:从 PyPI 安装
bash
pip install tree-of-thoughts-llm
  • 方式 2:从源码安装
bash
git clone https://github.com/princeton-nlp/tree-of-thought-llm
cd tree-of-thought-llm
pip install -r requirements.txt
pip install -e .  # install `tot` package

快速开始

以下最小脚本将尝试用 4 5 6 10 求解 24 点游戏(由于使用 GPT-4,可能会稍慢):

python
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])

输出结果大致如下(注意其并非确定性的,有时输出可能是错误的):

10 - 4 = 6 (left: 5 6 6)
5 * 6 = 30 (left: 6 30)
30 - 6 = 24 (left: 24)
Answer: (5 * (10 - 4)) - 6 = 24

论文实验

通过 sh scripts/{game24, text, crosswords}/{standard_sampling, cot_sampling, bfs}.sh 运行实验,但在填字游戏(crosswords)中我们对 ToT 使用 DFS 算法,可通过 scripts/crosswords/search_crosswords-dfs.ipynb 运行。

非常简单的 run.py 实现了 To

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonlarge-language-modelsllmpromptingtree-of-thoughts

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.