Skip to content

1ring2rta/MCTS-GRPO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

MCTS-GRPO

GRPO is awesome, letโ€™s put a tree on it! ๐ŸŒฒ๐ŸŒŸ Exploration gets smarter when it follows the branches. ๐ŸŒฑ

Architecture

For a quick start, set up your environment through this:

conda create --prefix /root/r1-engine python==3.11
conda activate /root/r1-engine

pip install "torch==2.5.1" tensorboard "setuptools<71.0.0"
pip install flash-attn

pip install  --upgrade \
  "transformers==4.48.1" \
  "datasets==3.1.0" \
  "accelerate==1.3.0" \
  "hf-transfer==0.1.9" \
  "deepspeed==0.15.3" \
  "trl==0.14.0" \
  "vllm==0.7.0"

pip install graphviz
pip install openpyxl

Qwen2.5-7B, Trained on WikiTQ

Task Dataset Qwen2.5-7B-Instruct MCTS+GRPO
TableQA FEVEROUS
WikiTQ 68.55% 75.62%
HybridQA
Math GSM8K
AIME

Math Example

step3: step3 step6: step6 step9: step9 step100: step100 step200: step200

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ PROMPT โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ # User Question:                                                             โ”‚
โ”‚ Solve the following math problem step by step. You have two action that you  โ”‚
โ”‚ can do thinking and answering. Plz put your thinking in a <think></think>    โ”‚
โ”‚ block, and answer in a <answer></answer> block. Question:                    โ”‚
โ”‚ Let $S$ be the solid in three-dimensional space consisting of all points (   โ”‚
โ”‚ $x, y, z$ ) satisfying the following system of six simultaneous conditions:  โ”‚
โ”‚ $$                                                                           โ”‚
โ”‚ \begin{aligned}                                                              โ”‚
โ”‚ & x \geqslant 0, \quad y \geqslant 0, \quad z \geqslant 0 \\                 โ”‚
โ”‚ & x+y+z<11, \\                                                               โ”‚
โ”‚ & 2 x+4 y+3 z \leqslant 36 \\                                                โ”‚
โ”‚ & 2 x+3 z \leqslant 24.                                                      โ”‚
โ”‚ \end{aligned}                                                                โ”‚
โ”‚ $$                                                                           โ”‚
โ”‚  Determine the number $v$ of vertices of $S$.<|im_end|>                      โ”‚
โ”‚ <|im_start|>assistant                                                        โ”‚
โ”‚ STEP-1:                                                                      โ”‚
โ”‚ <think>                                                                      โ”‚
โ”‚ To determine the number of vertices of the solid \( S \), we need to find    โ”‚
โ”‚ the points where the boundaries of the inequalities intersect. Each vertex   โ”‚
โ”‚ of the solid is a point where three inequalities meet. We need to solve the  โ”‚
โ”‚ system of equations formed by the intersections of these inequalities.       โ”‚
โ”‚                                                                              โ”‚
โ”‚ The inequalities are:                                                        โ”‚
โ”‚ 1. \( x \geq 0 \)                                                            โ”‚
โ”‚ 2. \( y \geq 0 \)                                                            โ”‚
โ”‚ 3. \( z \geq 0 \)                                                            โ”‚
โ”‚ 4. \( x + y + z < 11 \)                                                      โ”‚
โ”‚ 5. \( 2x + 4y + 3z \leq 36 \)                                                โ”‚
โ”‚ 6. \( 2x + 3z \leq 24 \)                                                     โ”‚
โ”‚                                                                              โ”‚
โ”‚ To find the vertices, we will solve the system of equations formed by        โ”‚
โ”‚ setting the inequalities as equalities and checking for non-negative         โ”‚
โ”‚ solutions.                                                                   โ”‚
โ”‚ </think><|im_end|>                                                           โ”‚
โ”‚ <|im_start|>assistant                                                        โ”‚
โ”‚ STEP-2:                                                                      โ”‚
โ”‚ <think>                                                                      โ”‚
โ”‚ We will solve the following systems of equations to find the vertices:       โ”‚
โ”‚                                                                              โ”‚
โ”‚ 1. \( x + y + z = 11 \), \( 2x + 4y + 3z = 36 \), \( 2x + 3z = 24 \)         โ”‚
โ”‚ 2. \( x + y + z = 11 \), \( 2x + 4y + 3z = 36 \), \( z = 0 \)                โ”‚
โ”‚ 3. \( x + y + z = 11 \), \( 2x + 4y + 3z = 36 \), \( y = 0 \)                โ”‚
โ”‚ 4. \( x + y + z = 11 \), \( 2x + 3z = 24 \), \( z = 0 \)                     โ”‚
โ”‚ 5. \( x + y + z = 11 \), \( 2x + 3z = 24 \), \( y = 0 \)                     โ”‚
โ”‚ 6. \( 2x + 4y + 3z = 36 \), \( 2x + 3z = 24 \), \( z = 0 \)                  โ”‚
โ”‚ 7. \( 2x + 4y + 3z = 36 \), \( 2x + 3z = 24 \), \( y = 0 \)                  โ”‚
โ”‚ 8. \( 2x + 4y + 3z = 36 \), \( z = 0 \), \( y = 0 \)                         โ”‚
โ”‚ 9. \( 2x + 3z = 24 \), \( y = 0 \), \( z = 0 \)                              โ”‚
โ”‚ 10. \( x + y + z = 11 \), \( z = 0 \), \( y = 0 \)                           โ”‚
โ”‚ 11. \( x + y + z = 11 \), \( 2x + 4y = 36 \), \( z = 0 \)                    โ”‚
โ”‚                                                                              โ”‚
โ”‚ Let's solve these systems step by step.                                      โ”‚
โ”‚ </think>                                                                     โ”‚
โ”‚                                                                              โ”‚
โ”‚ <tool_call>                                                                  โ”‚
โ”‚ {"name": "execute_python_code", "arguments": {"code": "from sympy import     โ”‚
โ”‚ symbols, Eq, solve\n\nx, y, z = symbols('x y z')\n\n# System 1\neq1 = Eq(x + โ”‚
โ”‚ y + z, 11)\neq2 = Eq(2*x + 4*y + 3*z, 36)\neq3 = Eq(2*x + 3*z, 24)\n\n#      โ”‚
โ”‚ Solve the system\nsolution1 = solve((eq1, eq2, eq3), (x, y, z))\n\n# System  โ”‚
โ”‚ 2\neq4 = Eq(2*x + 4*y + 3*z, 36)\neq5 = Eq(z, 0)\n\n# Solve the              โ”‚
โ”‚ system\nsolution2 = solve((eq1, eq4, eq5), (x, y, z))\n\n# System 3\neq6 =   โ”‚
โ”‚ Eq(2*x + 4*y + 3*z, 36)\neq7 = Eq(y, 0)\n\n# Solve the system\nsolution3 =   โ”‚
โ”‚ solve((eq1, eq6, eq7), (x, y, z))\n\n# System 4\neq8 = Eq(x + y + z,         โ”‚
โ”‚ 11)\neq9 = Eq(2*x + 3*z, 24)\neq10 = Eq(z, 0)\n\n# Solve the                 โ”‚
โ”‚ system\nsolution4 = solve((eq8, eq9, eq10), (x, y, z))\n\n# System 5\neq11 = โ”‚
โ”‚ Eq(x + y + z, 11)\neq12 = Eq(2*x + 3*z, 24)\neq13 = Eq(y, 0)\n\n# Solve the  โ”‚
โ”‚ system\nsolution5 = solve((eq11, eq12, eq13), (x, y, z))\n\n# System 6\neq14 โ”‚
โ”‚ = Eq(2*x + 4*y + 3*z, 36)\neq15 = Eq(2*x + 3*z, 24)\neq16 = Eq(z, 0)\n\n#    โ”‚
โ”‚ Solve the system\nsolution6 = solve((eq14, eq15, eq16), (x, y, z))\n\n#      โ”‚
โ”‚ System 7\neq17 = Eq(2*x + 4*y + 3*z, 36)\neq18 = Eq(2*x + 3*z, 24)\neq19 =   โ”‚
โ”‚ Eq(y, 0)\n\n# Solve the system\nsolution7 = solve((eq17, eq18, eq19), (x, y, โ”‚
โ”‚ z))\n\n# System 8\neq20 = Eq(2*x + 4*y + 3*z, 36)\neq21 = Eq(z, 0)\neq22 =   โ”‚
โ”‚ Eq(y, 0)\n\n# Solve the system\nsolution8 = solve((eq20, eq21, eq22), (x, y, โ”‚
โ”‚ z))\n\n# System 9\neq23 = Eq(2*x + 3*z, 24)\neq24 = Eq(y, 0)\neq25 = Eq(z,   โ”‚
โ”‚ 0)\n\n# Solve the system\nsolution9 = solve((eq23, eq24, eq25), (x, y,       โ”‚
โ”‚ z))\n\n# System 10\neq26 = Eq(x + y + z, 11)\neq27 = Eq(z, 0)\neq28 = Eq(y,  โ”‚
โ”‚ 0)\n\n# Solve the system\nsolution10 = solve((eq26, eq27, eq28), (x, y,      โ”‚
โ”‚ z))\n\n# System 11\neq29 = Eq(x + y + z, 11)\neq30 = Eq(2*x + 4*y, 36)\neq31 โ”‚
โ”‚ = Eq(z, 0)\n\n# Solve the system\nsolution11 = solve((eq29, eq30, eq31), (x, โ”‚
โ”‚ y, z))\n\nsolution1, solution2, solution3, solution4, solution5, solution6,  โ”‚
โ”‚ solution7, solution8, solution9, solution10, solution11"}}                   โ”‚
โ”‚ </tool_call><|im_end|>                                                       โ”‚
โ”‚ <|im_start|>user                                                             โ”‚
โ”‚ <tool_response>                                                              โ”‚
โ”‚ Var: eq25; Type: Equality                                                    โ”‚
โ”‚ Eq(z, 0)                                                                     โ”‚
โ”‚ Var: solution9; Type: dict                                                   โ”‚
โ”‚ dict(dict_items([(x, 12), (y, 0), (z, 0)]))                                  โ”‚
โ”‚ Var: eq26; Type: Equality                                                    โ”‚
โ”‚ Eq(x + y + z, 11)                                                            โ”‚
โ”‚ Var: eq27; Type: Equality                                                    โ”‚
โ”‚ Eq(z, 0)                                                                     โ”‚
โ”‚ Var: eq28; Type: Equality                                                    โ”‚
โ”‚ Eq(y, 0)                                                                     โ”‚
โ”‚ Var: solution10; Type: dict                                                  โ”‚
โ”‚ dict(dict_items([(x, 11), (y, 0), (z, 0)]))                                  โ”‚
โ”‚ Var: eq29; Type: Equality                                                    โ”‚
โ”‚ Eq(x + y + z, 11)                                                            โ”‚
โ”‚ Var: eq30; Type: Equality                                                    โ”‚
โ”‚ Eq(2*x + 4*y, 36)                                                            โ”‚
โ”‚ Var: eq31; Type: Equality                                                    โ”‚
โ”‚ Eq(z, 0)                                                                     โ”‚
โ”‚ Var: solution11; Type: dict                                                  โ”‚
โ”‚ dict(dict_items([(x, 4), (y, 7), (z, 0)]))                                   โ”‚
โ”‚ </tool_response><|im_end|>                                                   โ”‚
โ”‚ <|im_start|>assistant                                                        โ”‚
โ”‚                                                                              โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ COMPLETION โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ STEP-3:                                                                      โ”‚
โ”‚ <think>                                                                      โ”‚
โ”‚ We have solved the systems of equations and found the following solutions:   โ”‚
โ”‚                                                                              โ”‚
โ”‚ 1. \( (x, y, z) = (3, 5, 3) \)                                               โ”‚
โ”‚ 2. \( (x, y, z) = (9, 2, 0) \)                                               โ”‚
โ”‚ 3. \( (x, y, z) = (7, 0, 4) \)                                               โ”‚
โ”‚ 4. \( (x, y, z) = (11, 0, 0) \)                                              โ”‚
โ”‚ 5. \( (x, y, z) = (6, 0, 0) \)                                               โ”‚
โ”‚ 6. \( (x, y, z) = (9, 0, 0) \) (This solution is a repetition of solution 2) โ”‚
โ”‚ 7. \( (x, y, z) = (12, 0, 0) \) (This solution is not valid because \( x + y โ”‚
โ”‚ + z > 11 \))                                                                 โ”‚
โ”‚ 8. \( (x, y, z) = (0, 0, 0) \)                                               โ”‚
โ”‚ 9. \( (x, y, z) = (12, 0, 0) \) (Again, this solution is not valid)          โ”‚
โ”‚ 10. \( (x, y, z) = (11, 0, 0) \) (This solution is a repetition of solution  โ”‚
โ”‚ 4)                                                                           โ”‚
โ”‚ 11. \( (x, y, z) = (4, 7, 0) \)                                              โ”‚
โ”‚                                                                              โ”‚
โ”‚ After removing the repeated and invalid solutions, we have the following     โ”‚
โ”‚ unique vertices:                                                             โ”‚
โ”‚ 1. \( (3, 5, 3) \)                                                           โ”‚
โ”‚ 2. \( (9, 2, 0) \)                                                           โ”‚
โ”‚ 3. \( (7, 0, 4) \)                                                           โ”‚
โ”‚ 4. \( (11, 0, 0) \)                                                          โ”‚
โ”‚ 5. \( (6, 0, 0) \)                                                           โ”‚
โ”‚ 6. \( (0, 0, 0) \)                                                           โ”‚
โ”‚ 7. \( (4, 7, 0) \)                                                           โ”‚
โ”‚                                                                              โ”‚
โ”‚ Therefore, the number of vertices of the solid \( S \) is 7.                 โ”‚
โ”‚ </think>                                                                     โ”‚
โ”‚ <answer>7</answer>                                                           โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ GROUND TRUTH โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ 7                                                                            โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

About

Policy Optimization is awesome, letโ€™s put a tree on it! ๐ŸŒฒ๐ŸŒŸ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages