In traditional reinforcement learning (RL), the reward function is often a "black box"—either a sparse scalar signal that provides little guidance or a complex neural network that is impossible for a human to audit. When an agent exhibits strange behavior, researchers are left guessing whether the issue lies in the optimization process or the reward signal itself.
A growing body of research suggests a different path: representing reward functions as executable code or symbolic expressions. By moving from opaque weights to human-readable Python scripts or mathematical trees, we can create "white-box" reward signals that are inherently interpretable, debuggable, and surprisingly efficient.
The Shift to Symbolic Representations
The core intuition behind this direction is that human intent is better captured by logical rules and physical heuristics than by high-dimensional vectors. Early work in this area, such as the LISR framework by Hassam Ullah Sheikh and colleagues, demonstrated that symbolic mathematical trees could represent dense rewards using far fewer parameters than neural networks. This compactness acts as a strong inductive bias, preventing the overfitting often seen in high-capacity reward models.
Similarly, Freddy Lecue and Tom Bewley proposed using binary decision trees to partition the state-action space. Because these trees use simple conditional tests on features, the resulting reward structure is a set of human-readable rules. If an agent fails, a developer can "audit" the tree to see exactly which rule triggered the suboptimal behavior.
Large Language Models as Reward Architects
The rise of Large Language Models (LLMs) has accelerated this trend by providing a bridge between natural language instructions and executable code. Frameworks like Text2Reward, developed by Siheng Zhao and Victor Zhong, use LLMs to translate a user’s goal (e.g., "pick up the red block") into a Python function that calculates a dense reward based on the environment's state.
This approach, which David Venuto and Doina Precup call Code as Reward (VLM-CaR), offers three distinct advantages:
- Transparency: The reward logic is plain text. A human can verify that the code prioritizes efficient movement over raw torque before the agent ever starts training.
- Modularity: Code can use helper functions and object-centric logic. Timo Kaufmann and the OCALM team showed that focusing on object relations allows agents to master games like Atari without ever seeing a numerical score.
- Efficiency: Executing a simple Python script is orders of magnitude faster than querying a massive Vision-Language Model at every step of an RL loop.
Evolution and Reverse Engineering
If we can represent rewards as code, we can also "evolve" them. The REvolve framework by Rishi Hazra uses LLMs as "intelligent genetic operators." By taking human feedback—such as "the car is driving too aggressively"—the LLM can rewrite the Python reward code to better align with the user's preference.
This logic extends to Inverse Reinforcement Learning (IRL), where the goal is to figure out the reward function by watching an expert. The GRACE framework (Generating Rewards As CodE) by Silvia Sapora and Bogdan Mazoure reverse-engineers expert demonstrations into symbolic Python functions. Because the output is code rather than a neural network, the resulting reward is modular and can be reused across different tasks or environments.
Safety and Public Trust
The move toward code-based rewards is not just about performance; it is about safety. In high-stakes domains like public health resource allocation, Nikhil Behari and Edwin Zhang argue that executable code serves as a vital intermediate layer. It allows human experts to audit the decision logic of an optimization engine before it is deployed to real-world patients.
By treating the reward function as a piece of software rather than a black-box model, researchers are making RL systems that are not only more capable but also more accountable to the humans who design them.