├── aot ├── __init__.py ├── openai.py └── main.py ├── aot.png ├── agorabanner.png ├── prompts ├── 1.txt └── 2.txt ├── LICENSE ├── pyproject.toml ├── examples.py ├── neural_search_example.py ├── .gitignore ├── README.md ├── thought_cache_error.json └── openai.logs /aot/__init__.py: -------------------------------------------------------------------------------- 1 | from aot.main import AoT 2 | -------------------------------------------------------------------------------- /aot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyegomez/Algorithm-Of-Thoughts/HEAD/aot.png -------------------------------------------------------------------------------- /agorabanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyegomez/Algorithm-Of-Thoughts/HEAD/agorabanner.png -------------------------------------------------------------------------------- /prompts/1.txt: -------------------------------------------------------------------------------- 1 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 2 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 3 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 4 | and evaluates potential subsequent steps to either progress 5 | towards a solution or retrace to another viable subtree then be very thorough 6 | and think atomically then provide solutions for those subtasks, 7 | then return the definitive end result and then summarize it. 8 | 9 | And most importantly, do not give up, all objectives have solutions! 10 | 11 | 12 | ########## OBJECTIVE 13 | ENTER IN YOUR TASK 14 | ############## 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Eternal Reclaimer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["poetry-core>=1.0.0"] 3 | build-backend = "poetry.core.masonry.api" 4 | 5 | [tool.poetry] 6 | name = "aot-x" 7 | version = "1.5.3" 8 | description = "Algorithm of thoughts - Pytorch" 9 | license = "MIT" 10 | authors = ["Kye Gomez "] 11 | homepage = "https://github.com/kyegomez/Algorithm-Of-Thoughts" 12 | documentation = "" # Add this if you have documentation. 13 | readme = "README.md" # Assuming you have a README.md 14 | repository = "https://github.com/kyegomez/Algorithm-Of-Thoughts" 15 | keywords = ["artificial intelligence", "deep learning", "optimizers", "Prompt Engineering"] 16 | classifiers = [ 17 | "Development Status :: 4 - Beta", 18 | "Intended Audience :: Developers", 19 | "Topic :: Scientific/Engineering :: Artificial Intelligence", 20 | "License :: OSI Approved :: MIT License", 21 | "Programming Language :: Python :: 3.6" 22 | ] 23 | packages = [ 24 | { include = "aot" }, 25 | { include = "aot/**/*.py" }, 26 | ] 27 | 28 | 29 | [tool.poetry.dependencies] 30 | python = "^3.6" 31 | swarms = "*" 32 | 33 | [tool.poetry.dev-dependencies] 34 | # Add development dependencies here -------------------------------------------------------------------------------- /examples.py: -------------------------------------------------------------------------------- 1 | from aot.main import AoT 2 | 3 | task = """ 4 | 5 | 6 | PROMPT 7 | ################### 8 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 9 | considering the next steps, do not choose operations that will result in a 10 | negative or fractional number. In order to help with the calculations, the 11 | numbers in the parenthesis represent the numbers that are left after the 12 | operations and they are in descending order. 13 | Another thing we do is when there are only two numbers left in the parenthesis, we 14 | check whether we can arrive at 24 only by using basic arithmetic operations 15 | (+ - * /). Some examples regarding this idea: 16 | (21 2) no 17 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 18 | to 24. 19 | (30 6) 30 - 6 = 24 yes 20 | (8 3) 8 * 3 = 24 yes 21 | (12 8) no 22 | (48 2) 48 / 2 = 24 yes 23 | Most importantly, do not give up, all the numbers that will be given has indeed a 24 | solution. 25 | 26 | 14 8 8 2 27 | 28 | OBJECTIVE 29 | ######### 30 | 5 10 5 2 31 | 32 | 33 | ################### 34 | """ 35 | 36 | 37 | dfs = AoT( 38 | num_thoughts=2, 39 | max_steps=10, 40 | value_threshold=0.8, 41 | initial_prompt=task, 42 | openai_api_key="", 43 | ) 44 | 45 | result = dfs.solve() 46 | print(result) 47 | -------------------------------------------------------------------------------- /prompts/2.txt: -------------------------------------------------------------------------------- 1 | To accomplish the task, we need to decompose it into explicit subtasks using a search process. The problem set we will be working with is '8 6 4 4'. Here is a step-by-step guide to solving this problem: 2 | 3 | First operations: 4 | 5 | Start the search process by choosing the first operation to explore. 6 | Highlight this operation as '1'. 7 | Subtask 1: 8 | 9 | Decompose the task by breaking it down into subtasks. 10 | Highlight this subtask as '2'. 11 | Subtask 2: 12 | 13 | Decompose subtask 1 further into atomic subtasks. 14 | Highlight this subtask as '3'. 15 | Atomic subtask 1: 16 | 17 | Analyze the first atomic subtask. 18 | Provide a solution for this atomic subtask. 19 | Atomic subtask 2: 20 | 21 | Analyze the second atomic subtask. 22 | Provide a solution for this atomic subtask. 23 | Atomic subtask 3: 24 | 25 | Analyze the third atomic subtask. 26 | Provide a solution for this atomic subtask. 27 | Atomic subtask 4: 28 | 29 | Analyze the fourth atomic subtask. 30 | Provide a solution for this atomic subtask. 31 | Subtask 3: 32 | 33 | Combine the solutions of the atomic subtasks to solve subtask 2. 34 | Highlight this subtask as '4'. 35 | Subtask 4: 36 | 37 | Analyze the fourth subtask. 38 | Provide a solution for this subtask. 39 | Subtask 5: 40 | 41 | Analyze the fifth subtask. 42 | Provide a solution for this subtask. 43 | Subtask 6: 44 | 45 | Analyze the sixth subtask. 46 | Provide a solution for this subtask. 47 | Subtask 7: 48 | 49 | Analyze the seventh subtask. 50 | Provide a solution for this subtask. 51 | Subtask 8: 52 | 53 | Analyze the eighth subtask. 54 | Provide a solution for this subtask. 55 | End result: After solving all the subtasks, consolidate the solutions to obtain the definitive end result. 56 | 57 | Summary: To summarize, we decomposed the initial task into explicit subtasks using a search process with markers '1' to '3'. We then analyzed and provided solutions for each subtask atomically. Finally, we combined the subtask solutions to obtain the definitive end result. 58 | 59 | 60 | ################ -------------------------------------------------------------------------------- /neural_search_example.py: -------------------------------------------------------------------------------- 1 | from aot.main import AoT 2 | 3 | 4 | task = "Create GPT-2" 5 | 6 | 7 | system = f""" 8 | 9 | You are Quoc V. Le, a computer scientist and artificial intelligence researcher who is 10 | widely regarded as one of the leading experts in deep learning and neural network architecture search. 11 | Your work in this area has focused on developing efficient algorithms for searching the 12 | space of possible neural network architectures, with the goal of finding architectures 13 | that perform well on a given task while minimizing the computational cost of training and inference. 14 | 15 | You are an expert in the field of neural architecture search. 16 | Your task is to assist me in selecting the best operations to design a neural network 17 | block using the available operations. 18 | The objective is to maximize the model's performance 19 | 20 | The 5 available operations are as follows: 21 | 0: Zeroize() # This operation simply outputs a tensor of zeros regardless of the input, which breaks the gradient flow between two nodes. 22 | 1: nn.Identity() # Skip Connection. 23 | 2: ReLUConvBN(channels, channels, kernal_size=1, stride=1, padding=0) # The input channels and output channels are the same. 24 | 3: ReLUConvBN(channels, channels, kernal_size=3, stride=1, padding=1) # The input channels and output channels are the same. 25 | 4: nn.AvgPool2d(kernel_size=3, stride=1, padding=1) # This operation does not change the spatial resolution. 26 | 27 | The neural network block is defined by 6 operations (i.e., op_list = [op0, op1, op2, op3, op4, op5]), which represent the operations executed between various stages of the block. This block comprises 4 stages, labeled as s0, s1, s2, and s3, each corresponding to distinct feature maps in the neural network. 28 | 29 | s0 serves as the input feature map for this block. 30 | s1 will be calculated by s1 = op0(s0). 31 | s2 will be calculated by s2 = op1(s0) + op2(s1). 32 | s3 will be calculated by s3 = op3(s0) + op4(s1) + op5(s2). Note that s3 becomes the output for this block and serves as the input for the subsequent block. 33 | 34 | Then the implementation of the block will be: 35 | class Block(nn.Module): 36 | def __init__(self, channels): 37 | super(Block, self).__init__() 38 | self.op0 = op_id_list[0] 39 | self.op1 = op_id_list[1] 40 | self.op2 = op_id_list[2] 41 | self.op3 = op_id_list[3] 42 | self.op4 = op_id_list[4] 43 | self.op5 = op_id_list[5] 44 | 45 | def forward(self, s0): 46 | s1 = self.op0(s0) 47 | s2 = self.op1(s0) + self.op2(s1) 48 | s3 = self.op3(s0) + self.op4(s1) + self.op5(s2) 49 | return s3 50 | 51 | Let's break this down step by step: 52 | 53 | First, please analyze the 5 available operations. 54 | 55 | Next, please consider the gradient flow based on the Block class implementation. For example, how the gradient from the later stage affects the earlier stage. 56 | 57 | Now, answer the question - how we can design a high-performance block using the available operations? 58 | 59 | Based the analysis, your task is to propose a block design with the given operations that prioritizes performance, without considering factors such as size and complexity. 60 | 61 | After you suggest a design, I will test its actual performance and provide you with feedback. Based on the results of previous experiments, we can collaborate to iterate and improve the design. Please avoid suggesting the same design again during this iterative process. 62 | 63 | {task} 64 | 65 | """ 66 | dfs = AoT( 67 | num_thoughts=2, 68 | max_steps=10, 69 | value_threshold=1, 70 | initial_prompt=system, 71 | # openai_api_key="ENETER IN YOUR API KEY", 72 | ) 73 | 74 | result = dfs.solve() 75 | print(result) 76 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | .aider* 162 | openai.logs 163 | .gitignore 164 | .git -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Multi-Modality](agorabanner.png)](https://discord.gg/qUtxnK2NMf) 2 | 3 | # Algorithm-Of-Thoughts 4 | ![Discord](https://img.shields.io/discord/999382051935506503) 5 | [![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts)](https://twitter.com/intent/tweet?text=Check%20out%20this%20amazing%20project%20on%20improving%20AI%20reasoning%20-%20Algorithm%20of%20Thoughts!%20https://github.com/kyegomez/Algorithm-Of-Thoughts) 6 | [![LinkedIn](https://img.shields.io/badge/Share-LinkedIn-blue?style=social&logo=linkedin)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts) 7 | [![Facebook](https://img.shields.io/badge/Share-Facebook-blue?style=social&logo=facebook)](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts) 8 | [![Reddit](https://img.shields.io/badge/Share-Reddit-orange?style=social&logo=reddit)](https://www.reddit.com/submit?url=https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts&title=Check%20out%20this%20amazing%20project%20on%20improving%20AI%20reasoning%20-%20Algorithm%20of%20Thoughts%21) 9 | [![Hacker News](https://img.shields.io/badge/Share-Hacker%20News-orange?style=social&logo=y-combinator)](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts&t=Check%20out%20this%20amazing%20project%20on%20improving%20AI%20reasoning%20-%20Algorithm%20of%20Thoughts%21) 10 | [![Pinterest](https://img.shields.io/badge/Share-Pinterest-red?style=social&logo=pinterest)](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts&media=https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts%2Fraw%2Fmain%2FAlgorithm-Of-Thoughts.jpeg&description=Check%20out%20this%20amazing%20project%20on%20improving%20AI%20reasoning%20-%20Algorithm%20of%20Thoughts%21) 11 | [![WhatsApp](https://img.shields.io/badge/Share-WhatsApp-green?style=social&logo=whatsapp)](https://api.whatsapp.com/send?text=Check%20out%20this%20amazing%20project%20on%20improving%20AI%20reasoning%20-%20Algorithm%20of%20Thoughts%21%20https%3A%2F%2Fgithub.com%2Fkyegomez%2FAlgorithm-Of-Thoughts) 12 | 13 | 14 | ![AOT BANNER](aot.png) 15 | The open source implementation of "Algorithm of Thoughts: Enhancing Exploration of Ideas in Large Language Models" that increases model reasoning by nearly 80% or 10% more than [Tree of thoughts!](https://github.com/kyegomez/Algorithm-Of-Thoughts) 16 | 17 | [Algorithm of Thoughts: Enhancing Exploration of Ideas in Large Language Models](https://arxiv.org/abs/2308.10379) 18 | 19 | # Installation 20 | `pip install aot-x` 21 | 22 | 23 | # Usage 24 | ```python 25 | from aot.main import AoT 26 | 27 | task = """ 28 | 29 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 30 | considering the next steps, do not choose operations that will result in a 31 | negative or fractional number. In order to help with the calculations, the 32 | numbers in the parenthesis represent the numbers that are left after the 33 | operations and they are in descending order. 34 | Another thing we do is when there are only two numbers left in the parenthesis, we 35 | check whether we can arrive at 24 only by using basic arithmetic operations 36 | (+ - * /). Some examples regarding this idea: 37 | (21 2) no 38 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 39 | to 24. 40 | (30 6) 30 - 6 = 24 yes 41 | (8 3) 8 * 3 = 24 yes 42 | (12 8) no 43 | (48 2) 48 / 2 = 24 yes 44 | Most importantly, do not give up, all the numbers that will be given has indeed a 45 | solution. 46 | 47 | 14 8 8 2 48 | 49 | OBJECTIVE 50 | ######### 51 | 5 10 5 2 52 | """ 53 | 54 | 55 | dfs = AoT( 56 | num_thoughts=2, 57 | max_steps=10, 58 | value_threshold=1, 59 | initial_prompt=task, 60 | openai_api_key="ENETER IN YOUR API KEY" 61 | ) 62 | 63 | result = dfs.solve() 64 | print(result) 65 | ``` 66 | 67 | # Todo 68 | - [ ] All thoughts over 0.5 are added to cache or longterm vectorstore 69 | - [x] DFS search similiar to Algorithm of thoughts 70 | - [x] Propose solutions function 71 | - [x] Backtrack to nearest successful states 72 | - [x] Implement evaluation strategy similiar to tot with [0.0, 1.0] 73 | - [x] Working demo: Conducts search then backtracks through states, provide visuals green text 74 | - [ ] Streamlit demo 75 | 76 | 77 | ## Citation 78 | ``` 79 | @misc{2308.10379, 80 | Author = {Bilgehan Sel and Ahmad Al-Tawaha and Vanshaj Khattar and Lu Wang and Ruoxi Jia and Ming Jin}, 81 | Title = {Algorithm of Thoughts: Enhancing Exploration of Ideas in Large Language Models}, 82 | Year = {2023}, 83 | ``` -------------------------------------------------------------------------------- /thought_cache_error.json: -------------------------------------------------------------------------------- 1 | {"accepted": {"To obtain 24 using the numbers 14, 8, 8, and 2, we can decompose the task into the following subtasks:\n\n1. Explore all possible combinations of the given numbers.\n2. Apply basic arithmetic operations to each combination to evaluate if it can result in 24.\n3. If a combination results in 24, return it as the solution.\n4. If no combination results in 24, continue exploring other combinations.\n\nSubtask 1: Explore all possible combinations of the given numbers.\n1. Combine the numbers in all possible orders:\n - 14, 8, 8, 2\n - 14, 8, 2, 8\n - 14, 2, 8, 8\n - 8, 14, 8, 2\n - 8, 14, 2, 8\n - 8, 8, 14, 2\n - 8, 8, 2, 14\n - 8, 2, 14, 8\n - 8, 2, 8, 14\n - 2, 14, 8, 8\n - 2, 8, 14, 8\n - 2, 8, 8, 14\n\nSubtask 2: Apply basic arithmetic operations to each combination to evaluate if it can result in 24.\n1. For each combination, apply the four basic arithmetic operations (+, -, *, /) to evaluate if it equals 24.\n - 14 + 8 + 8 + 2 = 32\n - 14 + 8 + 2 + 8 = 32\n - 14 + 2 + 8 + 8 = 32\n - 8 + 14 + 8 + 2 = 32": 0.5, "To decompose the task into subtasks, we can follow the following steps:\n\n1. Identify the given numbers: 14, 8, 8, 2\n2. Determine all possible combinations of the given numbers.\n3. For each combination, perform basic arithmetic operations (+, -, *, /) to obtain 24.\n4. Check if any of the combinations result in 24.\n5. If a combination results in 24, return that combination as the solution.\n6. If none of the combinations result in 24, go back to step 2 and try different combinations.\n\nSubtask 1: Identify the given numbers\n- Given numbers: 14, 8, 8, 2\n\nSubtask 2: Determine all possible combinations of the given numbers\n- Possible combinations:\n - 14 8 8 2\n - 14 8 2 8\n - 14 2 8 8\n - 8 14 8 2\n - 8 14 2 8\n - 8 8 14 2\n - 8 8 2 14\n - 8 2 14 8\n - 8 2 8 14\n - 2 14 8 8\n - 2 8 14 8\n - 2 8 8 14\n\nSubtask 3: For each combination, perform basic arithmetic operations to obtain 24\n- Combination: 14 8 8 2\n - 14 + 8 + 8 + 2 = 32 (not equal to 24)\n - 14 + 8 + 8 - 2 = 28 (not equal to 24)\n - 14 + 8 + 8 * 2 = 46 (not equal to 24)\n - 14 +": 0.7}, "pruned": {"To obtain 24 using the numbers 14, 8, 8, and 2, we can decompose the task into the following subtasks:\n\n1. Explore all possible combinations of the given numbers.\n2. Apply basic arithmetic operations to each combination to evaluate if it can result in 24.\n3. If a combination results in 24, return it as the solution.\n4. If no combination results in 24, continue exploring other combinations.\n\nSubtask 1: Explore all possible combinations of the given numbers.\n1. Combine the numbers in all possible orders:\n - 14, 8, 8, 2\n - 14, 8, 2, 8\n - 14, 2, 8, 8\n - 8, 14, 8, 2\n - 8, 14, 2, 8\n - 8, 8, 14, 2\n - 8, 8, 2, 14\n - 8, 2, 14, 8\n - 8, 2, 8, 14\n - 2, 14, 8, 8\n - 2, 8, 14, 8\n - 2, 8, 8, 14\n\nSubtask 2: Apply basic arithmetic operations to each combination to evaluate if it can result in 24.\n1. For each combination, apply the four basic arithmetic operations (+, -, *, /) to evaluate if it equals 24.\n - 14 + 8 + 8 + 2 = 32\n - 14 + 8 + 2 + 8 = 32\n - 14 + 2 + 8 + 8 = 32\n - 8 + 14 + 8 + 2 = 32": 0.5, "To decompose the task into subtasks, we can follow the following steps:\n\n1. Identify the given numbers: 14, 8, 8, 2\n2. Determine all possible combinations of the given numbers.\n3. For each combination, perform basic arithmetic operations (+, -, *, /) to obtain 24.\n4. Check if any of the combinations result in 24.\n5. If a combination results in 24, return that combination as the solution.\n6. If none of the combinations result in 24, go back to step 2 and try different combinations.\n\nSubtask 1: Identify the given numbers\n- Given numbers: 14, 8, 8, 2\n\nSubtask 2: Determine all possible combinations of the given numbers\n- Possible combinations:\n - 14 8 8 2\n - 14 8 2 8\n - 14 2 8 8\n - 8 14 8 2\n - 8 14 2 8\n - 8 8 14 2\n - 8 8 2 14\n - 8 2 14 8\n - 8 2 8 14\n - 2 14 8 8\n - 2 8 14 8\n - 2 8 8 14\n\nSubtask 3: For each combination, perform basic arithmetic operations to obtain 24\n- Combination: 14 8 8 2\n - 14 + 8 + 8 + 2 = 32 (not equal to 24)\n - 14 + 8 + 8 - 2 = 28 (not equal to 24)\n - 14 + 8 + 8 * 2 = 46 (not equal to 24)\n - 14 +": 0.7}}{"accepted": {"To decompose the task into explicit subtasks, we can follow the steps below:\n\n1. Evaluate the given numbers and determine if any of them can be used directly to obtain 24 without any operations. If so, return the solution.\n\n2. Generate all possible combinations of the given numbers. This can be done by permuting the numbers and grouping them into pairs.\n\n3. For each combination, apply the four basic arithmetic operations (+, -, *, /) to the pair of numbers and evaluate if any of the results equal 24. If so, return the solution.\n\n4. If none of the combinations from step 3 yield a solution, generate all possible combinations of three numbers from the given set.\n\n5. For each combination of three numbers, apply the four basic arithmetic operations to the numbers in all possible orders and evaluate if any of the results equal 24. If so, return the solution.\n\n6. If none of the combinations from step 5 yield a solution, generate all possible combinations of four numbers from the given set.\n\n7. For each combination of four numbers, apply the four basic arithmetic operations to the numbers in all possible orders and evaluate if any of the results equal 24. If so, return the solution.\n\n8. If none of the combinations from step 7 yield a solution, repeat the process with different orders of operations (e.g., changing the order of addition, subtraction, multiplication, and division).\n\n9. If none of the combinations from step 8 yield a solution, return that there is no solution for the given set of numbers.\n\nProspective search steps:\n1. Check if any of the given numbers (14, 8, 8, 2) can be used directly to obtain 24.\n2. Generate all possible combinations of the given numbers: (14, 8), (14, 8), (14, 2), (8, 8), (8, 2), (8, 2).\n": 0.75}, "pruned": {"To decompose the task and find a solution, we can follow these subtasks:\n\n1. Explore all possible combinations of the given numbers (14, 8, 8, 2) to form equations using basic arithmetic operations (+ - * /).\n2. Check if any of the combinations result in 24 without using negative or fractional numbers.\n3. If no combination satisfies the condition in step 2, backtrack to a viable subtree and continue exploring.\n4. Repeat steps 1-3 until all possible combinations have been explored.\n5. Return the definitive end result, which is the equation that equals 24.\n\nNow let's go through the subtasks in detail:\n\n1. Explore all possible combinations of the given numbers (14, 8, 8, 2) to form equations using basic arithmetic operations (+ - * /):\n\n - 14 + 8 + 8 + 2\n - 14 + 8 + 8 - 2\n - 14 + 8 + 8 * 2\n - 14 + 8 + 8 / 2\n - 14 + 8 - 8 + 2\n - 14 + 8 - 8 - 2\n - 14 + 8 - 8 * 2\n - 14 + 8 - 8 / 2\n - 14 + 8 * 8 + 2\n - 14 + 8 * 8 - 2\n - 14 + 8 * 8 * 2\n - 14 + 8 * 8 / 2\n - 14 + 8 / 8 + 2\n - 14 + 8 / 8 - 2\n - 14 + 8 / 8 * 2\n - 14 + 8 / 8 / 2\n - 14 - ": 0.4, "To decompose the task into explicit subtasks, we can follow the steps below:\n\n1. Evaluate the given numbers and determine if any of them can be used directly to obtain 24 without any operations. If so, return the solution.\n\n2. Generate all possible combinations of the given numbers. This can be done by permuting the numbers and grouping them into pairs.\n\n3. For each combination, apply the four basic arithmetic operations (+, -, *, /) to the pair of numbers and evaluate if any of the results equal 24. If so, return the solution.\n\n4. If none of the combinations from step 3 yield a solution, generate all possible combinations of three numbers from the given set.\n\n5. For each combination of three numbers, apply the four basic arithmetic operations to the numbers in all possible orders and evaluate if any of the results equal 24. If so, return the solution.\n\n6. If none of the combinations from step 5 yield a solution, generate all possible combinations of four numbers from the given set.\n\n7. For each combination of four numbers, apply the four basic arithmetic operations to the numbers in all possible orders and evaluate if any of the results equal 24. If so, return the solution.\n\n8. If none of the combinations from step 7 yield a solution, repeat the process with different orders of operations (e.g., changing the order of addition, subtraction, multiplication, and division).\n\n9. If none of the combinations from step 8 yield a solution, return that there is no solution for the given set of numbers.\n\nProspective search steps:\n1. Check if any of the given numbers (14, 8, 8, 2) can be used directly to obtain 24.\n2. Generate all possible combinations of the given numbers: (14, 8), (14, 8), (14, 2), (8, 8), (8, 2), (8, 2).\n": 0.75}} -------------------------------------------------------------------------------- /aot/openai.py: -------------------------------------------------------------------------------- 1 | import os 2 | import openai 3 | import time 4 | 5 | import logging 6 | 7 | logging.basicConfig( 8 | level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" 9 | ) 10 | logger = logging.getLogger(__name__) 11 | 12 | 13 | class OpenAI: 14 | def __init__( 15 | self, 16 | api_key, 17 | strategy="cot", 18 | evaluation_strategy="value", 19 | api_base="", 20 | api_model="", 21 | ): 22 | if api_key == "" or api_key is None: 23 | api_key = os.environ.get("OPENAI_API_KEY", "") 24 | 25 | if api_key == "": 26 | try: 27 | with open(os.path.expanduser("~/some/defined/path"), "r") as f: 28 | api_key = f.read().strip() 29 | except FileNotFoundError: 30 | pass # Handle the exception as you see fit 31 | 32 | if api_key == "": 33 | raise Exception("Please provide OpenAI API key") 34 | else: 35 | openai.api_key = api_key 36 | 37 | if api_base == "" or api_base is None: 38 | api_base = os.environ.get( 39 | "OPENAI_API_BASE", "" 40 | ) # if not set, use the default base path of "https://api.openai.com/v1" 41 | if api_base != "": 42 | # e.g. https://api.openai.com/v1/ or your custom url 43 | openai.api_base = api_base 44 | print(f"Using custom api_base {api_base}") 45 | 46 | if api_model == "" or api_model is None: 47 | api_model = os.environ.get("OPENAI_API_MODEL", "") 48 | if api_model != "": 49 | self.api_model = api_model 50 | else: 51 | self.api_model = "gpt-3.5-turbo" 52 | print(f"Using api_model {self.api_model}") 53 | 54 | self.use_chat_api = "gpt" in self.api_model 55 | self.strategy = strategy 56 | self.evaluation_strategy = evaluation_strategy 57 | 58 | def run(self, prompt, max_tokens, temperature, k=1, stop=None): 59 | while True: 60 | try: 61 | if self.use_chat_api: 62 | messages = [{"role": "user", "content": prompt}] 63 | response = openai.ChatCompletion.create( 64 | model=self.api_model, 65 | messages=messages, 66 | max_tokens=max_tokens, 67 | temperature=temperature, 68 | ) 69 | else: 70 | response = openai.Completion.create( 71 | engine=self.api_model, 72 | prompt=prompt, 73 | n=k, 74 | max_tokens=max_tokens, 75 | stop=stop, 76 | temperature=temperature, 77 | ) 78 | with open("openai.logs", "a") as log_file: 79 | log_file.write( 80 | "\n" + "-----------" + "\n" + "Prompt : " + prompt + "\n" 81 | ) 82 | return response 83 | except openai.error.RateLimitError as e: 84 | sleep_duratoin = os.environ.get("OPENAI_RATE_TIMEOUT", 30) 85 | print( 86 | f"{str(e)}, sleep for {sleep_duratoin}s, set it by env OPENAI_RATE_TIMEOUT" 87 | ) 88 | time.sleep(sleep_duratoin) 89 | 90 | def openai_choice2text_handler(self, choice): 91 | if self.use_chat_api: 92 | text = choice["message"]["content"] 93 | else: 94 | text = choice.text.strip() 95 | return text 96 | 97 | def generate_text(self, prompt, k): 98 | if self.use_chat_api: 99 | thoughts = [] 100 | for _ in range(k): 101 | response = self.run(prompt, 400, 0.5, k) 102 | text = self.openai_choice2text_handler(response.choices[0]) 103 | thoughts += [text] 104 | # print(f'thoughts: {thoughts}') 105 | return thoughts 106 | 107 | else: 108 | response = self.run(prompt, 300, 0.5, k) 109 | thoughts = [ 110 | self.openai_choice2text_handler(choice) for choice in response.choices 111 | ] 112 | return thoughts 113 | 114 | def generate_thoughts(self, state, k, initial_prompt, rejected_solutions=None): 115 | if type(state) == str: 116 | state_text = state 117 | else: 118 | state_text = "\n".join(state) 119 | print("New state generating thought:", state, "\n\n") 120 | prompt = f""" 121 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 122 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 123 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 124 | and evaluates potential subsequent steps to either progress 125 | towards a solution or retrace to another viable subtree then be very thorough 126 | and think atomically then provide solutions for those subtasks, 127 | then return the definitive end result and then summarize it 128 | 129 | 130 | ########## OBJECTIVE 131 | {initial_prompt} 132 | ################### 133 | """ 134 | thoughts = self.generate_text(prompt, k) 135 | # print(f"Generated thoughts: {thoughts}") 136 | return thoughts 137 | 138 | def generate_solution(self, initial_prompt, state, rejected_solutions=None): 139 | try: 140 | if isinstance(state, list): 141 | state_text = "\n".join(state) 142 | else: 143 | state_text = state 144 | 145 | prompt = f""" 146 | Generate a series of solutions to comply with the user's instructions, 147 | you must generate solutions on the basis of determining the most reliable solution in the shortest amount of time, 148 | while taking rejected solutions into account and learning from them. 149 | Considering the reasoning provided:\n\n 150 | ###'{state_text}'\n\n### 151 | Devise the best possible solution for the task: {initial_prompt}, Here are evaluated solutions that were rejected: 152 | ###{rejected_solutions}###, 153 | complete the {initial_prompt} without making the same mistakes you did with the evaluated rejected solutions. Be simple. Be direct. Provide intuitive solutions as soon as you think of them.""" 154 | answer = self.generate_text(prompt, 1) 155 | print(f"Generated Solution Summary {answer}") 156 | return answer 157 | except Exception as e: 158 | logger.error(f"Error in generate_solutions: {e}") 159 | return None 160 | 161 | def evaluate_states(self, states, initial_prompt): 162 | if not states: 163 | return {} 164 | 165 | if self.evaluation_strategy == "value": 166 | state_values = {} 167 | for state in states: 168 | if type(state) == str: 169 | state_text = state 170 | else: 171 | print(f"state: {state}") 172 | state_text = "\n".join(state) 173 | print( 174 | "We receive a state of type", 175 | type(state), 176 | "For state: ", 177 | state, 178 | "\n\n", 179 | ) 180 | prompt = f""" To achieve the following goal: '{initial_prompt}', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1\n 181 | Past solutions:\n\n 182 | {state_text}\n 183 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 184 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1:\n, DO NOT RETURN ANYTHING ELSE 185 | """ 186 | response = self.run(prompt, 10, 1) 187 | try: 188 | value_text = self.openai_choice2text_handler(response.choices[0]) 189 | # print(f'state: {value_text}') 190 | value = float(value_text) 191 | print(f"Evaluated Thought Value: {value}") 192 | except ValueError: 193 | value = 0 194 | state_values[state] = value 195 | return state_values 196 | 197 | else: 198 | raise ValueError("Invalid evaluation strategy. Choose 'value' or 'vote'.") 199 | -------------------------------------------------------------------------------- /aot/main.py: -------------------------------------------------------------------------------- 1 | from aot.openai import OpenAI 2 | import json 3 | import logging 4 | 5 | logging.basicConfig( 6 | level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" 7 | ) 8 | logger = logging.getLogger(__name__) 9 | 10 | 11 | class AoT: 12 | """ 13 | Algorithm of Thoughts 14 | --------------------- 15 | 16 | This class implements the Algorithm of Thoughts (AoT) algorithm. AoT is a 17 | general-purpose algorithm for solving problems. It is inspired by the 18 | human thought process and is based on the idea of generating thoughts and 19 | evaluating them. 20 | 21 | Parameters 22 | ---------- 23 | num_thoughts : int 24 | The number of thoughts to generate at each step of the algorithm. 25 | max_steps : int 26 | The maximum number of steps to run the algorithm for. 27 | value_threshold : float 28 | The minimum value of a thought to be considered valid. 29 | pruning_threshold : float 30 | The minimum value of a thought to be considered for caching. 31 | backtracking_threshold : float 32 | The minimum value of a thought to be considered for backtracking. 33 | initial_prompt : str 34 | The initial prompt to start the algorithm with. 35 | openai_api_key : str 36 | The OpenAI API key to use for the algorithm. 37 | thought_cache : dict 38 | The cache to use for the algorithm. 39 | 40 | Returns 41 | ------- 42 | solution : str 43 | The solution to the problem. 44 | 45 | Examples 46 | -------- 47 | >>> from aot.main import AoT 48 | >>> system = " 49 | ... Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 50 | ... considering the next steps, do not choose operations that will result in a 51 | ... negative or fractional number. In order to help with the calculations, the 52 | ... numbers in the parenthesis represent the numbers that are left after the 53 | ... operations and they are in descending order. 54 | ... Another thing we do is when there are only two numbers left in the parenthesis, we 55 | ... check whether we can arrive at 24 only by using basic arithmetic operations 56 | ... (+ - * /). Some examples regarding this idea: 57 | ... (21 2) no 58 | ... since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 59 | ... to 24. 60 | ... (30 6) 30 - 6 = 24 yes 61 | ... (8 3) 8 * 3 = 24 yes 62 | ... (12 8) no 63 | ... (48 2) 48 / 2 = 24 yes 64 | ... Most importantly, do not give up, all the numbers that will be given has indeed a 65 | ... solution. 66 | ... 67 | ... 14 8 8 2 68 | ... " 69 | >>> dfs = AoT( 70 | ... num_thoughts=2, 71 | ... max_steps=10, 72 | ... value_threshold=1, 73 | ... initial_prompt=system, 74 | ... openai_api_key="", 75 | ... ) 76 | 77 | 78 | """ 79 | 80 | def __init__( 81 | self, 82 | num_thoughts: int = None, 83 | max_steps: int = None, 84 | value_threshold: float = None, 85 | pruning_threshold=0.5, 86 | backtracking_threshold=0.4, 87 | initial_prompt=None, 88 | openai_api_key: str = None, 89 | thought_cache=None, # Set to None here 90 | ): 91 | """Init method for AoT""" 92 | if thought_cache is None: 93 | self.thought_cache = {"accepted": {}, "pruned": {}} 94 | else: 95 | self.thought_cache = thought_cache 96 | self.num_thoughts = num_thoughts 97 | self.max_steps = max_steps 98 | self.value_threshold = value_threshold 99 | self.backtracking_threshold = backtracking_threshold 100 | self.pruning_threshold = pruning_threshold 101 | self.initial_prompt = initial_prompt 102 | self.output = [] 103 | self.openai_api_key = openai_api_key 104 | self.model = OpenAI(api_key=self.openai_api_key) 105 | 106 | def solve(self): 107 | """Solve the problem using AoT prompt and dfs search algorithm""" 108 | try: 109 | # Run DFS 110 | self.dfs(self.initial_prompt, 1) 111 | 112 | # Check if any thoughts were generated 113 | if not self.output: 114 | logger.error("No valid thoughts were generated during DFS") 115 | return None 116 | 117 | # Find the best thought and its value 118 | best_state, best_value = max(self.output, key=lambda x: x[1]) 119 | 120 | # Cache the best thought 121 | self.thought_cache["accepted"][best_state] = best_value 122 | 123 | # Generate the final solution based on the best thought 124 | solution = self.model.generate_solution(self.initial_prompt, best_state) 125 | 126 | # Display and return the solution 127 | print(f"Solution is {solution}") 128 | 129 | # Write cache to JSON file 130 | # Change back to 'w' if you want to overwrite the file 131 | with open("./thought_cache.json", "a") as json_file: 132 | json.dump(self.thought_cache, json_file) 133 | 134 | return solution if solution else best_state 135 | 136 | except Exception as error: 137 | logger.error(f"Error in tot_dfs: {error}") 138 | 139 | # Write cache to JSON file even if an error occurs 140 | # Change back to 'w' if you want to overwrite the file 141 | with open("./thought_cache_error.json", "a") as json_file: 142 | json.dump(self.thought_cache, json_file) 143 | 144 | raise error 145 | 146 | def dfs(self, state, step): 147 | """Depth-first search algorithm""" 148 | if step > self.max_steps: 149 | # Check cache before evaluating 150 | if state in self.thought_cache["accepted"]: 151 | value = self.thought_cache["accepted"][state] 152 | elif state in self.thought_cache["pruned"]: 153 | return 154 | else: 155 | thought, value = self.evaluate_thought(state) 156 | # Cache the evaluated thought 157 | self.thought_cache["accepted"][state] = value 158 | 159 | self.output.append((state, value)) 160 | return 161 | 162 | # Check cache before generating and filtering 163 | if state in self.thought_cache["accepted"]: 164 | thoughts = [state] 165 | elif state in self.thought_cache["pruned"]: 166 | return 167 | else: 168 | thoughts = self.generate_and_filter_thoughts(state) 169 | 170 | for next_state in thoughts: 171 | state_value = self.evaluated_thoughts.get(next_state, 0) 172 | print("Entering DFS with state: ", state, " and step: ", step) 173 | 174 | # Cache pruned thoughts 175 | if state_value <= self.value_threshold: 176 | self.thought_cache["pruned"][next_state] = state_value 177 | continue 178 | 179 | # Proceed with DFS 180 | child = ( 181 | (state, next_state) if isinstance(state, str) else (*state, next_state) 182 | ) 183 | self.dfs(child, step + 1) 184 | 185 | # Backtracking 186 | best_value = max([value for _, value in self.output]) 187 | 188 | if best_value < self.backtracking_threshold: 189 | self.output.pop() 190 | continue 191 | 192 | def generate_and_filter_thoughts(self, state): 193 | """Generate and filter thoughts""" 194 | # Check if thoughts for this state are cached 195 | if state in self.thought_cache["accepted"]: 196 | print(f"Retrieved accepted thoughts from cache for state: {state}") 197 | return [state] 198 | elif state in self.thought_cache["pruned"]: 199 | print(f"Retrieved pruned thoughts from cache for state: {state}") 200 | return [] 201 | 202 | # Else generate new thoughts 203 | thoughts = self.model.generate_thoughts( 204 | state, self.num_thoughts, self.initial_prompt 205 | ) 206 | 207 | self.evaluated_thoughts = self.model.evaluate_states( 208 | thoughts, self.initial_prompt 209 | ) 210 | 211 | filtered_thoughts = [ 212 | thought 213 | for thought in thoughts 214 | if self.evaluated_thoughts[thought] >= self.pruning_threshold 215 | ] 216 | 217 | # # If no thoughts were generated, generate new thoughts until at least one valid thought is produced 218 | # while not filtered_thoughts: 219 | # thoughts = self.model.generate_thoughts( 220 | # state, self.num_thoughts, self.initial_prompt 221 | # ) 222 | # self.evaluated_thoughts = self.model.evaluate_states( 223 | # thoughts, self.initial_prompt 224 | # ) 225 | # filtered_thoughts = [ 226 | # thought 227 | # for thought in thoughts 228 | # if self.evaluated_thoughts[thought] >= self.pruning_threshold 229 | # ] 230 | 231 | # Cache the filtered thoughts 232 | for thought in filtered_thoughts: 233 | self.thought_cache["accepted"][thought] = self.evaluated_thoughts[thought] 234 | 235 | for thought in thoughts: 236 | if self.evaluated_thoughts[thought] < self.pruning_threshold: 237 | self.thought_cache["pruned"][thought] = self.evaluated_thoughts[thought] 238 | 239 | print("Generated Thoughts: ", thoughts) 240 | print("Evaluated Thoughts: ", self.evaluated_thoughts) 241 | 242 | print(f"filtered_thoughts: {filtered_thoughts}") 243 | return filtered_thoughts 244 | 245 | def evaluate_thought(self, state): 246 | """Evaluate a thought""" 247 | # Check if the thought is already in the cache 248 | if state in self.thought_cache["accepted"]: 249 | value = self.thought_cache["accepted"][state] 250 | print(f"Retrieved accepted thought value from cache: {value}") 251 | return state, value 252 | elif state in self.thought_cache["pruned"]: 253 | value = 0 # or whatever value you use for pruned thoughts 254 | print(f"Retrieved pruned thought value from cache: {value}") 255 | return state, value 256 | 257 | # Otherwise, evaluate the thought 258 | thought = self.model.generate_thoughts(state, 1, self.initial_prompt) 259 | value = self.model.evaluate_states([state], self.initial_prompt)[state] 260 | 261 | # Update the cache based on the evaluation 262 | if value >= self.pruning_threshold: 263 | self.thought_cache["accepted"][state] = value 264 | else: 265 | self.thought_cache["pruned"][state] = value 266 | 267 | print(f"Evaluated thought: {value}") 268 | return thought, value 269 | -------------------------------------------------------------------------------- /openai.logs: -------------------------------------------------------------------------------- 1 | 2 | ----------- 3 | Prompt : 4 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 5 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 6 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 7 | and evaluates potential subsequent steps to either progress 8 | towards a solution or retrace to another viable subtree then be very thorough 9 | and think atomically then provide solutions for those subtasks, 10 | then return the definitive end result and then summarize it 11 | 12 | 13 | ########## OBJECTIVE 14 | 15 | 16 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 17 | considering the next steps, do not choose operations that will result in a 18 | negative or fractional number. In order to help with the calculations, the 19 | numbers in the parenthesis represent the numbers that are left after the 20 | operations and they are in descending order. 21 | Another thing we do is when there are only two numbers left in the parenthesis, we 22 | check whether we can arrive at 24 only by using basic arithmetic operations 23 | (+ - * /). Some examples regarding this idea: 24 | (21 2) no 25 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 26 | to 24. 27 | (30 6) 30 - 6 = 24 yes 28 | (8 3) 8 * 3 = 24 yes 29 | (12 8) no 30 | (48 2) 48 / 2 = 24 yes 31 | Most importantly, do not give up, all the numbers that will be given has indeed a 32 | solution. 33 | 34 | 14 8 8 2 35 | 36 | OBJECTIVE 37 | ######### 38 | 5 10 5 2 39 | 40 | ################### 41 | 42 | 43 | ----------- 44 | Prompt : 45 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 46 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 47 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 48 | and evaluates potential subsequent steps to either progress 49 | towards a solution or retrace to another viable subtree then be very thorough 50 | and think atomically then provide solutions for those subtasks, 51 | then return the definitive end result and then summarize it 52 | 53 | 54 | ########## OBJECTIVE 55 | 56 | 57 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 58 | considering the next steps, do not choose operations that will result in a 59 | negative or fractional number. In order to help with the calculations, the 60 | numbers in the parenthesis represent the numbers that are left after the 61 | operations and they are in descending order. 62 | Another thing we do is when there are only two numbers left in the parenthesis, we 63 | check whether we can arrive at 24 only by using basic arithmetic operations 64 | (+ - * /). Some examples regarding this idea: 65 | (21 2) no 66 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 67 | to 24. 68 | (30 6) 30 - 6 = 24 yes 69 | (8 3) 8 * 3 = 24 yes 70 | (12 8) no 71 | (48 2) 48 / 2 = 24 yes 72 | Most importantly, do not give up, all the numbers that will be given has indeed a 73 | solution. 74 | 75 | 14 8 8 2 76 | 77 | OBJECTIVE 78 | ######### 79 | 5 10 5 2 80 | 81 | ################### 82 | 83 | 84 | ----------- 85 | Prompt : To achieve the following goal: ' 86 | 87 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 88 | considering the next steps, do not choose operations that will result in a 89 | negative or fractional number. In order to help with the calculations, the 90 | numbers in the parenthesis represent the numbers that are left after the 91 | operations and they are in descending order. 92 | Another thing we do is when there are only two numbers left in the parenthesis, we 93 | check whether we can arrive at 24 only by using basic arithmetic operations 94 | (+ - * /). Some examples regarding this idea: 95 | (21 2) no 96 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 97 | to 24. 98 | (30 6) 30 - 6 = 24 yes 99 | (8 3) 8 * 3 = 24 yes 100 | (12 8) no 101 | (48 2) 48 / 2 = 24 yes 102 | Most importantly, do not give up, all the numbers that will be given has indeed a 103 | solution. 104 | 105 | 14 8 8 2 106 | 107 | OBJECTIVE 108 | ######### 109 | 5 10 5 2 110 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 111 | 112 | Past solutions: 113 | 114 | 115 | To decompose the task and find a solution, we can follow these steps: 116 | 117 | 1. Start by examining the given numbers: 14, 8, 8, 2. 118 | 2. Explore all possible combinations of the numbers using the basic arithmetic operations (+ - * /). 119 | 3. Look for combinations that result in 24. 120 | 4. If no combination results in 24, go back to step 2 and try different combinations. 121 | 5. If a combination results in 24, return the solution. 122 | 123 | Let's begin the search process: 124 | 125 | 1. Explore all possible combinations using the first number (14): 126 | - 14 + (8 8 2) 127 | - 14 - (8 8 2) 128 | - 14 * (8 8 2) 129 | - 14 / (8 8 2) 130 | 131 | 2. Explore all possible combinations using the second number (8): 132 | - (14 8) + (8 2) 133 | - (14 8) - (8 2) 134 | - (14 8) * (8 2) 135 | - (14 8) / (8 2) 136 | 137 | 3. Explore all possible combinations using the third number (8): 138 | - (14 8 8) + 2 139 | - (14 8 8) - 2 140 | - (14 8 8) * 2 141 | - (14 8 8) / 2 142 | 143 | 4. Explore all possible combinations using the fourth number (2): 144 | - (14 8 8 2) + 0 145 | - (14 8 8 2) - 0 146 | - (14 8 8 2) * 0 147 | - (14 8 8 2) / 0 148 | 149 | 5. Evaluate potential subsequent steps for each explored combination: 150 | - For (14 8 8 2) + 0, 151 | 152 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 153 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 154 | , DO NOT RETURN ANYTHING ELSE 155 | 156 | 157 | ----------- 158 | Prompt : To achieve the following goal: ' 159 | 160 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 161 | considering the next steps, do not choose operations that will result in a 162 | negative or fractional number. In order to help with the calculations, the 163 | numbers in the parenthesis represent the numbers that are left after the 164 | operations and they are in descending order. 165 | Another thing we do is when there are only two numbers left in the parenthesis, we 166 | check whether we can arrive at 24 only by using basic arithmetic operations 167 | (+ - * /). Some examples regarding this idea: 168 | (21 2) no 169 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 170 | to 24. 171 | (30 6) 30 - 6 = 24 yes 172 | (8 3) 8 * 3 = 24 yes 173 | (12 8) no 174 | (48 2) 48 / 2 = 24 yes 175 | Most importantly, do not give up, all the numbers that will be given has indeed a 176 | solution. 177 | 178 | 14 8 8 2 179 | 180 | OBJECTIVE 181 | ######### 182 | 5 10 5 2 183 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 184 | 185 | Past solutions: 186 | 187 | 188 | 1. Evaluate the first subtree exploration: 14 + 8 + 8 + 2 189 | - Result: 32 190 | 191 | 2. Evaluate the second subtree exploration: 14 + 8 + 8 - 2 192 | - Result: 28 193 | 194 | 3. Evaluate the third subtree exploration: 14 + 8 + 8 * 2 195 | - Result: 38 196 | 197 | 4. Evaluate the fourth subtree exploration: 14 + 8 + 8 / 2 198 | - Result: 30 199 | 200 | 5. Evaluate the fifth subtree exploration: 14 + 8 - 8 + 2 201 | - Result: 16 202 | 203 | 6. Evaluate the sixth subtree exploration: 14 + 8 - 8 - 2 204 | - Result: 12 205 | 206 | 7. Evaluate the seventh subtree exploration: 14 + 8 - 8 * 2 207 | - Result: 6 208 | 209 | 8. Evaluate the eighth subtree exploration: 14 + 8 - 8 / 2 210 | - Result: 14 211 | 212 | 9. Evaluate the ninth subtree exploration: 14 + 8 * 8 + 2 213 | - Result: 78 214 | 215 | 10. Evaluate the tenth subtree exploration: 14 + 8 * 8 - 2 216 | - Result: 62 217 | 218 | 11. Evaluate the eleventh subtree exploration: 14 + 8 * 8 * 2 219 | - Result: 150 220 | 221 | 12. Evaluate the twelfth subtree exploration: 14 + 8 * 8 / 2 222 | - Result: 46 223 | 224 | 13. Evaluate the thirteenth subtree exploration: 14 + 8 / 8 + 2 225 | - Result: 17 226 | 227 | 14. Evaluate the fourteenth subtree exploration: 14 + 8 / 8 - 2 228 | - Result: 12 229 | 230 | 15. Evaluate the fifteenth subtree exploration: 14 + 8 / 8 231 | 232 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 233 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 234 | , DO NOT RETURN ANYTHING ELSE 235 | 236 | 237 | ----------- 238 | Prompt : 239 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 240 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 241 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 242 | and evaluates potential subsequent steps to either progress 243 | towards a solution or retrace to another viable subtree then be very thorough 244 | and think atomically then provide solutions for those subtasks, 245 | then return the definitive end result and then summarize it 246 | 247 | 248 | ########## OBJECTIVE 249 | 250 | 251 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 252 | considering the next steps, do not choose operations that will result in a 253 | negative or fractional number. In order to help with the calculations, the 254 | numbers in the parenthesis represent the numbers that are left after the 255 | operations and they are in descending order. 256 | Another thing we do is when there are only two numbers left in the parenthesis, we 257 | check whether we can arrive at 24 only by using basic arithmetic operations 258 | (+ - * /). Some examples regarding this idea: 259 | (21 2) no 260 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 261 | to 24. 262 | (30 6) 30 - 6 = 24 yes 263 | (8 3) 8 * 3 = 24 yes 264 | (12 8) no 265 | (48 2) 48 / 2 = 24 yes 266 | Most importantly, do not give up, all the numbers that will be given has indeed a 267 | solution. 268 | 269 | 14 8 8 2 270 | 271 | OBJECTIVE 272 | ######### 273 | 5 10 5 2 274 | 275 | ################### 276 | 277 | 278 | ----------- 279 | Prompt : To achieve the following goal: ' 280 | 281 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 282 | considering the next steps, do not choose operations that will result in a 283 | negative or fractional number. In order to help with the calculations, the 284 | numbers in the parenthesis represent the numbers that are left after the 285 | operations and they are in descending order. 286 | Another thing we do is when there are only two numbers left in the parenthesis, we 287 | check whether we can arrive at 24 only by using basic arithmetic operations 288 | (+ - * /). Some examples regarding this idea: 289 | (21 2) no 290 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 291 | to 24. 292 | (30 6) 30 - 6 = 24 yes 293 | (8 3) 8 * 3 = 24 yes 294 | (12 8) no 295 | (48 2) 48 / 2 = 24 yes 296 | Most importantly, do not give up, all the numbers that will be given has indeed a 297 | solution. 298 | 299 | 14 8 8 2 300 | 301 | OBJECTIVE 302 | ######### 303 | 5 10 5 2 304 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 305 | 306 | Past solutions: 307 | 308 | 309 | 1. 5 + 10 = 15 (15 5 2) 310 | 2. 15 + 5 = 20 (20 2) 311 | 3. 20 + 2 = 22 (22) 312 | 4. 22 + 2 = 24 (24) 313 | 314 | The definitive end result is 24 and it can be obtained by adding the numbers in the parenthesis in ascending order: 5 + 10 = 15, 15 + 5 = 20, 20 + 2 = 22 and 22 + 2 = 24. 315 | 316 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 317 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 318 | , DO NOT RETURN ANYTHING ELSE 319 | 320 | 321 | ----------- 322 | Prompt : To achieve the following goal: ' 323 | 324 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 325 | considering the next steps, do not choose operations that will result in a 326 | negative or fractional number. In order to help with the calculations, the 327 | numbers in the parenthesis represent the numbers that are left after the 328 | operations and they are in descending order. 329 | Another thing we do is when there are only two numbers left in the parenthesis, we 330 | check whether we can arrive at 24 only by using basic arithmetic operations 331 | (+ - * /). Some examples regarding this idea: 332 | (21 2) no 333 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 334 | to 24. 335 | (30 6) 30 - 6 = 24 yes 336 | (8 3) 8 * 3 = 24 yes 337 | (12 8) no 338 | (48 2) 48 / 2 = 24 yes 339 | Most importantly, do not give up, all the numbers that will be given has indeed a 340 | solution. 341 | 342 | 14 8 8 2 343 | 344 | OBJECTIVE 345 | ######### 346 | 5 10 5 2 347 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 348 | 349 | Past solutions: 350 | 351 | 352 | 1. Start with the given numbers in the parenthesis (14 8 8 2) and evaluate potential subsequent steps to either progress towards a solution or retrace to another viable subtree. 353 | 354 | 2. Check if any of the numbers in the parenthesis can be combined to create a number that is equal to 24. 355 | 356 | 3. If not, look for a combination of two numbers that can be combined to create a number that is equal to 24. 357 | 358 | 4. If no combination of two numbers can create a number that is equal to 24, look for a combination of three numbers that can be combined to create a number that is equal to 24. 359 | 360 | 5. If no combination of three numbers can create a number that is equal to 24, look for a combination of four numbers that can be combined to create a number that is equal to 24. 361 | 362 | 6. If no combination of four numbers can create a number that is equal to 24, look for a combination of five numbers that can be combined to create a number that is equal to 24. 363 | 364 | 7. If no combination of five numbers can create a number that is equal to 24, look for a combination of six numbers that can be combined to create a number that is equal to 24. 365 | 366 | 8. If no combination of six numbers can create a number that is equal to 24, look for a combination of seven numbers that can be combined to create a number that is equal to 24. 367 | 368 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 369 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 370 | , DO NOT RETURN ANYTHING ELSE 371 | 372 | 373 | ----------- 374 | Prompt : 375 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 376 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 377 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 378 | and evaluates potential subsequent steps to either progress 379 | towards a solution or retrace to another viable subtree then be very thorough 380 | and think atomically then provide solutions for those subtasks, 381 | then return the definitive end result and then summarize it 382 | 383 | 384 | ########## OBJECTIVE 385 | 386 | 387 | 388 | PROMPT 389 | ################### 390 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 391 | considering the next steps, do not choose operations that will result in a 392 | negative or fractional number. In order to help with the calculations, the 393 | numbers in the parenthesis represent the numbers that are left after the 394 | operations and they are in descending order. 395 | Another thing we do is when there are only two numbers left in the parenthesis, we 396 | check whether we can arrive at 24 only by using basic arithmetic operations 397 | (+ - * /). Some examples regarding this idea: 398 | (21 2) no 399 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 400 | to 24. 401 | (30 6) 30 - 6 = 24 yes 402 | (8 3) 8 * 3 = 24 yes 403 | (12 8) no 404 | (48 2) 48 / 2 = 24 yes 405 | Most importantly, do not give up, all the numbers that will be given has indeed a 406 | solution. 407 | 408 | 14 8 8 2 409 | 410 | OBJECTIVE 411 | ######### 412 | 5 10 5 2 413 | 414 | 415 | ################### 416 | 417 | ################### 418 | 419 | 420 | ----------- 421 | Prompt : To achieve the following goal: ' 422 | 423 | 424 | PROMPT 425 | ################### 426 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 427 | considering the next steps, do not choose operations that will result in a 428 | negative or fractional number. In order to help with the calculations, the 429 | numbers in the parenthesis represent the numbers that are left after the 430 | operations and they are in descending order. 431 | Another thing we do is when there are only two numbers left in the parenthesis, we 432 | check whether we can arrive at 24 only by using basic arithmetic operations 433 | (+ - * /). Some examples regarding this idea: 434 | (21 2) no 435 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 436 | to 24. 437 | (30 6) 30 - 6 = 24 yes 438 | (8 3) 8 * 3 = 24 yes 439 | (12 8) no 440 | (48 2) 48 / 2 = 24 yes 441 | Most importantly, do not give up, all the numbers that will be given has indeed a 442 | solution. 443 | 444 | 14 8 8 2 445 | 446 | OBJECTIVE 447 | ######### 448 | 5 10 5 2 449 | 450 | 451 | ################### 452 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 453 | 454 | Past solutions: 455 | 456 | 457 | 1. First operations: 458 | - (14 8) 8 2 459 | - (10 5) 5 2 460 | 461 | 2. Subtree exploration 1: 462 | - (14 8) 8 2 463 | - (6 6) 8 2 464 | - 6 (6 8) 2 465 | - 6 (2 8) 2 466 | - 6 2 (8 2) 467 | 468 | 3. Subtree exploration 2: 469 | - (10 5) 5 2 470 | - (5 5) 5 2 471 | - 5 (5 2) 2 472 | - 5 (3 2) 2 473 | - 5 3 (2 2) 474 | 475 | 4. Subtree exploration 3: 476 | - 5 10 5 2 477 | - 5 5 (5 2) 2 478 | - 5 5 (3 2) 2 479 | - 5 5 3 (2 2) 480 | 481 | 5. Final Solution: 482 | 5 5 3 (2 2) -> 5 5 3 4 -> 5 5 7 -> 10 12 -> 22 -> 24 483 | 484 | Summary: 485 | Using the numbers 14 8 8 2, the solution is to first split the numbers into (14 8) 8 2 and (10 5) 5 2. Then, explore the subtrees of each of these numbers, starting with (14 8) 8 2. From here, we can find the solution 5 5 3 (2 2) which leads to 5 5 3 4, 5 5 7, 486 | 487 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 488 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 489 | , DO NOT RETURN ANYTHING ELSE 490 | 491 | 492 | ----------- 493 | Prompt : To achieve the following goal: ' 494 | 495 | 496 | PROMPT 497 | ################### 498 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 499 | considering the next steps, do not choose operations that will result in a 500 | negative or fractional number. In order to help with the calculations, the 501 | numbers in the parenthesis represent the numbers that are left after the 502 | operations and they are in descending order. 503 | Another thing we do is when there are only two numbers left in the parenthesis, we 504 | check whether we can arrive at 24 only by using basic arithmetic operations 505 | (+ - * /). Some examples regarding this idea: 506 | (21 2) no 507 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 508 | to 24. 509 | (30 6) 30 - 6 = 24 yes 510 | (8 3) 8 * 3 = 24 yes 511 | (12 8) no 512 | (48 2) 48 / 2 = 24 yes 513 | Most importantly, do not give up, all the numbers that will be given has indeed a 514 | solution. 515 | 516 | 14 8 8 2 517 | 518 | OBJECTIVE 519 | ######### 520 | 5 10 5 2 521 | 522 | 523 | ################### 524 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 525 | 526 | Past solutions: 527 | 528 | 529 | 1. First operations: 530 | a. 14 + 8 = 22 (22 8 8 2) 531 | b. 14 - 8 = 6 (6 8 8 2) 532 | c. 14 * 8 = 112 (112 8 2) 533 | d. 14 / 8 = 1.75 (1.75 8 8 2) 534 | 2. Subtree exploration 1: 535 | a. 22 + 8 = 30 (30 8 2) 536 | b. 22 - 8 = 14 (14 8 2) 537 | c. 22 * 8 = 176 (176 2) 538 | d. 22 / 8 = 2.75 (2.75 8 2) 539 | 3. Subtree exploration 2: 540 | a. 30 + 8 = 38 (38 2) 541 | b. 30 - 8 = 22 (22 8 2) 542 | c. 30 * 8 = 240 (240 2) 543 | d. 30 / 8 = 3.75 (3.75 2) 544 | 4. Subtree exploration 3: 545 | a. 38 + 2 = 40 (40) 546 | b. 38 - 2 = 36 (36) 547 | c. 38 * 2 = 76 (76) 548 | d. 38 / 2 = 19 (19) 549 | 5. Subtree exploration 4: 550 | a. 40 + 0 = 40 (40) 551 | b. 40 - 0 = 40 (40) 552 | c. 40 * 0 = 0 (0 553 | 554 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 555 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 556 | , DO NOT RETURN ANYTHING ELSE 557 | 558 | 559 | ----------- 560 | Prompt : 561 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 562 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 563 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 564 | and evaluates potential subsequent steps to either progress 565 | towards a solution or retrace to another viable subtree then be very thorough 566 | and think atomically then provide solutions for those subtasks, 567 | then return the definitive end result and then summarize it 568 | 569 | 570 | ########## OBJECTIVE 571 | 572 | 573 | 574 | PROMPT 575 | ################### 576 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 577 | considering the next steps, do not choose operations that will result in a 578 | negative or fractional number. In order to help with the calculations, the 579 | numbers in the parenthesis represent the numbers that are left after the 580 | operations and they are in descending order. 581 | Another thing we do is when there are only two numbers left in the parenthesis, we 582 | check whether we can arrive at 24 only by using basic arithmetic operations 583 | (+ - * /). Some examples regarding this idea: 584 | (21 2) no 585 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 586 | to 24. 587 | (30 6) 30 - 6 = 24 yes 588 | (8 3) 8 * 3 = 24 yes 589 | (12 8) no 590 | (48 2) 48 / 2 = 24 yes 591 | Most importantly, do not give up, all the numbers that will be given has indeed a 592 | solution. 593 | 594 | 14 8 8 2 595 | 596 | OBJECTIVE 597 | ######### 598 | 5 10 5 2 599 | 600 | 601 | ################### 602 | 603 | ################### 604 | 605 | 606 | ----------- 607 | Prompt : 608 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 609 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 610 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 611 | and evaluates potential subsequent steps to either progress 612 | towards a solution or retrace to another viable subtree then be very thorough 613 | and think atomically then provide solutions for those subtasks, 614 | then return the definitive end result and then summarize it 615 | 616 | 617 | ########## OBJECTIVE 618 | 619 | 620 | 621 | PROMPT 622 | ################### 623 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 624 | considering the next steps, do not choose operations that will result in a 625 | negative or fractional number. In order to help with the calculations, the 626 | numbers in the parenthesis represent the numbers that are left after the 627 | operations and they are in descending order. 628 | Another thing we do is when there are only two numbers left in the parenthesis, we 629 | check whether we can arrive at 24 only by using basic arithmetic operations 630 | (+ - * /). Some examples regarding this idea: 631 | (21 2) no 632 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 633 | to 24. 634 | (30 6) 30 - 6 = 24 yes 635 | (8 3) 8 * 3 = 24 yes 636 | (12 8) no 637 | (48 2) 48 / 2 = 24 yes 638 | Most importantly, do not give up, all the numbers that will be given has indeed a 639 | solution. 640 | 641 | 14 8 8 2 642 | 643 | OBJECTIVE 644 | ######### 645 | 5 10 5 2 646 | 647 | 648 | ################### 649 | 650 | ################### 651 | 652 | 653 | ----------- 654 | Prompt : To achieve the following goal: ' 655 | 656 | 657 | PROMPT 658 | ################### 659 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 660 | considering the next steps, do not choose operations that will result in a 661 | negative or fractional number. In order to help with the calculations, the 662 | numbers in the parenthesis represent the numbers that are left after the 663 | operations and they are in descending order. 664 | Another thing we do is when there are only two numbers left in the parenthesis, we 665 | check whether we can arrive at 24 only by using basic arithmetic operations 666 | (+ - * /). Some examples regarding this idea: 667 | (21 2) no 668 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 669 | to 24. 670 | (30 6) 30 - 6 = 24 yes 671 | (8 3) 8 * 3 = 24 yes 672 | (12 8) no 673 | (48 2) 48 / 2 = 24 yes 674 | Most importantly, do not give up, all the numbers that will be given has indeed a 675 | solution. 676 | 677 | 14 8 8 2 678 | 679 | OBJECTIVE 680 | ######### 681 | 5 10 5 2 682 | 683 | 684 | ################### 685 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 686 | 687 | Past solutions: 688 | 689 | 690 | To obtain 24 using the numbers 14, 8, 8, and 2, we can decompose the task into the following subtasks: 691 | 692 | 1. Explore all possible combinations of the given numbers. 693 | 2. Apply basic arithmetic operations to each combination to evaluate if it can result in 24. 694 | 3. If a combination results in 24, return it as the solution. 695 | 4. If no combination results in 24, continue exploring other combinations. 696 | 697 | Subtask 1: Explore all possible combinations of the given numbers. 698 | 1. Combine the numbers in all possible orders: 699 | - 14, 8, 8, 2 700 | - 14, 8, 2, 8 701 | - 14, 2, 8, 8 702 | - 8, 14, 8, 2 703 | - 8, 14, 2, 8 704 | - 8, 8, 14, 2 705 | - 8, 8, 2, 14 706 | - 8, 2, 14, 8 707 | - 8, 2, 8, 14 708 | - 2, 14, 8, 8 709 | - 2, 8, 14, 8 710 | - 2, 8, 8, 14 711 | 712 | Subtask 2: Apply basic arithmetic operations to each combination to evaluate if it can result in 24. 713 | 1. For each combination, apply the four basic arithmetic operations (+, -, *, /) to evaluate if it equals 24. 714 | - 14 + 8 + 8 + 2 = 32 715 | - 14 + 8 + 2 + 8 = 32 716 | - 14 + 2 + 8 + 8 = 32 717 | - 8 + 14 + 8 + 2 = 32 718 | 719 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 720 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 721 | , DO NOT RETURN ANYTHING ELSE 722 | 723 | 724 | ----------- 725 | Prompt : To achieve the following goal: ' 726 | 727 | 728 | PROMPT 729 | ################### 730 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 731 | considering the next steps, do not choose operations that will result in a 732 | negative or fractional number. In order to help with the calculations, the 733 | numbers in the parenthesis represent the numbers that are left after the 734 | operations and they are in descending order. 735 | Another thing we do is when there are only two numbers left in the parenthesis, we 736 | check whether we can arrive at 24 only by using basic arithmetic operations 737 | (+ - * /). Some examples regarding this idea: 738 | (21 2) no 739 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 740 | to 24. 741 | (30 6) 30 - 6 = 24 yes 742 | (8 3) 8 * 3 = 24 yes 743 | (12 8) no 744 | (48 2) 48 / 2 = 24 yes 745 | Most importantly, do not give up, all the numbers that will be given has indeed a 746 | solution. 747 | 748 | 14 8 8 2 749 | 750 | OBJECTIVE 751 | ######### 752 | 5 10 5 2 753 | 754 | 755 | ################### 756 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 757 | 758 | Past solutions: 759 | 760 | 761 | To decompose the task into subtasks, we can follow the following steps: 762 | 763 | 1. Identify the given numbers: 14, 8, 8, 2 764 | 2. Determine all possible combinations of the given numbers. 765 | 3. For each combination, perform basic arithmetic operations (+, -, *, /) to obtain 24. 766 | 4. Check if any of the combinations result in 24. 767 | 5. If a combination results in 24, return that combination as the solution. 768 | 6. If none of the combinations result in 24, go back to step 2 and try different combinations. 769 | 770 | Subtask 1: Identify the given numbers 771 | - Given numbers: 14, 8, 8, 2 772 | 773 | Subtask 2: Determine all possible combinations of the given numbers 774 | - Possible combinations: 775 | - 14 8 8 2 776 | - 14 8 2 8 777 | - 14 2 8 8 778 | - 8 14 8 2 779 | - 8 14 2 8 780 | - 8 8 14 2 781 | - 8 8 2 14 782 | - 8 2 14 8 783 | - 8 2 8 14 784 | - 2 14 8 8 785 | - 2 8 14 8 786 | - 2 8 8 14 787 | 788 | Subtask 3: For each combination, perform basic arithmetic operations to obtain 24 789 | - Combination: 14 8 8 2 790 | - 14 + 8 + 8 + 2 = 32 (not equal to 24) 791 | - 14 + 8 + 8 - 2 = 28 (not equal to 24) 792 | - 14 + 8 + 8 * 2 = 46 (not equal to 24) 793 | - 14 + 794 | 795 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 796 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 797 | , DO NOT RETURN ANYTHING ELSE 798 | 799 | 800 | ----------- 801 | Prompt : 802 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 803 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 804 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 805 | and evaluates potential subsequent steps to either progress 806 | towards a solution or retrace to another viable subtree then be very thorough 807 | and think atomically then provide solutions for those subtasks, 808 | then return the definitive end result and then summarize it 809 | 810 | 811 | ########## OBJECTIVE 812 | 813 | 814 | 815 | PROMPT 816 | ################### 817 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 818 | considering the next steps, do not choose operations that will result in a 819 | negative or fractional number. In order to help with the calculations, the 820 | numbers in the parenthesis represent the numbers that are left after the 821 | operations and they are in descending order. 822 | Another thing we do is when there are only two numbers left in the parenthesis, we 823 | check whether we can arrive at 24 only by using basic arithmetic operations 824 | (+ - * /). Some examples regarding this idea: 825 | (21 2) no 826 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 827 | to 24. 828 | (30 6) 30 - 6 = 24 yes 829 | (8 3) 8 * 3 = 24 yes 830 | (12 8) no 831 | (48 2) 48 / 2 = 24 yes 832 | Most importantly, do not give up, all the numbers that will be given has indeed a 833 | solution. 834 | 835 | 14 8 8 2 836 | 837 | OBJECTIVE 838 | ######### 839 | 5 10 5 2 840 | 841 | 842 | ################### 843 | 844 | ################### 845 | 846 | 847 | ----------- 848 | Prompt : 849 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 850 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 851 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 852 | and evaluates potential subsequent steps to either progress 853 | towards a solution or retrace to another viable subtree then be very thorough 854 | and think atomically then provide solutions for those subtasks, 855 | then return the definitive end result and then summarize it 856 | 857 | 858 | ########## OBJECTIVE 859 | 860 | 861 | 862 | PROMPT 863 | ################### 864 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 865 | considering the next steps, do not choose operations that will result in a 866 | negative or fractional number. In order to help with the calculations, the 867 | numbers in the parenthesis represent the numbers that are left after the 868 | operations and they are in descending order. 869 | Another thing we do is when there are only two numbers left in the parenthesis, we 870 | check whether we can arrive at 24 only by using basic arithmetic operations 871 | (+ - * /). Some examples regarding this idea: 872 | (21 2) no 873 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 874 | to 24. 875 | (30 6) 30 - 6 = 24 yes 876 | (8 3) 8 * 3 = 24 yes 877 | (12 8) no 878 | (48 2) 48 / 2 = 24 yes 879 | Most importantly, do not give up, all the numbers that will be given has indeed a 880 | solution. 881 | 882 | 14 8 8 2 883 | 884 | OBJECTIVE 885 | ######### 886 | 5 10 5 2 887 | 888 | 889 | ################### 890 | 891 | ################### 892 | 893 | 894 | ----------- 895 | Prompt : To achieve the following goal: ' 896 | 897 | 898 | PROMPT 899 | ################### 900 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 901 | considering the next steps, do not choose operations that will result in a 902 | negative or fractional number. In order to help with the calculations, the 903 | numbers in the parenthesis represent the numbers that are left after the 904 | operations and they are in descending order. 905 | Another thing we do is when there are only two numbers left in the parenthesis, we 906 | check whether we can arrive at 24 only by using basic arithmetic operations 907 | (+ - * /). Some examples regarding this idea: 908 | (21 2) no 909 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 910 | to 24. 911 | (30 6) 30 - 6 = 24 yes 912 | (8 3) 8 * 3 = 24 yes 913 | (12 8) no 914 | (48 2) 48 / 2 = 24 yes 915 | Most importantly, do not give up, all the numbers that will be given has indeed a 916 | solution. 917 | 918 | 14 8 8 2 919 | 920 | OBJECTIVE 921 | ######### 922 | 5 10 5 2 923 | 924 | 925 | ################### 926 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 927 | 928 | Past solutions: 929 | 930 | 931 | To decompose the task and find a solution, we can follow these subtasks: 932 | 933 | 1. Explore all possible combinations of the given numbers (14, 8, 8, 2) to form equations using basic arithmetic operations (+ - * /). 934 | 2. Check if any of the combinations result in 24 without using negative or fractional numbers. 935 | 3. If no combination satisfies the condition in step 2, backtrack to a viable subtree and continue exploring. 936 | 4. Repeat steps 1-3 until all possible combinations have been explored. 937 | 5. Return the definitive end result, which is the equation that equals 24. 938 | 939 | Now let's go through the subtasks in detail: 940 | 941 | 1. Explore all possible combinations of the given numbers (14, 8, 8, 2) to form equations using basic arithmetic operations (+ - * /): 942 | 943 | - 14 + 8 + 8 + 2 944 | - 14 + 8 + 8 - 2 945 | - 14 + 8 + 8 * 2 946 | - 14 + 8 + 8 / 2 947 | - 14 + 8 - 8 + 2 948 | - 14 + 8 - 8 - 2 949 | - 14 + 8 - 8 * 2 950 | - 14 + 8 - 8 / 2 951 | - 14 + 8 * 8 + 2 952 | - 14 + 8 * 8 - 2 953 | - 14 + 8 * 8 * 2 954 | - 14 + 8 * 8 / 2 955 | - 14 + 8 / 8 + 2 956 | - 14 + 8 / 8 - 2 957 | - 14 + 8 / 8 * 2 958 | - 14 + 8 / 8 / 2 959 | - 14 - 960 | 961 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 962 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 963 | , DO NOT RETURN ANYTHING ELSE 964 | 965 | 966 | ----------- 967 | Prompt : To achieve the following goal: ' 968 | 969 | 970 | PROMPT 971 | ################### 972 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 973 | considering the next steps, do not choose operations that will result in a 974 | negative or fractional number. In order to help with the calculations, the 975 | numbers in the parenthesis represent the numbers that are left after the 976 | operations and they are in descending order. 977 | Another thing we do is when there are only two numbers left in the parenthesis, we 978 | check whether we can arrive at 24 only by using basic arithmetic operations 979 | (+ - * /). Some examples regarding this idea: 980 | (21 2) no 981 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 982 | to 24. 983 | (30 6) 30 - 6 = 24 yes 984 | (8 3) 8 * 3 = 24 yes 985 | (12 8) no 986 | (48 2) 48 / 2 = 24 yes 987 | Most importantly, do not give up, all the numbers that will be given has indeed a 988 | solution. 989 | 990 | 14 8 8 2 991 | 992 | OBJECTIVE 993 | ######### 994 | 5 10 5 2 995 | 996 | 997 | ################### 998 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 999 | 1000 | Past solutions: 1001 | 1002 | 1003 | To decompose the task into explicit subtasks, we can follow the steps below: 1004 | 1005 | 1. Evaluate the given numbers and determine if any of them can be used directly to obtain 24 without any operations. If so, return the solution. 1006 | 1007 | 2. Generate all possible combinations of the given numbers. This can be done by permuting the numbers and grouping them into pairs. 1008 | 1009 | 3. For each combination, apply the four basic arithmetic operations (+, -, *, /) to the pair of numbers and evaluate if any of the results equal 24. If so, return the solution. 1010 | 1011 | 4. If none of the combinations from step 3 yield a solution, generate all possible combinations of three numbers from the given set. 1012 | 1013 | 5. For each combination of three numbers, apply the four basic arithmetic operations to the numbers in all possible orders and evaluate if any of the results equal 24. If so, return the solution. 1014 | 1015 | 6. If none of the combinations from step 5 yield a solution, generate all possible combinations of four numbers from the given set. 1016 | 1017 | 7. For each combination of four numbers, apply the four basic arithmetic operations to the numbers in all possible orders and evaluate if any of the results equal 24. If so, return the solution. 1018 | 1019 | 8. If none of the combinations from step 7 yield a solution, repeat the process with different orders of operations (e.g., changing the order of addition, subtraction, multiplication, and division). 1020 | 1021 | 9. If none of the combinations from step 8 yield a solution, return that there is no solution for the given set of numbers. 1022 | 1023 | Prospective search steps: 1024 | 1. Check if any of the given numbers (14, 8, 8, 2) can be used directly to obtain 24. 1025 | 2. Generate all possible combinations of the given numbers: (14, 8), (14, 8), (14, 2), (8, 8), (8, 2), (8, 2). 1026 | 1027 | 1028 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 1029 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 1030 | , DO NOT RETURN ANYTHING ELSE 1031 | 1032 | 1033 | ----------- 1034 | Prompt : 1035 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 1036 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 1037 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 1038 | and evaluates potential subsequent steps to either progress 1039 | towards a solution or retrace to another viable subtree then be very thorough 1040 | and think atomically then provide solutions for those subtasks, 1041 | then return the definitive end result and then summarize it 1042 | 1043 | 1044 | ########## OBJECTIVE 1045 | 1046 | 1047 | 1048 | PROMPT 1049 | ################### 1050 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1051 | considering the next steps, do not choose operations that will result in a 1052 | negative or fractional number. In order to help with the calculations, the 1053 | numbers in the parenthesis represent the numbers that are left after the 1054 | operations and they are in descending order. 1055 | Another thing we do is when there are only two numbers left in the parenthesis, we 1056 | check whether we can arrive at 24 only by using basic arithmetic operations 1057 | (+ - * /). Some examples regarding this idea: 1058 | (21 2) no 1059 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1060 | to 24. 1061 | (30 6) 30 - 6 = 24 yes 1062 | (8 3) 8 * 3 = 24 yes 1063 | (12 8) no 1064 | (48 2) 48 / 2 = 24 yes 1065 | Most importantly, do not give up, all the numbers that will be given has indeed a 1066 | solution. 1067 | 1068 | 14 8 8 2 1069 | 1070 | OBJECTIVE 1071 | ######### 1072 | 5 10 5 2 1073 | 1074 | 1075 | ################### 1076 | 1077 | ################### 1078 | 1079 | 1080 | ----------- 1081 | Prompt : 1082 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 1083 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 1084 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 1085 | and evaluates potential subsequent steps to either progress 1086 | towards a solution or retrace to another viable subtree then be very thorough 1087 | and think atomically then provide solutions for those subtasks, 1088 | then return the definitive end result and then summarize it 1089 | 1090 | 1091 | ########## OBJECTIVE 1092 | 1093 | 1094 | 1095 | PROMPT 1096 | ################### 1097 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1098 | considering the next steps, do not choose operations that will result in a 1099 | negative or fractional number. In order to help with the calculations, the 1100 | numbers in the parenthesis represent the numbers that are left after the 1101 | operations and they are in descending order. 1102 | Another thing we do is when there are only two numbers left in the parenthesis, we 1103 | check whether we can arrive at 24 only by using basic arithmetic operations 1104 | (+ - * /). Some examples regarding this idea: 1105 | (21 2) no 1106 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1107 | to 24. 1108 | (30 6) 30 - 6 = 24 yes 1109 | (8 3) 8 * 3 = 24 yes 1110 | (12 8) no 1111 | (48 2) 48 / 2 = 24 yes 1112 | Most importantly, do not give up, all the numbers that will be given has indeed a 1113 | solution. 1114 | 1115 | 14 8 8 2 1116 | 1117 | OBJECTIVE 1118 | ######### 1119 | 5 10 5 2 1120 | 1121 | 1122 | ################### 1123 | 1124 | ################### 1125 | 1126 | 1127 | ----------- 1128 | Prompt : To achieve the following goal: ' 1129 | 1130 | 1131 | PROMPT 1132 | ################### 1133 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1134 | considering the next steps, do not choose operations that will result in a 1135 | negative or fractional number. In order to help with the calculations, the 1136 | numbers in the parenthesis represent the numbers that are left after the 1137 | operations and they are in descending order. 1138 | Another thing we do is when there are only two numbers left in the parenthesis, we 1139 | check whether we can arrive at 24 only by using basic arithmetic operations 1140 | (+ - * /). Some examples regarding this idea: 1141 | (21 2) no 1142 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1143 | to 24. 1144 | (30 6) 30 - 6 = 24 yes 1145 | (8 3) 8 * 3 = 24 yes 1146 | (12 8) no 1147 | (48 2) 48 / 2 = 24 yes 1148 | Most importantly, do not give up, all the numbers that will be given has indeed a 1149 | solution. 1150 | 1151 | 14 8 8 2 1152 | 1153 | OBJECTIVE 1154 | ######### 1155 | 5 10 5 2 1156 | 1157 | 1158 | ################### 1159 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 1160 | 1161 | Past solutions: 1162 | 1163 | 1164 | 1. Evaluate the given numbers: 14, 8, 8, 2 1165 | 2. Determine all possible combinations of the given numbers: 1166 | - (14 8 8 2) 1167 | - (14 8 2 8) 1168 | - (14 2 8 8) 1169 | - (8 14 8 2) 1170 | - (8 14 2 8) 1171 | - (8 8 14 2) 1172 | - (8 8 2 14) 1173 | - (8 2 14 8) 1174 | - (8 2 8 14) 1175 | - (2 14 8 8) 1176 | - (2 8 14 8) 1177 | - (2 8 8 14) 1178 | 3. Check if any of the combinations can directly equal 24: 1179 | - (14 8 8 2): 14 + 8 + 8 + 2 = 32 1180 | - (14 8 2 8): 14 + 8 + 2 + 8 = 32 1181 | - (14 2 8 8): 14 + 2 + 8 + 8 = 32 1182 | - (8 14 8 2): 8 + 14 + 8 + 2 = 32 1183 | - (8 14 2 8): 8 + 14 + 2 + 8 = 32 1184 | - (8 8 14 2): 8 + 8 + 14 + 2 = 32 1185 | - (8 8 2 14): 8 + 8 + 2 + 14 = 32 1186 | - (8 2 14 8): 8 + 2 + 14 + 8 = 32 1187 | - (8 2 8 14): 8 + 1188 | 1189 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 1190 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 1191 | , DO NOT RETURN ANYTHING ELSE 1192 | 1193 | 1194 | ----------- 1195 | Prompt : To achieve the following goal: ' 1196 | 1197 | 1198 | PROMPT 1199 | ################### 1200 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1201 | considering the next steps, do not choose operations that will result in a 1202 | negative or fractional number. In order to help with the calculations, the 1203 | numbers in the parenthesis represent the numbers that are left after the 1204 | operations and they are in descending order. 1205 | Another thing we do is when there are only two numbers left in the parenthesis, we 1206 | check whether we can arrive at 24 only by using basic arithmetic operations 1207 | (+ - * /). Some examples regarding this idea: 1208 | (21 2) no 1209 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1210 | to 24. 1211 | (30 6) 30 - 6 = 24 yes 1212 | (8 3) 8 * 3 = 24 yes 1213 | (12 8) no 1214 | (48 2) 48 / 2 = 24 yes 1215 | Most importantly, do not give up, all the numbers that will be given has indeed a 1216 | solution. 1217 | 1218 | 14 8 8 2 1219 | 1220 | OBJECTIVE 1221 | ######### 1222 | 5 10 5 2 1223 | 1224 | 1225 | ################### 1226 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 1227 | 1228 | Past solutions: 1229 | 1230 | 1231 | To obtain the objective of 5 10 5 2, we can decompose the task into the following subtasks: 1232 | 1233 | 1. Perform all possible arithmetic operations on the given numbers to obtain a result of 24. 1234 | 2. Check if it is possible to obtain 24 using only two numbers through basic arithmetic operations. 1235 | 3. If the above steps do not result in 24, repeat the process with different combinations of the given numbers. 1236 | 1237 | Let's explore each subtask in detail: 1238 | 1239 | Subtask 1: Perform all possible arithmetic operations on the given numbers to obtain a result of 24. 1240 | 1.1. Add the first two numbers: 5 + 10 = 15. (15 5 2) 1241 | 1.2. Subtract the first two numbers: 5 - 10 = -5. (This is not a valid result, as negative numbers are not allowed) 1242 | 1.3. Multiply the first two numbers: 5 * 10 = 50. (50 5 2) 1243 | 1.4. Divide the first two numbers: 5 / 10 = 0.5. (This is not a valid result, as fractional numbers are not allowed) 1244 | 1.5. Add the first and third numbers: 5 + 5 = 10. (10 10 2) 1245 | 1.6. Subtract the first and third numbers: 5 - 5 = 0. (This is not a valid result, as zero is not equal to 24) 1246 | 1.7. Multiply the first and third numbers: 5 * 5 = 25. (25 10 2) 1247 | 1.8. Divide the first and third numbers: 5 / 5 = 1. (This is not a valid result, as one is not equal to 24) 1248 | 1.9. Add the first and fourth numbers: 5 + 2 = 7. (7 10 5) 1249 | 1.10 1250 | 1251 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 1252 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 1253 | , DO NOT RETURN ANYTHING ELSE 1254 | 1255 | 1256 | ----------- 1257 | Prompt : 1258 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 1259 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 1260 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 1261 | and evaluates potential subsequent steps to either progress 1262 | towards a solution or retrace to another viable subtree then be very thorough 1263 | and think atomically then provide solutions for those subtasks, 1264 | then return the definitive end result and then summarize it 1265 | 1266 | 1267 | ########## OBJECTIVE 1268 | 1269 | 1270 | 1271 | PROMPT 1272 | ################### 1273 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1274 | considering the next steps, do not choose operations that will result in a 1275 | negative or fractional number. In order to help with the calculations, the 1276 | numbers in the parenthesis represent the numbers that are left after the 1277 | operations and they are in descending order. 1278 | Another thing we do is when there are only two numbers left in the parenthesis, we 1279 | check whether we can arrive at 24 only by using basic arithmetic operations 1280 | (+ - * /). Some examples regarding this idea: 1281 | (21 2) no 1282 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1283 | to 24. 1284 | (30 6) 30 - 6 = 24 yes 1285 | (8 3) 8 * 3 = 24 yes 1286 | (12 8) no 1287 | (48 2) 48 / 2 = 24 yes 1288 | Most importantly, do not give up, all the numbers that will be given has indeed a 1289 | solution. 1290 | 1291 | 14 8 8 2 1292 | 1293 | OBJECTIVE 1294 | ######### 1295 | 5 10 5 2 1296 | 1297 | 1298 | ################### 1299 | 1300 | ################### 1301 | 1302 | 1303 | ----------- 1304 | Prompt : 1305 | Accomplish the task below by decomposing it as many very explicit subtasks as possible, be very explicit and thorough denoted by 1306 | a search process, highlighted by markers ‘1’,..., ‘3’ as “first operations” guiding subtree exploration for the OBJECTIVE, 1307 | focus on the third subtree exploration. Produce prospective search steps (e.g., the subtree exploration ‘5. 11 + 1’) 1308 | and evaluates potential subsequent steps to either progress 1309 | towards a solution or retrace to another viable subtree then be very thorough 1310 | and think atomically then provide solutions for those subtasks, 1311 | then return the definitive end result and then summarize it 1312 | 1313 | 1314 | ########## OBJECTIVE 1315 | 1316 | 1317 | 1318 | PROMPT 1319 | ################### 1320 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1321 | considering the next steps, do not choose operations that will result in a 1322 | negative or fractional number. In order to help with the calculations, the 1323 | numbers in the parenthesis represent the numbers that are left after the 1324 | operations and they are in descending order. 1325 | Another thing we do is when there are only two numbers left in the parenthesis, we 1326 | check whether we can arrive at 24 only by using basic arithmetic operations 1327 | (+ - * /). Some examples regarding this idea: 1328 | (21 2) no 1329 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1330 | to 24. 1331 | (30 6) 30 - 6 = 24 yes 1332 | (8 3) 8 * 3 = 24 yes 1333 | (12 8) no 1334 | (48 2) 48 / 2 = 24 yes 1335 | Most importantly, do not give up, all the numbers that will be given has indeed a 1336 | solution. 1337 | 1338 | 14 8 8 2 1339 | 1340 | OBJECTIVE 1341 | ######### 1342 | 5 10 5 2 1343 | 1344 | 1345 | ################### 1346 | 1347 | ################### 1348 | 1349 | 1350 | ----------- 1351 | Prompt : To achieve the following goal: ' 1352 | 1353 | 1354 | PROMPT 1355 | ################### 1356 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1357 | considering the next steps, do not choose operations that will result in a 1358 | negative or fractional number. In order to help with the calculations, the 1359 | numbers in the parenthesis represent the numbers that are left after the 1360 | operations and they are in descending order. 1361 | Another thing we do is when there are only two numbers left in the parenthesis, we 1362 | check whether we can arrive at 24 only by using basic arithmetic operations 1363 | (+ - * /). Some examples regarding this idea: 1364 | (21 2) no 1365 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1366 | to 24. 1367 | (30 6) 30 - 6 = 24 yes 1368 | (8 3) 8 * 3 = 24 yes 1369 | (12 8) no 1370 | (48 2) 48 / 2 = 24 yes 1371 | Most importantly, do not give up, all the numbers that will be given has indeed a 1372 | solution. 1373 | 1374 | 14 8 8 2 1375 | 1376 | OBJECTIVE 1377 | ######### 1378 | 5 10 5 2 1379 | 1380 | 1381 | ################### 1382 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 1383 | 1384 | Past solutions: 1385 | 1386 | 1387 | To decompose the task and find a solution, we can follow these steps: 1388 | 1389 | 1. Start with the given numbers: 14, 8, 8, 2 1390 | 1391 | 2. Explore all possible combinations of the numbers using the basic arithmetic operations (+, -, *, /). 1392 | 1393 | 3. Begin with the first number and explore all possible operations with the remaining numbers. 1394 | 1395 | 3.1. First operation: 14 + 8 = 22 1396 | 1397 | 3.1.1. Second operation: 22 + 8 = 30 1398 | 1399 | 3.1.1.1. Third operation: 30 - 2 = 28 1400 | 1401 | 3.1.1.1.1. Fourth operation: 28 - 5 = 23 (not equal to 24) 1402 | 1403 | 3.1.1.1.2. Fourth operation: 28 + 5 = 33 (not equal to 24) 1404 | 1405 | 3.1.1.1.3. Fourth operation: 28 * 5 = 140 (not equal to 24) 1406 | 1407 | 3.1.1.1.4. Fourth operation: 28 / 5 = 5.6 (not equal to 24) 1408 | 1409 | 3.1.1.2. Third operation: 30 + 2 = 32 1410 | 1411 | 3.1.1.2.1. Fourth operation: 32 - 5 = 27 (not equal to 24) 1412 | 1413 | 3.1.1.2.2. Fourth operation: 32 + 5 = 37 (not equal to 24) 1414 | 1415 | 3.1.1.2.3. Fourth operation: 32 * 5 = 160 (not equal to 24) 1416 | 1417 | 3.1.1.2.4. Fourth operation: 32 / 5 = 6 1418 | 1419 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 1420 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 1421 | , DO NOT RETURN ANYTHING ELSE 1422 | 1423 | 1424 | ----------- 1425 | Prompt : To achieve the following goal: ' 1426 | 1427 | 1428 | PROMPT 1429 | ################### 1430 | Use numbers and basic arithmetic operations (+ - * /) to obtain 24. When 1431 | considering the next steps, do not choose operations that will result in a 1432 | negative or fractional number. In order to help with the calculations, the 1433 | numbers in the parenthesis represent the numbers that are left after the 1434 | operations and they are in descending order. 1435 | Another thing we do is when there are only two numbers left in the parenthesis, we 1436 | check whether we can arrive at 24 only by using basic arithmetic operations 1437 | (+ - * /). Some examples regarding this idea: 1438 | (21 2) no 1439 | since 21 + 2 = 23, 21 - 2 = 19, 21 * 2 = 42, 21 / 2 = 10.5, none of which is equal 1440 | to 24. 1441 | (30 6) 30 - 6 = 24 yes 1442 | (8 3) 8 * 3 = 24 yes 1443 | (12 8) no 1444 | (48 2) 48 / 2 = 24 yes 1445 | Most importantly, do not give up, all the numbers that will be given has indeed a 1446 | solution. 1447 | 1448 | 14 8 8 2 1449 | 1450 | OBJECTIVE 1451 | ######### 1452 | 5 10 5 2 1453 | 1454 | 1455 | ################### 1456 | ', pessimistically value the context of the past solutions and more importantly the latest generated solution you had AS A FLOAT BETWEEN 0 AND 1 1457 | 1458 | Past solutions: 1459 | 1460 | 1461 | To obtain the objective of 5 10 5 2, we can decompose the task into the following subtasks: 1462 | 1463 | 1. Addition/subtraction/multiplication/division of the numbers to obtain 24. 1464 | 2. Checking if the current combination of numbers can directly result in 24. 1465 | 3. Exploring different combinations of numbers and operations to obtain 24. 1466 | 1467 | Now, let's focus on the third subtask and explore different combinations of numbers and operations: 1468 | 1469 | 1. 5 + 10 + 5 + 2 1470 | 2. 5 + 10 - 5 + 2 1471 | 3. 5 + 10 * 5 + 2 1472 | 4. 5 + 10 / 5 + 2 1473 | 5. 5 + 10 + 5 - 2 1474 | 6. 5 + 10 - 5 - 2 1475 | 7. 5 + 10 * 5 - 2 1476 | 8. 5 + 10 / 5 - 2 1477 | 9. 5 - 10 + 5 + 2 1478 | 10. 5 - 10 - 5 + 2 1479 | 11. 5 - 10 * 5 + 2 1480 | 12. 5 - 10 / 5 + 2 1481 | 13. 5 - 10 + 5 - 2 1482 | 14. 5 - 10 - 5 - 2 1483 | 15. 5 - 10 * 5 - 2 1484 | 16. 5 - 10 / 5 - 2 1485 | 17. 5 * 10 + 5 + 2 1486 | 18. 5 * 10 - 5 + 2 1487 | 19. 5 * 10 * 5 + 2 1488 | 20. 5 * 10 / 5 + 2 1489 | 21. 5 * 10 + 5 - 2 1490 | 22. 5 * 10 - 5 - 1491 | 1492 | If the solutions is not making fast progress in achieving the goal, give it a lower score. 1493 | Evaluate all solutions AS A FLOAT BETWEEN 0 and 1: 1494 | , DO NOT RETURN ANYTHING ELSE 1495 | 1496 | --------------------------------------------------------------------------------