DiReCL: Learning Differentiable Reward Code with Inverse Reinforcement Learning
Aoran Wang ⋅ Jingtao Zhang ⋅ Maosen Li ⋅ Zongzhang Zhang
Abstract
In reinforcement learning (RL), reward specification plays a fundamental role in shaping policy optimization. Inverse RL (IRL) offers a data-driven approach to inferring rewards from demonstrations, but widely used neural-network-based methods often produce rewards that are difficult to interpret, inspect, or revise manually. In contrast, human-written or large language model (LLM)-generated reward code provides explicit semantic structure, yet its precise numerical parameters are often difficult to calibrate and prone to specification errors. To bridge this gap, we propose DiReCL (\textbf{Di}fferentiable \textbf{Re}ward \textbf{C}ode \textbf{L}earning), a novel framework that unifies these two paradigms by formulating reward learning in a differentiable reward code space. DiReCL first prompts an LLM to synthesize reward code templates, then converts the numeric elements in these templates into differentiable parameters and aligns them with expert demonstrations through IRL. We further introduce a reflection mechanism that uses IRL diagnostics to provide evidence of inadequacies in the reward structure and guide template revision. Experiments on four MuJoCo locomotion tasks and two autonomous driving benchmarks demonstrate that DiReCL achieves over $1.25 \times$ the performance of the compared IRL and LLM-assisted reward design baselines, while retaining explicit and inspectable reward semantics.
Successful Page Load