Skip to main content
QUICK REVIEW

[Paper Review] Text2Reward: Reward Shaping with Language Models for Reinforcement Learning

Tianbao Xie, Siheng Zhao|arXiv (Cornell University)|Sep 20, 2023
Software Engineering ResearchComputer Science8 citations
TL;DR

Text2Reward automates dense reward function generation for RL using LLMs, enabling data-free, interpretable reward codes that guide training across manipulation and locomotion tasks, with human-in-the-loop refinement.

ABSTRACT

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/ .

Motivation & Objective

  • Reduce manual effort and cost in reward design for RL by using natural language goals.
  • Generate dense, executable reward code grounded in a compact environment representation.
  • Enable zero-shot and few-shot reward generation with interactive human feedback for refinement.
  • Demonstrate transfer to real robots and broad RL tasks beyond simulation.

Proposed method

  • Ground environment in a compact Pythonic abstraction of states, objects, and actions.
  • Use large language models to convert natural language goals into dense reward code executable in Python.
  • Incorporate background knowledge and few-shot exemplars to guide code generation.
  • Execute generated reward code to catch syntax/runtime errors and refine via iterative LLM feedback.
  • Enable interactive human feedback after RL rollouts to further refine reward functions.
Figure 1: An overview of Text2Reward of three stages: Expert Abstraction provides an abstraction of the environment as a hierarchy of Pythonic classes. User Instruction describes the goal to be achieved in natural language. User Feedback allows users to summarize the failure mode or their preference
Figure 1: An overview of Text2Reward of three stages: Expert Abstraction provides an abstraction of the environment as a hierarchy of Pythonic classes. User Instruction describes the goal to be achieved in natural language. User Feedback allows users to summarize the failure mode or their preference

Experimental results

Research questions

  • RQ1Can zero-shot or few-shot dense reward code generated by an LLM achieve comparable performance to expert-designed rewards across manipulation tasks?
  • RQ2Does interactive human feedback improve reward function quality and RL success in scenarios with ambiguous or under-specified goals?
  • RQ3Are policies trained with Text2Reward transferable to real robot hardware without extensive retraining?
  • RQ4Do reward codes generalize to novel locomotion tasks beyond the training distribution?

Key findings

  • On 13 of 17 manipulation tasks, Text2Reward matches or surpasses expert-tuned rewards in success rate and convergence speed.
  • Zero-shot or few-shot Text2Reward outperforms expert rewards on 4 tasks in terms of convergence speed or success rate.
  • In MuJoCo locomotion, Text2Reward enables six novel behaviors with over 94% success rate (human-evaluated).
  • Policies trained in simulation with Text2Reward can be deployed on a real Franka Panda robot with minimal calibration.
  • Interactive feedback can further improve performance, resolving task ambiguity and increasing success rates across iterations.
Figure 2: Learning curves on Maniskill2 under zero-shot and few-shot reward generation settings, measured by task success rate. Oracle means the expert-written reward function provided by the environment; zero-shot and few-shot stands for the reward function is generated by Text2Reward w.o and w. re
Figure 2: Learning curves on Maniskill2 under zero-shot and few-shot reward generation settings, measured by task success rate. Oracle means the expert-written reward function provided by the environment; zero-shot and few-shot stands for the reward function is generated by Text2Reward w.o and w. re

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.