You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<summary>Note: https://github.com/kyegomez/tree-of-thoughts is NOT the correct implementation to replicate paper results. </summary>
6
-
7
-
In fact, people have reported that his code [cannot](https://github.com/kyegomez/tree-of-thoughts/issues/52)[properly](https://github.com/kyegomez/tree-of-thoughts/issues/41)[run](https://github.com/kyegomez/tree-of-thoughts/issues/60), and is [probably automatically generated by ChatGPT](fake.png), and [kyegomez has done so for other popular ML methods](https://twitter.com/qbitium/status/1663954096741814272), while intentionally refusing to link to official implementations for his own interests (see https://github.com/kyegomez/tree-of-thoughts/issues/54, https://github.com/kyegomez/tree-of-thoughts/issues/55, https://github.com/kyegomez/tree-of-thoughts/issues/56).
5
+
<summary>Note: https://github.com/kyegomez/tree-of-thoughts CANNOT replicate paper results. </summary>
6
+
7
+
In fact, people have reported that his code [cannot](https://github.com/kyegomez/tree-of-thoughts/issues/52)[properly](https://github.com/kyegomez/tree-of-thoughts/issues/41)[run](https://github.com/kyegomez/tree-of-thoughts/issues/60), and is [probably automatically generated by ChatGPT](pics/fake.png), and [kyegomez has done so for other popular ML methods](https://twitter.com/qbitium/status/1663954096741814272), while intentionally refusing to link to official implementations for his own interests (see https://github.com/kyegomez/tree-of-thoughts/issues/54, https://github.com/kyegomez/tree-of-thoughts/issues/55, https://github.com/kyegomez/tree-of-thoughts/issues/56).
8
8
Unfortunately, Google/Github searches go to kyegomez's malicious repo by default as it has more stars. **Please DE-STAR his repo and STAR this to help other people avoid being misled, thanks!**
9
9
</details>
10
10
11
11
12
+

12
13
14
+
Official implementation for paper [Tree of Thoughts: Deliberate Problem Solving with Large Language Models](https://arxiv.org/abs/2305.10601) with code, prompts, model outputs.
15
+
Also check [its tweet thread](https://twitter.com/ShunyuYao12/status/1659357547474681857) in 1min.
13
16
14
17
15
-

16
18
17
-
Official implementation for paper [Tree of Thoughts: Deliberate Problem Solving with Large Language Models](https://arxiv.org/abs/2305.10601) with code, prompts, model outputs.
18
-
Also check [its tweet thread](https://twitter.com/ShunyuYao12/status/1659357547474681857) in 1min.
19
19
20
20
21
-
Please cite the paper and star this repo if you use ToT and find it interesting/useful. Thanks!
22
21
23
-
```bibtex
24
-
@misc{yao2023tree,
25
-
title={{Tree of Thoughts}: Deliberate Problem Solving with Large Language Models},
26
-
author={Shunyu Yao and Dian Yu and Jeffrey Zhao and Izhak Shafran and Thomas L. Griffiths and Yuan Cao and Karthik Narasimhan},
27
-
year={2023},
28
-
eprint={2305.10601},
29
-
archivePrefix={arXiv},
30
-
primaryClass={cs.CL}
31
-
}
22
+
## Setup
23
+
- Set up OpenAI API key and store in environment variable ``OPENAI_API_KEY`` (see [here](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety)).
24
+
25
+
- Install dependencies and `tot` package (PyPI package coming soon):
The 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):
36
+
```python
37
+
import argparse
38
+
from tot.methods.bfs import solve
39
+
from tot.tasks.game24 import Game24Task
35
40
36
-
## Setup
37
-
You need to first have an OpenAI API key and store it in the environment variable ``OPENAI_API_KEY`` (see [here](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety)). If you use custom base url, set it by environment variable ``OPENAI_API_BASE`` (e.g. https://api.openai.com/v1).
And the output would be something like (note it's not deterministic, and sometimes the output can be wrong):
49
+
```
50
+
10 - 4 = 6 (left: 5 6 6)
51
+
5 * 6 = 30 (left: 6 30)
52
+
30 - 6 = 24 (left: 24)
53
+
Answer: (5 * (10 - 4)) - 6 = 24
54
+
```
41
55
42
-
## Experiments
56
+
## Paper Experiments
43
57
44
58
Run experiments via ``sh scripts/{game24, text, crosswords}/{standard_sampling, cot_sampling, bfs}.sh``, except in crosswords we use a DFS algorithm for ToT, which can be run via ``scripts/crosswords/search_crosswords-dfs.ipynb``.
45
59
@@ -55,13 +69,24 @@ The very simple ``run.py`` implements the ToT + BFS algorithm, as well as the na
55
69
56
70
57
71
58
-
## Trajectories
72
+
## Paper Trajectories
59
73
``logs/`` contains all the trajectories from the paper's experiments, except for ``logs/game24/gpt-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.
60
74
75
+
## How to Add A New Task
76
+
Setting up a new task is easy, and mainly involves two steps.
77
+
* Set up a new task class in ``tot/tasks/`` and task files in ``tot/data/``. See ``tot/tasks/game24.py`` for an example. Add the task to ``tot/tasks/__init__.py``.
78
+
* Set up task-specific prompts in ``tot/prompts/``. See ``tot/prompts/game24.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.
61
79
80
+
## Citations
81
+
Please cite the paper and star this repo if you use ToT and find it interesting/useful, thanks! Feel free to contact shunyuyao.cs@gmail.com or open an issue if you have any questions.
62
82
63
-
## Questions
64
-
Feel free to contact shunyuyao.cs@gmail.com or open an issue if you have any questions.
65
-
66
-
67
-
83
+
```bibtex
84
+
@misc{yao2023tree,
85
+
title={{Tree of Thoughts}: Deliberate Problem Solving with Large Language Models},
86
+
author={Shunyu Yao and Dian Yu and Jeffrey Zhao and Izhak Shafran and Thomas L. Griffiths and Yuan Cao and Karthik Narasimhan},
0 commit comments