Learning Explainable Dense Reward Shapes via Bayesian Optimization

Ryan Koo, Ian Yang, Vipul Raheja, Mingyi Hong, Kwang-Sung Jun, Dongyeop KangarXiv 2025 · DOI

Introduction

Reinforcement Learning from Human Feedback (RLHF) is the standard for aligning Large Language Models (LLMs). However, it typically relies on "sparse rewards"—a single scalar score assigned at the end of a sequence. This creates a significant credit assignment problem: the model receives feedback on the whole response but doesn't know which specific tokens were beneficial or detrimental. While reward shaping can turn sparse rewards into dense, per-token signals, manual annotation is expensive and simple heuristics often fail to align with model logic.

The Proposed Framework

This paper introduces a novel framework that uses explainability methods to "densify" rewards and employs Bayesian Optimization (BO) to find the optimal balance of these signals.

Overview of the proposed framework: Step 1 samples weights via BO, Step 2 computes the dense reward shape using explainability methods (SHAP, LIME), and Step 3 trains the PPO policy.

The approach involves three key steps:

  1. Explainability-based Attribution: The system uses additive feature attribution methods—specifically SHAP and LIME—to decompose the final reward model score into the marginal contribution of each individual token.
  2. Bilevel Optimization with BO: Since explainability estimates can be noisy, the authors treat the weighting of these signals (SHAP, LIME, and Attention) as a black-box optimization problem. Bayesian Optimization is used in an "outer loop" to sample weights, while the "inner loop" performs standard PPO training.
  3. Policy Invariance Proof: The authors provide a theoretical proof showing that because these methods are additive, they function as "potential-based reward shaping." This ensures that the optimal policy found with dense rewards is identical to the one that would be found with the original sparse reward, only reached more efficiently.

Experimental Results

The framework was evaluated on the HH-RLHF and Ultrafeedback datasets using Llama-based models. Performance was measured via win rates on AlpacaEval-2 and MTBench.

Experimental results showing (a) reward curves for different BO variants, (b) validation reward across BO trials, and (c) a heatmap of the mean dense reward shape.

Key Insights

  • Performance Gains: On the Ultrafeedback task, the BO-SHAP-LIME combination achieved a win rate of 64.82% on AlpacaEval, significantly outperforming the sparse reward baseline (57.64%).
  • Training Stability: One of the most striking findings is that dense rewards drastically reduce PPO Value Head Loss. By providing feedback at every token, the model's internal critic predicts long-term value more accurately, leading to smoother training.
  • Generalization vs. Hacking: Explainable dense rewards helped the model generalize better to open benchmarks rather than just over-optimizing for the reward model's quirks, a common issue known as "reward hacking."

Conclusion and Future Work

This work demonstrates that "post-hoc" explainability tools can be effectively repurposed as "ante-hoc" training signals. By densifying rewards through an optimized combination of attribution methods, RLHF becomes more stable and produces better-aligned models. Future research may explore dynamic weighting, where the importance of different attribution sources changes based on context or token embeddings.

Summary updated

Abstract

Current reinforcement learning from human feedback (RLHF) pipelines for large language model (LLM) alignment typically assign scalar rewards to sequences, using the final token as a surrogate indicator for the quality of the entire sequence. However, this leads to sparse feedback and suboptimal token-level credit assignment. In this work, we frame reward shaping as an optimization problem focused on token-level credit assignment. We propose a reward-shaping function leveraging explainability methods such as SHAP and LIME to estimate per-token rewards from the reward model. To learn parameters of this shaping function, we employ a bilevel optimization framework that integrates Bayesian Optimization and policy training to handle noise from the token reward estimates. Our experiments show that achieving a better balance of token-level reward attribution leads to performance improvements over baselines on downstream tasks and finds an optimal policy faster during training. Furthermore, we show theoretically that explainability methods that are feature additive attribution functions maintain the optimal policy as the original reward.
BibTeX
@misc{koo2025learning,
  author = {Ryan Koo and Ian Yang and Vipul Raheja and Mingyi Hong and Kwang-Sung Jun and Dongyeop Kang},
  title = {{Learning Explainable Dense Reward Shapes via Bayesian Optimization}},
  year = {2025},
  eprint = {2504.16272},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.16272},
}
Figure