You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example demonstrates how to use the RAP (Reasoning via Planning) operator for complex reasoning tasks. The RAP operator treats reasoning as a planning problem and uses Monte Carlo Tree Search (MCTS) to explore reasoning paths.
4
+
5
+
> **Note**: RAP currently only supports the lite version because Conductor cannot handle nested loops (loops inside loops) which are required for the MCTS algorithm.
6
+
7
+
## Overview
8
+
9
+
The example implements a RAP workflow with three main components:
10
+
11
+
1.**Input Interface**
12
+
- Handles user input for math problems
13
+
- Provides a simple CLI interface
14
+
15
+
2.**RAP Workflow**
16
+
- Uses MCTS to explore reasoning paths
17
+
- Leverages a language model for reasoning
18
+
- Finds optimal solution paths
19
+
20
+
3.**Conclude Task**
21
+
- Extracts and formats the final answer
22
+
- Presents results to the user
23
+
24
+
## Prerequisites
25
+
26
+
- Access to OpenAI API or compatible endpoint
27
+
28
+
## Setup
29
+
30
+
Configure environment variables:
31
+
```bash
32
+
export custom_openai_key="your_openai_api_key"
33
+
export custom_openai_endpoint="your_openai_endpoint"# Optional: defaults to https://api.openai.com/v1
RAP is a workflow operator that performs reasoning by treating it as a planning problem with a world model. It uses Monte Carlo Tree Search (MCTS) to explore the reasoning space and find high-reward reasoning paths.
4
+
5
+
Refer to the example in the `examples/rap` directory to understand how to use this operator.
6
+
7
+
## Overview
8
+
9
+
RAP repurposes the language model as both:
10
+
1. A world model - to predict states and simulate outcomes
11
+
2. A reasoning agent - to explore and evaluate reasoning paths
12
+
13
+
The algorithm uses MCTS to strategically explore the vast reasoning space with a proper balance between exploration and exploitation.
14
+
15
+
## Inputs, Outputs and Configs
16
+
17
+
### Inputs:
18
+
| Name | Type | Required | Description |
19
+
| ---- | ---- | -------- | ----------- |
20
+
| query | str | true | The reasoning query/problem to solve |
21
+
22
+
### Outputs:
23
+
| Name | Type | Description |
24
+
| ---- | ---- | ----------- |
25
+
| final_answer | str | The final answer/solution to the query |
26
+
27
+
### Configs:
28
+
The config of the RAP operator should be defined in a `rap_workflow.yml` file:
29
+
30
+
```yml
31
+
- name: InputInterface
32
+
- name: Selection
33
+
- name: Expansion
34
+
llm: ${sub|gpt}
35
+
- name: SimulationPreProcess
36
+
- name: SimulationPostProcess
37
+
- name: BackPropagation
38
+
- name: MCTSCompletionCheck
39
+
```
40
+
41
+
## References
42
+
43
+
[1] Hao, S., Gu, Y., Ma, H., Hong, J. J., Wang, Z., Wang, D. Z., & Hu, Z. (2023). Reasoning with Language Model is Planning with World Model. arXiv preprint arXiv:2305.14992.
0 commit comments