Designing reward functions is a longstanding challenge in reinforcement learning (RL); it requires specialized knowledge or domain data, leading to high costs for development. To address this, we introduce Text2Reward, a data-free framework that automates the generation and shaping of dense reward functions based on large language models (LLMs). Given a goal described in natural language, Text2Reward generates shaped dense reward functions as an executable program grounded in a compact representation of the environment. Unlike inverse RL and recent work that uses LLMs to write sparse reward codes or unshaped dense rewards with a constant function across timesteps, Text2Reward produces interpretable, free-form dense reward codes that cover a wide range of tasks, utilize existing packages, and allow iterative refinement with human feedback. We evaluate Text2Reward on two robotic manipulation benchmarks (ManiSkill2, MetaWorld) and two locomotion environments of MuJoCo. On 13 of the 17 manipulation tasks, policies trained with generated reward codes achieve similar or better task success rates and convergence speed than expert-written reward codes. For locomotion tasks, our method learns six novel locomotion behaviors with a success rate exceeding 94%. Furthermore, we show that the policies trained in the simulator with our method can be deployed in the real world. Finally, Text2Reward further improves the policies by refining their reward functions with human feedback. Video results are available at https://text-to-reward.github.io/ .
翻译:设计奖励函数是强化学习(RL)中长期存在的挑战;它需要专业知识或领域数据,导致开发成本高昂。为解决此问题,我们提出了Text2Reward,一个基于大型语言模型(LLMs)的、无需数据的框架,用于自动化生成和塑形密集奖励函数。给定一个用自然语言描述的目标,Text2Reward生成塑形后的密集奖励函数,作为基于环境紧凑表示的可执行程序。与逆强化学习以及近期利用LLMs编写稀疏奖励代码或跨时间步为恒定函数的未塑形密集奖励的研究不同,Text2Reward生成可解释的、自由形式的密集奖励代码,这些代码覆盖广泛的任务,利用现有软件包,并允许通过人类反馈进行迭代优化。我们在两个机器人操作基准(ManiSkill2, MetaWorld)和两个MuJoCo运动环境上评估了Text2Reward。在17个操作任务中的13个上,使用生成的奖励代码训练的策略达到了与专家编写的奖励代码相似或更优的任务成功率和收敛速度。对于运动任务,我们的方法学习了六种新颖的运动行为,成功率超过94%。此外,我们展示了在模拟器中使用我们的方法训练的策略可以部署到现实世界中。最后,Text2Reward通过人类反馈优化奖励函数,进一步改进了策略。视频结果可见于 https://text-to-reward.github.io/ 。