Dense Reward for Free in Reinforcement Learning from Human Feedback

Alex J. Chan, Hao Sun, Samuel Holt, Mihaela van der Schaar · DOI

TL;DR

Reinforcement Learning from Human Feedback (RLHF) is crucial for aligning LLMs, but suffers from sparse rewards. This paper introduces "Attention Based Credit" (ABC), a method that leverages the attention maps within the reward model to create a denser, token-level reward signal without extra computational cost. This approach stabilizes training, accelerates learning, and can lead to better model performance.

What Problem Does This Paper Address?

Reinforcement Learning from Human Feedback (RLHF) has become a cornerstone for fine-tuning Large Language Models (LLMs) to follow instructions and produce helpful outputs. The standard RLHF pipeline involves training a reward model to score LLM completions, and then using this reward model to train the LLM via reinforcement learning (RL). However, this process faces a significant challenge: the reward is typically only given at the very end of a generated sequence (a "sparse reward"). This makes it difficult for RL algorithms to learn, as the model has to figure out which of its many token-generation "actions" were responsible for the final, delayed reward. This credit assignment problem can lead to unstable training and slow learning. While some methods try to address this by using more complex reward structures or entirely avoiding RL, this paper aims to improve the standard RLHF process by making the reward signal denser and more informative.

Methods

The core innovation is Attention Based Credit (ABC). Instead of just using the final scalar score from the reward model, ABC taps into the internal workings of the reward model, specifically its attention maps. The attention mechanism in transformer models reveals which input tokens a model "pays attention to" when making a prediction. ABC hypothesizes that tokens the reward model attends to when scoring a completion are more important for that score.

Here's how it works:

  1. Extract Attention Weights: ABC uses the attention weights from the last layer of the reward model. These weights indicate the importance of each token in the generated sequence for the final reward prediction.
  2. Redistribute Reward: The final scalar reward is then "redistributed" across the tokens of the generated sequence, weighted by these attention scores. This creates a token-level reward signal, making the feedback denser.
  3. Potential-Based Reward Shaping: Theoretically, this method is equivalent to potential-based reward shaping. This is crucial because it guarantees that the optimal policy under the new, denser reward signal remains the same as the optimal policy under the original sparse reward. This means ABC doesn't change what the model should learn, only how it learns it more effectively.

The paper also introduces a variant, ABC-Decoder, which uses the attention maps from the generative LLM itself instead of the reward model. This is presented as a way to bootstrap learning, though it's expected to be less effective than using the reward model's attention.

Datasets

The experiments were conducted on three tasks:

  • Positive Generation: The IMDb movie review dataset was used for training.
  • Summarisation: The openai/summarize_from_feedback dataset was used.
  • Single-turn Dialogue: The Anthropic HH-RLHF dataset was used.

The paper also mentions using the RedPajama dataset for training the OpenLLaMA family of models.

Key Insights and Ideas

  • Reward Models are Richer Than They Seem: The paper highlights that the scalar output of a reward model is just the tip of the iceberg. The internal attention mechanisms contain valuable information that can be leveraged for better RL training.
  • Dense Rewards are Crucial for RL: The core problem of sparse rewards in RL is well-known, but this paper shows a practical, "free" way to densify rewards in the context of LLM fine-tuning.
  • Theoretical Guarantees Matter: Demonstrating that ABC is a form of potential-based reward shaping is a key insight, as it assures practitioners that they won't inadvertently change the optimal policy they are trying to find.
  • Attention is a Natural Fit: Using the attention mechanism, which is already a core component of LLMs and reward models, makes ABC computationally efficient and easy to integrate.

Key Results

  • Faster and More Stable Training: Across all tested tasks, ABC consistently led to faster convergence and more stable training compared to vanilla RLHF. For instance, in the positive generation task, ABC reached optimal reward levels in less than half the timesteps required by RLHF.
  • Improved Performance: While theoretically the optimal policy shouldn't change, ABC's more stable and efficient optimization process often led to better local optima, resulting in higher average rewards.
  • Robustness to Sparsity: ABC and other dense reward methods showed significantly better performance and stability on longer generation tasks, where vanilla RLHF struggled and often diverged.
  • Better Reward-KL Trade-off: ABC achieved higher rewards for a given level of KL divergence from the reference policy, indicating more efficient learning.
  • Improved Dialogue Quality: In single-turn dialogue, ABC-trained models were preferred by an automatic evaluator (AlpacaEval 2.0) over RLHF-trained models, suggesting better subjective quality. This was linked to reduced variance in value estimates due to the denser reward signal.

Limitations and Future Work

  • Shared Tokenizers: ABC requires the generative model and the reward model to use the same tokenizer. This can be a limitation when trying to use pre-trained reward models with different tokenizers. The authors suggest future work on mapping rewards between different tokenizers.
  • Overfitting to Reward Model: There's a risk that the LLM might overfit to the reward model, especially with methods that improve optimization. While ABC didn't exacerbate this in their experiments, it's an area for further exploration. Using reward model ensembles is suggested as a mitigation strategy.
  • Assumption of Same-Sign Contributions: ABC assumes that all token-level contributions to the reward are of the same sign. Future work could explore feature attribution methods that can detect both positive and negative contributions, though this might incur higher computational costs.
  • Exploration of Attention Blocks: The paper primarily uses the last layer's attention. Further exploration could investigate using attention from other blocks or heads, which might specialize in different tasks.

Summary updated

BibTeX
@inproceedings{chan2024dense,
  author = {Alex J. Chan and Hao Sun and Samuel Holt and Mihaela van der Schaar},
  title = {{Dense Reward for Free in Reinforcement Learning from Human Feedback}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=eyxVRMrZ4m},
}
Figure