RL-GPT: Integrating Reinforcement Learning and Code-as-policy

Large Language Models (LLMs) have demonstrated proficiency in utilizing various tools by coding, yet they face limitations in handling intricate logic and precise control. In embodied tasks, high-level planning is amenable to direct coding, while low-level actions often necessitate task-specific refinement, such as Reinforcement Learning (RL). To seamlessly integrate both modalities, we introduce a two-level hierarchical framework, RL-GPT, comprising a slow agent and a fast agent. The slow agent analyzes actions suitable for coding, while the fast agent executes coding tasks. This decomposition effectively focuses each agent on specific tasks, proving highly efficient within our pipeline. Our approach outperforms traditional RL methods and existing GPT agents, demonstrating superior efficiency. In the Minecraft game, it rapidly obtains diamonds within a single day on an RTX3090. Additionally, it achieves SOTA performance across all designated MineDojo tasks.

Paper

Similar papers

Peer review

Reviewer ep8Y5/10 · confidence 3/52024-06-30

Summary

The authors present a framework to give LLMs the ability to code and train RL agents as a tool for completing tasks. They perform experiments in MineDojo.

Strengths

**Experiments:** Barring the standard deviation issue mentioned in teh weaknesses, the results are a significant improvement over Plan4MC. **Idea:** the method of using RL as a tool for crafting subfunctions to complete tasks via LLMs is interesting, intuitive, and simple.

Weaknesses

**Minor Issues:** - some relevant related works using LLMs to train RL agents: [https://rlvlmf2024.github.io/,](https://rlvlmf2024.github.io/) https://mihdalal.github.io/planseqlearn/, https://clvrai.github.io/boss/, https://clvrai.github.io/sprint/, https://instructionaugmentation.github.io/, https://gimme1dollar.github.io/lift/, **Clarity:** - The term “Code-as-Policy” is introduced without definition or citations in the introduction. Is this a common term? Is this referring to the [Code as Policies](https://code-as-policies.github.io/) paper? This will confuse readers who haven’t seen this term before. - The related works section doesn’t do a great job differentiating this work against prior work. For example section 2.2 doesn’t mention the current work in relation to prior work at all, same with the first paragraph of 2.3. - The method section isn’t really clear, it’s missing details, references to appendix sections, or references to figures clarifying things. Examples: - L133: If the focus is not on the reward function then how is the reward obtained? - L136: “A dedicated token is allocated for [integrating high-level actions]…” how is this trained or used? - L181: What are the inputs and outputs of $C$? image observatoins or other details from the environment state? - Overall, there’s not enough examples or details here to understand the method and how things are learned/trained without having to thoroughly dig through the appendix. For space reasons obviously not all details can be here, but I think this methods section can be rewritten to be much better. - Experiments: - L230 “It costs 3k steps for harvesting a log” what does this mean? This is the minimum number of timesteps required? or is this the empirical number the RL agent that the authors trained requires? - L232: please link to a specific section in the appendix. **Experiments:** - There are no standard deviations on any numbers, or information about # seeds in the main paper. How many seeds did you run? - Task-directed Voyager seems like a very direct comparison that uses LLMs for everything instead of RL. Why is this not compared?

Questions

See weaknesses

Rating

5

Confidence

3

Soundness

2

Presentation

2

Contribution

3

Limitations

Yes, but i think it's typical to include this in the main paper instead of the appendix.

Reviewer efny8/10 · confidence 4/52024-07-10

Summary

This paper introduces RL-GPT, a hierarchical framework that uses LLMs to first break down complex embodied tasks into sub-actions that are suitable for coding or learnable through RL, and then write codes or RL configurations to execute the actions. The authors evaluate the framework on MineDojo benchmark and the challenging ObtainDiamond task, showcasing better performance and efficiency compared to existing baselines.

Strengths

1. The integration of RL training pipeline is novel and generally applicable to other domains. 2. Strong empirical results on Minecraft tasks. Detailed ablation studies on key design choices. 3. The paper is clearly written and well presented.

Weaknesses

The proposed framework is only evaluated on the MineCraft games, which the GPTs have extensive knowledge about due to the massive relevant contents on the internet. It's unclear if the framework could be easily extended to novel domains like simple MuJoCo simulated environments, new games, or more real-world tasks, e.g. navigation or household tasks with real robots.

Questions

1. Have you tried using any smaller / open-source LLMs instead of GPT-4? How does the performance change? 2. When the fast agent fails to code up a sub-action, how does the slow agent decide if it should further break down the action into steps, or use an RL training pipeline? 3. Does the framework keep an archive of solutions (high level plans + codes / RL agents)?

Rating

8

Confidence

4

Soundness

3

Presentation

4

Contribution

3

Limitations

Yes.

Reviewer m13r5/10 · confidence 3/52024-07-13

Summary

This work is a variation of the code as policies, which utilizes LLMs to write code robotic policies in code snippets. This work examines minecraft, proposing that certain tasks can be composed into two sets: those solvable using LLM generated code and those best left to be solved using a standard RL agent. They utilize 2 LLM prompting styles. The first is for an LLM agent which decomposes tasks and determines which ones can be learned as code or using RL. The 2nd actually implements the code and inserts it into the action space for use by the RL agent. A critic LLM determines if the action was successful and how to improve it. This is used for iterative improvement of the code generating LLM.

Strengths

This deals with one of the most important problems in utilizing LLMs and code as policies, the fact that some actions are just not well suited for code and should be learned using standard RL. Ablations including removing the critic are shown. The improvements in Minecraft appear to be substantial. Overall, the paper presents a good improvement in an area of interest to many RL researchers. I generally support acceptance of this work if the limitations/broader impact are discussed.

Weaknesses

Alot of manual design is needed for each specific environment. A large amount of calls to an LLM API are used and this method becomes very expensive quickly. I would like to see how VLMs could be leveraged in other environments. The work does not explore envs outside of Minecraft. I would like to see how applications of this work could extend to other common RL envs.

Questions

Can the authors discuss the broader impact of this method in envs outside of Minecraft and how it can apply to other types of environments in robotics?

Rating

5

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

Limitations are clearly the expense of this work, could the authors discuss a bit more about this?

Reviewer LWBp7/10 · confidence 4/52024-07-21

Summary

The paper introduces RL-GPT, a novel framework that integrates Large Language Models (LLMs) with Reinforcement Learning (RL) to enhance the performance of LLM-based agents in complex, embodied environments. The primary goal is to address the limitations of LLMs in executing intricate logic and precise control, especially in open-world tasks like those found in the Minecraft game. The RL-GPT framework employs a two-level hierarchical approach, consisting of a slow agent and a fast agent. The slow agent is responsible for decomposing tasks and determining which actions can be coded directly, while the fast agent generates the corresponding code and integrates RL configurations. This division of labor allows for efficient handling of both high-level planning and low-level execution. Key contributions of the paper include: 1. Two-level hierarchical framework to determine which actions should be learned by RL and which ones can be coded (e.g. in a python). 2. The introduction of a mechanism where high-level actions coded by LLMs are appended to the RL agent’s action space, instead of only relying on low level actions. 3. Empirical validation showing that RL-GPT outperforms traditional RL methods and existing LLM agents in the Minecraft environment, particularly excelling in the ObtainDiamond task and other MineDojo tasks. In experiments, RL-GPT demonstrated superior performance, achieving state-of-the-art (SOTA) results in several tasks, including rapidly obtaining diamonds and excelling in long-horizon tasks with limited computational resources.

Strengths

**Originality**: - The paper proposes a novel integration of RL and LLMs, leveraging the strengths of both to improve task efficiency in open-world environments. - The fast agent's method of combining code-as-policy with RL by inserting high-level coded actions into the RL action space is a creative and original solution that sets RL-GPT apart from other frameworks. **Quality**: - Claims are well supported by extensive experimental results, comparing with previous SOTA methods in MineDojo **Clarity**: - The paper is generally well-written and structured, with detailed explanations of the framework components and their interactions. - Figures and tables effectively illustrate the performance improvements and workflow of RL-GPT. **Significance**: - There is often a question about the what is the right abstraction level for LLM agents to operate on: high level APIs/code-as-policies, or low level mouse/keyboard, etc. RL-GPT addresses this by trying to leverage the both, with the higher level actions appended to the RL agent’s action space. - The state-of-the-art performance in MineDojo tasks highlights its potential impact on the field, though the focus on Minecraft limits the generalizability of the results.

Weaknesses

1. The work focus on Minecraft, while useful as a testbed, may not fully represent the range of challenges present in other open-world environments. Expanding the scope of testing to other domains would enhance the significance of the work 2. While the integration approach is novel, the individual components (LLMs, RL, task decomposition) are well-known techniques. The paper could benefit from a more explicit discussion of how these components are synergistically combined to create a unique solution. 3. Some sections, particularly those describing the two-loop iteration process and the role of the critic agent, could benefit from more detailed explanations or examples to improve understanding. I am aware that the full prompts are included in the appendix and they do not fit in the main paper, however.

Questions

1. The slow agent can all a sub-action that the RL agent executes. But can the fast agent which uses “code as policies” also call the RL agent inside its loop? 2. What is the architecture and inputs of the PPO RL agent? In particular, it was said that “PPO is limited to a set of skills”: how is the sub-action (e.g. “Harvest log” sub-action 2 in Figure 3) from the slow agent represented to the policy network? Is it just a one-hot vector (“PPO is constrained to a limited set of skills”), or are you encoding the sub-action text instruction as an embedding vector, etc., or are you learning a different set of policy weights for each sub-action, or something else? 3. How would the proposed framework adapt to other open-ended environments beyond Minecraft? Are there specific modifications required for different domains? 4. (RL Interface Ablation) Do you have any hypotheses on why the action space reconstruction is more effective than designing the reward function? Is the action space shortening the horizon of the task and makes the reward less sparse? 5. Table 4: is this showing the %? In Section 4.4, it was reported as 0.34% and 0.65% success rate. Was this a typo and it’s supposed to be 34% and 65% success percentage for crafting a table? Post rebuttal: I have increased the score after the rebuttal.

Rating

7

Confidence

4

Soundness

3

Presentation

3

Contribution

4

Limitations

The authors acknowledge some limitations of their work, notably the reliance on the capabilities of LLMs and the potential challenges in generalizing to unseen data. However, there are additional limitations and assumptions that could be more explicitly addressed: 1. The approach assumes an environment with a structured observation space that can support coding as policies. This might not be feasible in more complex or less structured environments. Environments need to be compatible with the two-level hierarchical framework and provide sufficient information for task decomposition and action coding. It’ll be helpful to provide guidelines for adapting the framework to different types of environments, including those with less structured observation spaces. 2. The framework's reliance on multiple interacting agents and iterative refinement could complicate implementation and debugging. The need for specific prompts and hand written examples add to the complexity, making it challenging for broader adoption.

Reviewer ep8Y2024-08-12

Thanks for the response!. Overall, due to NeurIPS' rebuttal format, I cannot determine how the writing issues will be addressed (unless authors provide direct quotes for each part). However, I have re-read the paper again, with the proposed changes in mind, and I also saw some areas where I simply missed the author's text in answering some of my questions. Regarding experiments, I fundamentally disagree that experiments in simulation should only be run with 1 seed. VPT does use just one seed, but just because one paper uses one seed doesn't mean that should be the standard everywhere. I'm raising my score but keeping it at a borderline simply due to this standard deviation issue as I believe the paper itself has merit.

Authorsrebuttal2024-08-12

Thank you for your thoughtful feedback and for raising your score! We appreciate your insights and will carefully revise the writing issues you highlighted. We also take your point about using multiple seeds seriously and will incorporate experiments with multiple seeds in the revision.

Reviewer efny2024-08-13

Thanks for the response. I have increased my score given the additional results.

Authorsrebuttal2024-08-13

Thank you for recognizing our work and raising the score. We sincerely appreciate your valuable suggestions and will ensure they are incorporated in the revision.

Reviewer LWBp2024-08-14

Thank you for the detailed response addressing my questions and concerns regarding generalization to other environments, how the components are combined and more detailed explanations. I have increased my score to 7.

Authorsrebuttal2024-08-14

Thank you for your insightful comments and questions, which have greatly improved the quality of our paper. We deeply appreciate your recognition and the score increase! We will carefully integrate the results discussed with you into the revision.

Program Chairsdecision2024-09-25

Decision

Accept (oral)

© 2026 NYSGPT2525 LLC