Skip to content

Notebook tutorial for Tree of Thoughts #2105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update blog
  • Loading branch information
rahulbshrestha committed Jun 25, 2024
commit 6ed80ebd49340e9a4481440a9abfc65c2e295c06
207 changes: 153 additions & 54 deletions tree-of-thoughts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,32 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3a9253adff2a409084d62fe896a7b04e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HTML(value='<center> <img\\nsrc=https://huggingface.co/front/assets/huggingface_logo-noborder.sv…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from huggingface_hub import notebook_login\n",
"notebook_login()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -56,9 +81,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "88f02e1c34f74ab1867bc7cc9395693c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Loading checkpoint shards: 0%| | 0/3 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"model_id = \"mistralai/Mistral-7B-v0.3\"\n",
"model = AutoModelForCausalLM.from_pretrained(model_id)\n",
Expand All @@ -74,13 +114,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n"
]
},
{
"data": {
"text/plain": [
"'Hi! My name is 👋\\n\\nI’m a software engineer and a designer. I’m currently working at Google as a software engineer.\\n\\nI’m passionate about building products that people love. I’m also passionate about building products that are accessible to everyone.\\n\\nI’m a big fan of open source software. I’ve contributed to a few open source projects, including React Native, React, and Redux.\\n\\nI’m also a big fan of the'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def mistral(prompt):\n",
" inputs = tokenizer(prompt, return_tensors=\"pt\")\n",
" outputs = model.generate(**inputs, max_new_tokens=20)\n",
" outputs = model.generate(**inputs, max_new_tokens=100)\n",
" return tokenizer.decode(outputs[0], skip_special_tokens=True)\n",
"\n",
"mistral(\"Hi! My name is \")"
Expand All @@ -95,7 +153,7 @@
},
{
"cell_type": "code",
"execution_count": 62,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -116,7 +174,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -164,7 +222,7 @@
" - Depth first search\n",
"\n",
"\n",
"In this tutorial, we'll be using ToT with OpenAI's GPT-3.5 Turbo to solve the Game of 24.\n",
"In this tutorial, we'll be using ToT with Mistral-7B-v0.3 to solve the Game of 24.\n",
"\n",
"The Game of 24 is a task where given a sequence of 4 numbers, we’ll need to find the correct mathematical operations (add, subtract, multiply, divide) that’ll lead to the number 24. For example, if the sequence is {4, 9, 10, 13}, the correct operations using the 4 numbers are: (10 - 4) * (13 - 9) = 24. Each number in the sequence can only be used once.\n",
"\n",
Expand All @@ -189,7 +247,7 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -246,8 +304,7 @@
"Input: {input}\n",
"'''\n",
"\n",
"# 1-shot\n",
"propose_prompt = '''Input: 2 8 8 14\n",
"generate_prompt = '''Input: 2 8 8 14\n",
"Possible next steps:\n",
"2 + 8 = 10 (left: 8 10 14)\n",
"8 / 2 = 4 (left: 4 8 14)\n",
Expand Down Expand Up @@ -358,7 +415,7 @@
},
{
"cell_type": "code",
"execution_count": 65,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -372,7 +429,7 @@
" if current_numbers == '24':\n",
" prompt = cot_prompt.format(input=data) + 'Steps: ' + thought\n",
" else:\n",
" prompt = propose_prompt.format(input=current_numbers)\n",
" prompt = generate_prompt.format(input=current_numbers)\n",
"\n",
" return prompt\n",
"\n",
Expand All @@ -388,7 +445,8 @@
" prompt = prepare_generate_prompt(current_numbers, thought, data)\n",
" \n",
" # Generate thoughts with prompt\n",
" proposals = gpt(prompt, n=1, stop=None)[0].split('\\n')\n",
" proposals = mistral(prompt).split('\\n')\n",
" #proposals = gpt(prompt, n=1, stop=None)[0].split('\\n')\n",
" new_thoughts.extend([thought + _ + '\\n' for _ in proposals])\n",
"\n",
" return new_thoughts"
Expand Down Expand Up @@ -417,7 +475,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -439,7 +497,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -461,16 +519,16 @@
},
{
"cell_type": "code",
"execution_count": 66,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"def evaluate_thoughts(data, thoughts, n_evaluate_sample):\n",
" scores = []\n",
" for thought in thoughts:\n",
" evaluate_prompt = prepare_evaluate_prompt(data, thought)\n",
" evaluate_outputs = gpt(evaluate_prompt, n=n_evaluate_sample, stop=None)\n",
" print('Value outputs: ', evaluate_outputs)\n",
" #evaluate_outputs = gpt(evaluate_prompt, n=n_evaluate_sample, stop=None)\n",
" evaluate_outputs = mistral(evaluate_prompt)\n",
" score = evaluate_outputs_unwrap(thought, evaluate_outputs)\n",
" scores.append(score)\n",
" return scores"
Expand All @@ -492,7 +550,7 @@
},
{
"cell_type": "code",
"execution_count": 67,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -518,7 +576,7 @@
},
{
"cell_type": "code",
"execution_count": 68,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -527,7 +585,7 @@
},
{
"cell_type": "code",
"execution_count": 69,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -536,24 +594,24 @@
"\n",
"def solve(model, temperature, n_evaluate_sample, n_select_sample):\n",
"\n",
" global gpt\n",
" gpt = partial(gpt, model=model, temperature=temperature)\n",
" #global gpt\n",
" #gpt = partial(gpt, model=model, temperature=temperature)\n",
" \n",
" thoughts = ['']\n",
" data = '4 5 6 10'\n",
"\n",
" steps = 4\n",
" steps = 1\n",
"\n",
" for step in range(steps):\n",
"\n",
" print('Step Number ::', step)\n",
" print('(Step 0) Thoughts: ', thoughts)\n",
" print('(Step 0) Current Thoughts: ', thoughts)\n",
"\n",
" # Step 1: Thought Generation\n",
" new_thoughts = generate_thoughts(data, thoughts)\n",
" ids = list(range(len(new_thoughts)))\n",
"\n",
" print('(Step 1) new_thoughts: ', new_thoughts)\n",
" print('(Step 1) New Thoughts: ', new_thoughts)\n",
" print('(Step 1) ids ', ids)\n",
"\n",
" # Step 2: Thought Evaluation\n",
Expand All @@ -574,41 +632,82 @@
},
{
"cell_type": "code",
"execution_count": 70,
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Step Number :: 0\n",
"(Step 0) Current Thoughts: ['']\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(Step 1) New Thoughts: ['Input: 2 8 8 14\\n', 'Possible next steps:\\n', '2 + 8 = 10 (left: 8 10 14)\\n', '8 / 2 = 4 (left: 4 8 14)\\n', '14 + 2 = 16 (left: 8 8 16)\\n', '2 * 8 = 16 (left: 8 14 16)\\n', '8 - 2 = 6 (left: 6 8 14)\\n', '14 - 8 = 6 (left: 2 6 8)\\n', '14 / 2 = 7 (left: 7 8 8)\\n', '14 - 2 = 12 (left: 8 8 12)\\n', 'Input: 4 5 6 10\\n', 'Possible next steps:\\n', '4 + 5 = 9 (left: 5 6 10)\\n', '5 / 4 = 1 (left: 1 5 6)\\n', '6 + 5 = 11 (left: 5 6 11)\\n', '6 - 5 = 1 (left: 1 6 11)\\n', '10 + 4 = 14 (left: 4 6 14)\\n', '4 * \\n']\n",
"(Step 1) ids [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"functools.partial(<function gpt at 0x15fe828e0>, model='gpt-3.5-turbo', temperature=0.7)\n",
"STEP NUMBER ::::: 0\n",
"(Step 0) Thoughts so far: ['']\n",
"(Step 1) new_thoughts: ['4 + 5 = 9 (left: 6 9 10)\\n', '5 + 6 = 11 (left: 4 11 10)\\n', '6 + 4 = 10 (left: 10 5 6)\\n', '10 - 4 = 6 (left: 6 5 10)\\n', '6 * 5 = 30 (left: 4 30 10)\\n', '10 - 5 = 5 (left: 4 6 5)\\n', '10 - 6 = 4 (left: 4 5 10)\\n', '6 / 4 = 1.5 (left: 5 1.5 10)\\n']\n",
"(Step 1) ids [0, 1, 2, 3, 4, 5, 6, 7]\n",
"(Step 2) Values: [2.001, 1.002, 3.0, 21.001, 41.0, 41.0, 22.0, 2.0]\n",
"(Step 3) Selected new thoughts: ['6 * 5 = 30 (left: 4 30 10)\\n', '10 - 5 = 5 (left: 4 6 5)\\n', '10 - 6 = 4 (left: 4 5 10)\\n', '10 - 4 = 6 (left: 6 5 10)\\n', '6 + 4 = 10 (left: 10 5 6)\\n']\n",
"-----------------------------------------------------------------------------------------------------------------\n",
"STEP NUMBER ::::: 1\n",
"(Step 0) Thoughts so far: ['6 * 5 = 30 (left: 4 30 10)\\n', '10 - 5 = 5 (left: 4 6 5)\\n', '10 - 6 = 4 (left: 4 5 10)\\n', '10 - 4 = 6 (left: 6 5 10)\\n', '6 + 4 = 10 (left: 10 5 6)\\n']\n",
"(Step 1) new_thoughts: ['6 * 5 = 30 (left: 4 30 10)\\n4 + 30 = 34 (left: 10 34)\\n', '6 * 5 = 30 (left: 4 30 10)\\n30 / 4 = 7.5 (left: 7.5 10)\\n', '6 * 5 = 30 (left: 4 30 10)\\n10 + 4 = 14 (left: 14 30)\\n', '6 * 5 = 30 (left: 4 30 10)\\n4 * 30 = 120 (left: 10 120)\\n', '6 * 5 = 30 (left: 4 30 10)\\n30 - 4 = 26 (left: 26 10)\\n', '6 * 5 = 30 (left: 4 30 10)\\n10 / 4 = 2.5 (left: 2.5 10)\\n', '6 * 5 = 30 (left: 4 30 10)\\n30 - 10 = 20 (left: 4 20)\\n', '6 * 5 = 30 (left: 4 30 10)\\n30 / 10 = 3 (left: 3 4)\\n', '10 - 5 = 5 (left: 4 6 5)\\n4 + 6 = 10 (left: 5 10)\\n', '10 - 5 = 5 (left: 4 6 5)\\n6 - 4 = 2 (left: 2 5)\\n', '10 - 5 = 5 (left: 4 6 5)\\n4 * 6 = 24 (left: 5 24)\\n', '10 - 5 = 5 (left: 4 6 5)\\n6 / 4 = 1.5 (left: 1.5 5)\\n', '10 - 5 = 5 (left: 4 6 5)\\n5 + 4 = 9 (left: 6 9)\\n', '10 - 5 = 5 (left: 4 6 5)\\n5 - 4 = 1 (left: 1 6)\\n', '10 - 5 = 5 (left: 4 6 5)\\nInput: 3 9 4 12\\n', '10 - 5 = 5 (left: 4 6 5)\\nPossible next steps:\\n', '10 - 5 = 5 (left: 4 6 5)\\n3 + 9 = 12 (left: 4 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n9 / 3 = 3 (left: 3 4 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n4 * 3 = 12 (left: 12 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n12 - 3 = 9 (left: 9 4 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n9 / 3 = 3 (left: 4 3 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n12 - 4 = 8 (left: 3 8 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n12 / 4 = 3 (left: 3 9 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n9 + 3 = 12 (left: 4 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n9 - 3 = 6 (left: 6 4 12)\\n', '10 - 6 = 4 (left: 4 5 10)\\n4 + 5 = 9 (left: 9 10)\\n', '10 - 6 = 4 (left: 4 5 10)\\n5 * 4 = 20 (left: 20 10)\\n', '10 - 6 = 4 (left: 4 5 10)\\n10 - 4 = 6 (left: 6 5)\\n', '10 - 6 = 4 (left: 4 5 10)\\n10 / 5 = 2 (left: 4 2)\\n', '10 - 6 = 4 (left: 4 5 10)\\n5 - 4 = 1 (left: 1 10)\\n', '10 - 6 = 4 (left: 4 5 10)\\n10 - 5 = 5 (left: 4 5)\\n', '10 - 6 = 4 (left: 4 5 10)\\nInput: 1 3 5 7\\n', '10 - 6 = 4 (left: 4 5 10)\\nPossible next steps:\\n', '10 - 6 = 4 (left: 4 5 10)\\n1 + 3 = 4 (left: 4 5 7)\\n', '10 - 6 = 4 (left: 4 5 10)\\n3 * 5 = 15 (left: 1 15 7)\\n', '10 - 6 = 4 (left: 4 5 10)\\n7 - 1 = 6 (left: 6 5 7)\\n', '10 - 6 = 4 (left: 4 5 10)\\n5 - 3 = 2 (left: 1 2 7)\\n', '10 - 6 = 4 (left: 4 5 10)\\n7 - 5 = 2 (left: 1 3 2)\\n', '10 - 6 = 4 (left: 4 5 10)\\n7 - 3 = 4 (left: 1 5 4)\\n', '10 - 6 = 4 (left: 4 5 10)\\n7 / 1 = 7 (left: 3 5 7)\\n', '10 - 4 = 6 (left: 6 5 10)\\n6 + 5 = 11 (left: 10)\\n', '10 - 4 = 6 (left: 6 5 10)\\n6 * 5 = 30 (left: 10)\\n', '10 - 4 = 6 (left: 6 5 10)\\n6 - 5 = 1 (left: 1 10)\\n', '10 - 4 = 6 (left: 6 5 10)\\n5 * 10 = 50 (left: 6)\\n', '10 - 4 = 6 (left: 6 5 10)\\n5 + 10 = 15 (left: 6)\\n', '10 - 4 = 6 (left: 6 5 10)\\n10 - 6 = 4 (left: 4 5)\\n', '10 - 4 = 6 (left: 6 5 10)\\n10 / 5 = 2 (left: 6)\\n', '10 - 4 = 6 (left: 6 5 10)\\nInput: 3 9 27\\n', '10 - 4 = 6 (left: 6 5 10)\\nPossible next steps:\\n', '10 - 4 = 6 (left: 6 5 10)\\n3 * 9 = 27 (left: 27)\\n', '10 - 4 = 6 (left: 6 5 10)\\n3 + 9 = 12 (left: 12 27)\\n', '10 - 4 = 6 (left: 6 5 10)\\n9 / 3 = 3 (left: 3 27)\\n', '10 - 4 = 6 (left: 6 5 10)\\n9 * 27 = 243 (left: 3)\\n', '10 - 4 = 6 (left: 6 5 10)\\n9 + 27 = 36 (left: 3)\\n', '10 - 4 = 6 (left: 6 5 10)\\n27 / 3 = 9 (left: 9)\\n', '10 - 4 = 6 (left: 6 5 10)\\n27 - 9 = 18 (left: 3)\\n', '10 - 4 = 6 (left: 6 5 10)\\n9 - 3 = 6 (left: 6 27)\\n', '10 - 4 = 6 (left: 6 5 10)\\nInput: 4 2 2\\n', '10 - 4 = 6 (left: 6 5 10)\\nPossible next steps:\\n', '10 - 4 = 6 (left: 6 5 10)\\n4 + 2 = 6 (left: 2 6)\\n', '10 - 4 = 6 (left: 6 5 10)\\n4 * 2 = 8 (left: 2 8)\\n', '10 - 4 = 6 (left: 6 5 10)\\n4 / 2 = 2 (left: 2 2)\\n', '10 - 4 = 6 (left: 6 5 10)\\n2 * 2 = 4 (left: 4 2)\\n', '10 - 4 = 6 (left: 6 5 10)\\n2 / 2 = 1 (left: 1 2)\\n', '10 - 4 = 6 (left: 6 5 10)\\n2 + 2 = 4 (left: 4)\\n', '10 - 4 = 6 (left: 6 5 10)\\n2 - 2 = 0 (left: 4)\\n', '10 - 4 = 6 (left: 6 5 10)\\n4 - 2 = 2 (left: 2 2)\\n', '6 + 4 = 10 (left: 10 5 6)\\n10 + 5 = 15 (left: 6 15)\\n', '6 + 4 = 10 (left: 10 5 6)\\n10 / 5 = 2 (left: 2 6)\\n', '6 + 4 = 10 (left: 10 5 6)\\n10 - 5 = 5 (left: 5 6)\\n', '6 + 4 = 10 (left: 10 5 6)\\n5 + 6 = 11 (left: 10 11)\\n', '6 + 4 = 10 (left: 10 5 6)\\n6 - 5 = 1 (left: 1 6)\\n']\n",
"(Step 1) ids [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71]\n",
"(Step 2) Values: [0.003, 0.003, 20.002, 0.002, 0.003, 0.003, 40.001, 21.0, 0.003, 60.0, 0.002, 1.001, 0.003, 60.0, 0.002, 0.003, 0.003, 40.001, 40.001, 60.0, 60.0, 40.001, 1.002, 0.003, 60.0, 0.003, 0.001, 0.002, 1.001, 60.0, 40.001, 0.003, 0.003, 1.002, 2.0, 2.001, 1.002, 3.0, 2.0, 3.0, 0.002, 0.002, 60.0, 0.003, 0.003, 40.001, 0.003, 0.003, 0.003, 0.002, 0.003, 60.0, 0.0, 0.0, 0.003, 0.002, 0.003, 0.002, 0.003, 1.0, 1.002, 1.0, 1.0, 0.003, 0.0, 0.002, 21.0, 0.003, 0.003, 0.002, 0.003, 60.0]\n",
"(Step 3) Selected new thoughts: ['10 - 5 = 5 (left: 4 6 5)\\n6 - 4 = 2 (left: 2 5)\\n', '10 - 5 = 5 (left: 4 6 5)\\n5 - 4 = 1 (left: 1 6)\\n', '10 - 5 = 5 (left: 4 6 5)\\n12 - 3 = 9 (left: 9 4 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n9 / 3 = 3 (left: 4 3 12)\\n', '10 - 5 = 5 (left: 4 6 5)\\n9 - 3 = 6 (left: 6 4 12)\\n']\n",
"-----------------------------------------------------------------------------------------------------------------\n"
"(Step 2) Scores: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]\n",
"(Step 3) Selected new thoughts: ['Input: 2 8 8 14\\n', 'Possible next steps:\\n', '2 + 8 = 10 (left: 8 10 14)\\n', '8 / 2 = 4 (left: 4 8 14)\\n', '14 + 2 = 16 (left: 8 8 16)\\n']\n",
"--------\n"
]
},
{
"data": {
"text/plain": [
"['10 - 5 = 5 (left: 4 6 5)\\n6 - 4 = 2 (left: 2 5)\\n',\n",
" '10 - 5 = 5 (left: 4 6 5)\\n5 - 4 = 1 (left: 1 6)\\n',\n",
" '10 - 5 = 5 (left: 4 6 5)\\n12 - 3 = 9 (left: 9 4 12)\\n',\n",
" '10 - 5 = 5 (left: 4 6 5)\\n9 / 3 = 3 (left: 4 3 12)\\n',\n",
" '10 - 5 = 5 (left: 4 6 5)\\n9 - 3 = 6 (left: 6 4 12)\\n']"
"['Input: 2 8 8 14\\n',\n",
" 'Possible next steps:\\n',\n",
" '2 + 8 = 10 (left: 8 10 14)\\n',\n",
" '8 / 2 = 4 (left: 4 8 14)\\n',\n",
" '14 + 2 = 16 (left: 8 8 16)\\n']"
]
},
"execution_count": 70,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -620,9 +719,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "transformers",
"display_name": "Python [conda env:.conda-rahul_env]",
"language": "python",
"name": "python3"
"name": "conda-env-.conda-rahul_env-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -634,9 +733,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}