Representation-based Reward Modeling for Efficient Safety Alignment of Large Language Model

Qiyuan Deng, Xuefeng Bai, Kehai Chen, Yaowei Wang, Liqiang Nie, Min Zhang

TL;DR

This paper introduces a highly efficient framework for the safety alignment of Large Language Models (LLMs) that addresses the common issue of "distribution shift" in off-policy training methods like Direct Preference Optimization (DPO). By leveraging the model's internal representations to extract reward signals and converting expensive online token generation into a smart data re-ranking process, the authors achieve safety performance comparable to online methods while slashing computational overhead by roughly 300x.

What Problem Does This Paper Address?

Aligning LLMs with human values typically relies on preference optimization techniques. While reinforcement learning from human feedback (RLHF) traditionally uses PPO, simpler off-policy alternatives like Direct Preference Optimization (DPO) have become highly popular.

However, off-policy methods suffer from a fundamental flaw: distribution shift. Because they train on static, pre-collected preference datasets, the distribution of the data diverges from the distribution of the model's evolving policy during training.

To fix this, state-of-the-art approaches use online methods that continuously sample new responses from the active policy model. Unfortunately, generating new tokens iteratively during training is incredibly slow and computationally expensive, creating a massive bottleneck.

Figure 1: (a) Illustration of the distribution shift; (b) Comparison of computational cost between on-policy and off-policy methods.

Methods

The authors propose a novel framework based on a core hypothesis: During off-policy training, while the exact ranking of top generated items changes, their overall content distribution remains relatively stable. This insight allows them to replace expensive online text generation with a computationally cheap re-ranking of existing preference data.

The framework consists of two main components:

  1. Representation-based Hybrid Reward Model ($R_h$): Instead of training a separate, massive reward model, the authors discover that an LLM's internal hidden states (specifically the last token across different layers) already contain strong safety signals. They train a series of lightweight linear Support Vector Machines (SVMs) on top of these internal layers and combine them using a weighted softmax gate to dynamically extract rewards.
  2. Confidence-Aware Optimization (cDPO): The extracted reward signals are used to compute a dynamic "preference confidence" ($\gamma$) for each pair of responses. This confidence score acts as a soft label within a conservative DPO loss function, effectively simulating the target policy's distribution shift without generating a single new token.
Figure 2: Illustration of our alignment framework, including 1) initialize the hybrid reward model with inner representation of the last token; 2) preference data construction by re-ranking policy output with hybrid reward; 3) iteratively optimize policy and hybrid reward model with preference confidence.

Datasets

The authors validated their approach using several standard safety alignment and evaluation datasets:

  • PKU-SafeRLHF: Used as the primary training set to initialize the hybrid reward model (contains 83.4k preference entries).
  • Anthropic Hh-rlhf Red-teaming: A benchmark consisting of adversarial multi-round dialogues.
  • Do-Not-Answer: A curated dataset of prompts that responsible language models should refuse to answer.
  • Salad Bench: A comprehensive safety benchmark spanning 6 domains and 66 distinct safety categories.
  • XSTest: A specialized benchmark used to evaluate exaggerated safety (over-refusal behavior).

Key Insights and Ideas

  • Safety is Linearly Separable Internally: By applying Principal Component Analysis (PCA) to the hidden states of the model's final tokens, the authors found distinct, clear separability between safe and unsafe responses across multiple layers. The model inherently "knows" when it is being unsafe before it even finishes generating.
  • Equivalence of Sampling and Re-ranking: Mathematically, the optimal policy under DPO can be viewed as an energy-based model that re-weights the reference policy. This theoretical grounding justifies why re-ranking static data can successfully approximate active online generation.
  • Preventing Reward Hacking: In vanilla DPO, models often suffer from "reward hacking," where the DPO reward score surges artificially while the training loss becomes highly volatile. By introducing dynamic preference confidence, the proposed method stabilizes the training trajectory and ensures gradual, robust alignment.

Key Results

  • 300x Efficiency Gain: The proposed method achieves safety performance highly competitive with true online DPO methods while reducing the computational overhead by approximately 300 times.
  • Toxicity Reduction: Across Llama2-7B, Llama2-13B, and Qwen2.5-7B, the framework consistently outperformed standard offline baselines (DPO, KTO, IPO, simPO). For instance, on Llama2-7B, the average toxicity rate dropped from DPO's 25.7% down to 21.4% using the proposed cDPO.
  • Balanced Refusals: When evaluated on XSTest, the framework demonstrated a superior ability to distinguish between truly harmful prompts and benign prompts that merely look risky, reducing the common issue of "exaggerated safety" or over-refusal.

Limitations and Future Work

  • Domain Generalizability: While the internal representation probing works exceptionally well for safety alignment, the authors note that its generalizability to other alignment domains—such as helpfulness, coding, or mathematical reasoning—remains an open question for future research.
  • The Upper-Bound Gap: Although the method drastically narrows the gap between offline and online methods, a slight performance gap still remains when compared to true online DPO (the theoretical upper bound). The authors attribute this to the simplicity of using linear probes for reward extraction and suggest exploring more sophisticated probing architectures in the future.

Summary updated

BibTeX
@inproceedings{deng2025representation,
  author = {Qiyuan Deng and Xuefeng Bai and Kehai Chen and Yaowei Wang and Liqiang Nie and Min Zhang},
  title = {{Representation-based Reward Modeling for Efficient Safety Alignment of Large Language Model}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure