Iterative Reward Shaping using Human Feedback for Correcting Reward Misspecification

Jasmina Gajcin, James McCarthy, Rahul Nair, Radu Marinescu, Elizabeth Daly, Ivana Dusparic · DOI

Introduction

Reinforcement Learning (RL) relies heavily on the precise design of reward functions to guide agent behavior. However, in complex, multi-objective environments, designing a perfect reward function is notoriously difficult. This often leads to reward misspecification, where an agent discovers "shortcuts" to maximize its reward through nonsensical or dangerous behaviors—a phenomenon known as reward hacking.

This paper introduces ITERS (Iterative Reward Shaping), a framework designed to correct misspecified rewards by incorporating human feedback. Unlike previous methods that assume human feedback merely accelerates the learning of a correct reward, ITERS is built for scenarios where the human must actively contradict and fix a fundamentally flawed environment signal.

The ITERS Framework

ITERS employs a loop-based approach to iteratively refine the agent's behavior through a combination of human intuition and automated data augmentation. The process follows six key stages:

  1. Iterative Training: The agent is initially trained for a fixed number of steps using the existing (potentially flawed) reward function.
  2. Behavior Summarization: The system extracts and presents the user with a summary of the agent’s highest-performing trajectories.
  3. Human Feedback & Explanations: The user identifies trajectories that exhibit undesirable behavior. Crucially, the user provides an explanation for their dissatisfaction using one of three formats: feature-based (e.g., "speed is too high"), action-based (e.g., "too many turns"), or rule-based (e.g., SQL-like logic).
  4. Feedback Augmentation: To minimize the human workload, ITERS uses these explanations to generate a large synthetic dataset ($D_A$). It preserves the features identified in the explanation while randomizing other parts of the trajectory to create thousands of "bad" examples from a single human intervention.
  5. Reward Shaping Model ($R_s$): A supervised neural network is trained on this augmented dataset to predict user dissatisfaction.
  6. Integration: The learned model is integrated into the environment as a penalty term. The new reward function becomes $r = R_{env} + \lambda R_s$, where $\lambda$ scales the strength of the human-derived penalty.

Experimental Evaluation

The researchers evaluated ITERS across three distinct environments to test its versatility:

  • GridWorld (5x5): A discrete task where the initial reward failed to penalize unnecessary turns, leading to inefficient paths.
  • Highway Environment: A continuous state-space autonomous driving task where the agent initially ignored the safety risks of excessive lane changes.
  • Inventory Management: A discrete multi-objective task where the agent maximized sales but ignored the hidden costs of frequent deliveries.

Key Insights

Explanations as Force Multipliers

A core strength of ITERS is its use of explanations. Evaluating a full trajectory is more intuitive for humans than evaluating isolated state-action pairs. By asking why a behavior was bad, the system can generate vast amounts of synthetic data, acting as a force multiplier for human effort. In the GridWorld and Inventory tasks, the system required an average of only 3 to 4.34 human-marked trajectories to successfully correct the agent's policy.

Corrective vs. Additive Feedback

ITERS is specifically designed for conflict management. In many cases, the environment reward might signal that a behavior is optimal while the human signal indicates it is unacceptable. ITERS successfully navigates this conflict, eventually forcing the agent to prioritize human constraints over the original "hacked" reward signals.

The Importance of the Scaling Factor ($\lambda$)

The study highlighted that the scaling factor $\lambda$ is a critical hyperparameter. If $\lambda$ is too low, the agent continues to prioritize the misspecified environment reward. If it is too high, the agent may become overly risk-averse, potentially ceasing meaningful activity to avoid any possibility of a penalty.

Conclusion and Future Work

ITERS demonstrates a robust path forward for correcting reward hacking in RL systems. By leveraging human explanations to shape rewards, the framework achieves performance comparable to agents trained on perfectly specified "true" rewards with minimal human intervention.

Future research directions include extending the framework to non-episodic, "infinite" tasks, utilizing more sophisticated generative models for data augmentation, and developing methods to dynamically tune the $\lambda$ factor during training. Expanding the scope of human explanations to include natural language would also make the system more accessible to non-expert users.

Summary updated

BibTeX
@inproceedings{gajcin2023iterative,
  author = {Jasmina Gajcin and James McCarthy and Rahul Nair and Radu Marinescu and Elizabeth Daly and Ivana Dusparic},
  title = {{Iterative Reward Shaping using Human Feedback for Correcting Reward Misspecification}},
  booktitle = {ECAI},
  year = {2023},
  doi = {10.3233/faia230345},
}
Figure