Preprocessing Reward Functions for Interpretability

Erik Jenner, Adam GleavearXiv 2022 · DOI

Abstract

Learned reward functions in Reinforcement Learning (RL) are often complex, noisy, and difficult for humans to audit. This paper introduces a framework to "preprocess" these functions, transforming them into simpler, equivalent versions using potential shaping. By optimizing for sparsity or smoothness, the framework reveals the core objectives behind messy, learned rewards without altering the behavior they incentivize.

Introduction

In many complex RL tasks, reward functions are learned from human demonstrations or preferences rather than being hand-coded. While effective for training agents, these learned rewards are often "black boxes." Before deployment, it is crucial to verify if a model has learned the intended objective or merely captured artifacts of the training process.

Existing interpretability tools often fail when applied to rewards. However, reward functions possess a unique property: many distinct functions are "equivalent" in that they induce the same optimal policy. A noisy learned reward might simply be a "shaped" version of a simple goal. This research proposes a method to strip away this unnecessary complexity to reveal the underlying intent.

The Reward Preprocessing Framework

The proposed framework relies on two primary components:

  1. Equivalence via Potential Shaping: The framework uses potential shaping to define "legal" transformations. By adding a state-based potential to the reward, the immediate rewards change, but the optimal policy remains mathematically identical. This allows for searching a space of equivalent functions for the most readable one.
  2. Interpretability Cost Functions: To guide the transformation, the authors define cost functions ($J$) that measure "un-interpretability." They explore sparsity (using $L^1$ or logarithmic penalties to zero out most rewards) and smoothness (penalizing large jumps between time steps to create a cleaner trend).

The algorithm treats the learned reward as a black box and optimizes a neural network-parameterized potential function via gradient descent to minimize the chosen cost function, effectively distilling the reward.

Experimental Evaluation

The framework was tested on two classic RL benchmarks:

  • Gridworld: Tasks included "Goal" (single-point reward) and "Path" (trajectory reward), allowing for 2D heatmap visualizations of the reward landscape.
  • Mountain Car: A continuous control task where rewards were learned via Adversarial Inverse Reinforcement Learning (AIRL) and Deep RL from Human Preferences (DRLHP).
Figure 1: Preprocessing recovers the underlying sparse goal from various types of complex shaping in a Gridworld environment.

Key Results and Insights

The experiments demonstrated that redundancy in reward functions is an opportunity for interpretability. By searching the "equivalence space," the framework can effectively "un-shape" rewards that would otherwise be unintelligible to humans.

Recovering Ground Truth

In Gridworld, the framework successfully recovered original sparse rewards even after they were obscured by random, dense, or negative shaping. As shown in Figure 1, applying $L^1$ sparsity or log-smoothing to modified rewards consistently revealed the underlying goal location, which was previously hidden by noise.

Simplifying Continuous Signals

For rewards learned from human preferences in continuous environments, preprocessing significantly reduced high-frequency noise and clarified the reward signal over time.

Figure 4: Reward signals over time. Preprocessing (Log sparse/smooth) clarifies the reward structure compared to the raw unmodified signals.

As illustrated in Figure 4, the "Log smooth" and "Log sparse" variants produce much cleaner reward trajectories over time. This makes it obvious where the model is rewarding the agent, transforming a jittery signal into a clear, auditable trend.

Conclusion and Future Work

Reward preprocessing serves as a powerful validation step before deploying RL agents. If a reward remains unintelligible after preprocessing, it provides a strong signal that the learning algorithm failed or captured systematic errors rather than just being "shaped" strangely.

Future challenges include scaling these visualizations to high-dimensional robotic tasks and addressing the trade-off between human interpretability and "learnability." While a sparse reward is easier for a human to read, it may provide a weaker gradient for an agent during the initial training phase. Combining this preprocessing with other interpretability methods like saliency maps remains a promising direction for future research.

Summary updated

BibTeX
@misc{jenner2022preprocessing,
  author = {Erik Jenner and Adam Gleave},
  title = {{Preprocessing Reward Functions for Interpretability}},
  year = {2022},
  eprint = {2203.13553},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.13553},
}
Figure