[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-71133":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},71133,"tree-of-thought-llm","princeton-nlp\u002Ftree-of-thought-llm","princeton-nlp","[NeurIPS 2023] Tree of Thoughts: Deliberate Problem Solving with Large Language Models","https:\u002F\u002Farxiv.org\u002Fabs\u002F2305.10601",null,"Python",5988,617,119,7,0,3,18,44,9,83.77,"MIT License",false,"master",true,[27,28,29,30,31],"large-language-models","llm","prompting","tree-of-thoughts","tree-search","2026-06-12 04:00:59","# Official Repo of Tree of Thoughts (ToT)\n\n\u003Cp>\n    \u003Ca href=\"https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Ftree-of-thoughts-llm\">\n        \u003Cimg src=\"https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Ftree-of-thoughts-llm.svg\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fwww.python.org\u002F\">\n        \u003Cimg alt=\"Build\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3.7+-1f425f.svg?color=purple\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fcopyright.princeton.edu\u002Fpolicy\">\n        \u003Cimg alt=\"License\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-blue\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fzenodo.org\u002Fbadge\u002Flatestdoi\u002F642099326\">\n        \u003Cimg src=\"https:\u002F\u002Fzenodo.org\u002Fbadge\u002F642099326.svg\">\n    \u003C\u002Fa>\n\u003C\u002Fp>\n\n![teaser](pics\u002Fteaser.png)\n\nOfficial implementation for paper [Tree of Thoughts: Deliberate Problem Solving with Large Language Models](https:\u002F\u002Farxiv.org\u002Fabs\u002F2305.10601) with code, prompts, model outputs.\nAlso check [its tweet thread](https:\u002F\u002Ftwitter.com\u002FShunyuYao12\u002Fstatus\u002F1659357547474681857) in 1min.\n\n\n\n\n\n## Setup\n1. Set up OpenAI API key and store in environment variable ``OPENAI_API_KEY`` (see [here](https:\u002F\u002Fhelp.openai.com\u002Fen\u002Farticles\u002F5112595-best-practices-for-api-key-safety)). \n\n2. Install `tot` package in two ways:\n- Option 1: Install from PyPI\n```bash\npip install tree-of-thoughts-llm\n```\n- Option 2: Install from source\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fprinceton-nlp\u002Ftree-of-thought-llm\ncd tree-of-thought-llm\npip install -r requirements.txt\npip install -e .  # install `tot` package\n```\n\n\n## Quick Start\nThe following minimal script will attempt to solve the game of 24 with `4 5 6 10` (might be a bit slow as it's using GPT-4):\n```python\nimport argparse\nfrom tot.methods.bfs import solve\nfrom tot.tasks.game24 import Game24Task\n\nargs = 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)\n\ntask = Game24Task()\nys, infos = solve(args, task, 900)\nprint(ys[0])\n```\n\nAnd the output would be something like (note it's not deterministic, and sometimes the output can be wrong):\n```\n10 - 4 = 6 (left: 5 6 6)\n5 * 6 = 30 (left: 6 30)\n30 - 6 = 24 (left: 24)\nAnswer: (5 * (10 - 4)) - 6 = 24\n```\n\n## Paper Experiments\n\nRun experiments via ``sh scripts\u002F{game24, text, crosswords}\u002F{standard_sampling, cot_sampling, bfs}.sh``, except in crosswords we use a DFS algorithm for ToT, which can be run via ``scripts\u002Fcrosswords\u002Fsearch_crosswords-dfs.ipynb``.\n\nThe very simple ``run.py`` implements the ToT + BFS algorithm, as well as the naive IO\u002FCoT sampling. Some key arguments:\n\n- ``--naive_run``: if True, run naive IO\u002FCoT sampling instead of ToT + BFS.\n-  ``--prompt_sample`` (choices=[``standard``, ``cot``]): sampling prompt\n- ``--method_generate`` (choices=[``sample``, ``propose``]): thought generator, whether to sample independent thoughts (used in Creative Writing) or propose sequential thoughts (used in Game of 24)\n- ``--method_evaluate`` (choices=[``value``, ``vote``]): state evaluator, whether to use the value states independently (used in Game of 24) or vote on states together (used in Creative Writing)\n- ``--n_generate_sample``: number of times to prompt for thought generation\n- ``--n_evaluate_sample``: number of times to prompt for state evaluation\n- ``--n_select_sample``: number of states to keep from each step (i.e. ``b`` in the paper's ToT + BFS algorithm)\n\n\n\n## Paper Trajectories\n``logs\u002F`` contains all the trajectories from the paper's experiments, except for ``logs\u002Fgame24\u002Fgpt-4_0.7_propose1_value3_greedy5_start900_end1000.json`` which was reproduced after the paper (as the original experiment was done in a notebook) and achieved a 69\\% score instead of the original 74\\% score due to randomness in GPT decoding. We hope to aggregate multiple runs in the future to account for sampling randomness and update the paper, but this shouldn't affect the main conclusions of the paper.\n\n## How to Add A New Task\nSetting up a new task is easy, and mainly involves two steps.\n* Set up a new task class in ``tot\u002Ftasks\u002F`` and task files in ``tot\u002Fdata\u002F``. See ``tot\u002Ftasks\u002Fgame24.py`` for an example. Add the task to ``tot\u002Ftasks\u002F__init__.py``.\n* Set up task-specific prompts in ``tot\u002Fprompts\u002F``. See ``tot\u002Fprompts\u002Fgame24.py`` for an example. Depending on the nature of the task, choose ``--method_generate`` (choices=[``sample``, ``propose``]) and ``--method_evaluate`` (choices=[``value``, ``vote``]) and their corresponding prompts. \n\n## Citations\nPlease cite the paper and star this repo if you use ToT and find it interesting\u002Fuseful, thanks! Feel free to contact shunyuyao.cs@gmail.com or open an issue if you have any questions.\n\n```bibtex\n@misc{yao2023tree,\n      title={{Tree of Thoughts}: Deliberate Problem Solving with Large Language Models}, \n      author={Shunyu Yao and Dian Yu and Jeffrey Zhao and Izhak Shafran and Thomas L. Griffiths and Yuan Cao and Karthik Narasimhan},\n      year={2023},\n      eprint={2305.10601},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n","Tree of Thoughts (ToT) 是一个利用大型语言模型进行深思熟虑问题解决的研究项目。其核心功能包括通过树搜索算法（如广度优先搜索BFS）来生成、评估和选择解题思路，支持多种任务类型，如24点游戏、文本创作等。技术特点上，ToT 提供了灵活的参数配置选项，允许用户自定义思考生成方式（独立或序列）、评估策略（价值或投票）及选择方法。此外，该项目还支持从PyPI直接安装或从源代码构建，并且需要设置OpenAI API密钥以调用GPT-4等模型。适合于研究者探索如何结合大模型与结构化搜索方法来提高复杂问题解决能力的应用场景中使用。",2,"2026-06-11 03:36:03","high_star"]