Eureka: Human-Level Reward Design via Coding Large Language Models

Yecheng Jason Ma, William Liang, Guanzhi Wang, De-An Huang, Osbert Bastani, Dinesh Jayaraman, Yuke Zhu, Linxi Fan, Anima Anandkumar

TL;DR

EUREKA is an automated reward design algorithm that leverages the coding and reasoning capabilities of Large Language Models (LLMs) like GPT-4 to write reward functions for reinforcement learning (RL). By iteratively evolving reward code based on simulation feedback, it outperforms human experts on 83% of tasks and enables robots to master complex skills—such as dexterous pen spinning—for the first time.

The Challenge of Reward Design

In reinforcement learning, the "reward function" is the most critical component: it dictates what the agent should do and how it should learn to do it. However, designing these functions is notoriously difficult, often described as a "dark art." While a simple "win/loss" metric (sparse reward) is easy to define, it rarely provides enough continuous signal for an agent to learn complex, high-dimensional movements.

Consequently, researchers must manually engineer "shaped rewards" that provide incremental credit for sub-tasks (e.g., moving a robotic hand closer to an object). This process is tedious, requires deep domain expertise, and frequently leads to sub-optimal or unintended behaviors. While LLMs have shown promise as high-level semantic planners, using them to design the precise, low-level mathematical code required for complex robot manipulation has remained an open challenge.

Methods: The EUREKA Pipeline

To bridge this gap, the authors introduce EUREKA (Evolution-driven Universal REward Kit for Agent), which treats reward design as an iterative code-generation problem. The system operates without task-specific prompting or pre-defined reward templates, relying instead on three main components:

  1. Environment as Context: EUREKA feeds the raw Python source code of the simulation environment directly to the LLM. This allows the model to "see" exactly which state variables (like joint angles, positions, or velocities) are available to construct a reward function.
  2. Evolutionary Search: Rather than generating a single reward function, EUREKA samples a batch of candidates in parallel. These candidates are evaluated in Isaac Gym, a GPU-accelerated simulator capable of training RL policies rapidly.
  3. Reward Reflection: EUREKA extracts training statistics from the simulator (e.g., noting if an agent reached the goal but exhibited excessive velocity) and feeds them back to the LLM as a textual summary. The LLM uses this "reflection" to mutate and improve the reward code in the next evolutionary iteration.
The EUREKA pipeline: Environment code and task descriptions are used to sample reward candidates, which are evaluated in simulation to provide feedback for iterative refinement.

Experimental Setup

The researchers evaluated EUREKA across a diverse suite of 29 open-source RL environments featuring 10 distinct robot morphologies. This included the Isaac Suite (9 classic tasks like Quadcopter, Ant, and Humanoid), the Dexterity Benchmark (20 complex bi-manual tasks requiring Shadow Hands to perform skills like rotating a cup), and a newly introduced, highly dynamic Pen Spinning task designed to test the system's limits.

Key Insights and Results

EUREKA sets a new state-of-the-art for automated reward design, demonstrating several key advantages over traditional methods:

  • Outperforming Human Experts: EUREKA beat human-engineered rewards on 83% of the evaluated tasks, achieving an average normalized improvement of 52%.
  • Bridging the "Dexterity Gap": Performance gains were most significant in high-dimensional tasks, such as those involving the Shadow Hand, where human intuition often fails to account for complex physics.
  • Novelty over Intuition: EUREKA frequently discovers reward structures that are counter-intuitive to humans. For instance, it might identify a specific non-linear combination of distance and velocity that leads to faster convergence than standard linear combinations.
  • Gradient-Free RLHF: EUREKA enables a new form of Reinforcement Learning from Human Feedback (RLHF). A human can provide a simple text comment (e.g., "make the robot run more stably"), and EUREKA translates that into a code mutation incorporating a stability penalty—all without fine-tuning the underlying LLM.
  • Mastering Pen Spinning: By combining EUREKA with curriculum learning, the authors achieved the first-ever demonstration of a simulated Shadow Hand performing rapid, continuous pen spinning tricks.
Performance comparison showing EUREKA significantly outperforming both human experts and previous LLM-based baselines across various benchmarks.

Limitations and Future Work

While EUREKA excels in simulation, transferring these highly optimized rewards to physical hardware (Sim2Real) remains a challenge due to the inherent gap between simulated and real-world physics. Additionally, EUREKA still relies on a "fitness function" (a ground-truth success metric) to evaluate its candidates; if a task is so open-ended that success cannot be mathematically defined, the evolutionary loop cannot initiate. Finally, the length of environment code processed is limited by the LLM's context window, though this is mitigated by extracting only relevant code snippets.

Future work aims to incorporate Vision-Language Models (VLMs) to allow EUREKA to "watch" videos of robots and derive feedback directly from visual data, further reducing the reliance on human-defined success metrics.

Summary updated

BibTeX
@inproceedings{ma2024eureka,
  author = {Yecheng Jason Ma and William Liang and Guanzhi Wang and De-An Huang and Osbert Bastani and Dinesh Jayaraman and Yuke Zhu and Linxi Fan and Anima Anandkumar},
  title = {{Eureka: Human-Level Reward Design via Coding Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=IEduRUO55F},
}
Figure