Aligning Large Language Models with Human Preferences through Representation Engineering

Wenhao Liu, Xiaohua Wang, Muling Wu, Tianlong Li, Changze Lv, Zixuan Ling, Jianhao Zhu, Cenyuan Zhang, Xiaoqing Zheng, Xuanjing Huang

Introduction

Standard alignment techniques like Reinforcement Learning from Human Feedback (RLHF) are notoriously difficult to implement. They are sensitive to hyperparameters, prone to training instability, and require maintaining complex reward models and value networks. While simpler alternatives like Direct Preference Optimization (DPO) exist, they can still be vulnerable to noisy data.

This paper introduces Representation Alignment from Human Feedback (RAHF), a lightweight alternative to RLHF that aligns Large Language Models (LLMs) by manipulating their internal "thought patterns." The authors argue that human preferences (like helpfulness or safety) are embedded as high-level concepts within an LLM's internal representations. The challenge is precisely identifying these "preference directions" and finding a way to steer the model toward them during inference without breaking its general reasoning capabilities.

Comparison of RAHF with existing alignment paradigms like RLHF, DPO, and HIR.

Methods

RAHF draws inspiration from Representation Engineering (RepE) and follows a three-step process:

  1. Instructing for Contrast: The authors propose two ways to teach the model what "good" and "bad" look like:
  2. RAHF-SCIT (Single Model): Uses Contrastive Instruction Tuning. A single model is trained with pairs of instructions (e.g., "You are a helpful assistant" vs. "You are a harmful assistant") to learn the difference between preferred and dispreferred outputs.
  3. RAHF-Dual (Dual Models): Trains two separate models—a "preferred" model and a "dispreferred" model—on the respective sides of a preference dataset.
  4. Extracting Activity Patterns: The model is fed a prompt, and hidden states are extracted from intermediate layers. By subtracting the "bad" activity pattern from the "good" one, a Difference Vector ($v_l$) is calculated, representing the mathematical direction of human preference.
  5. Representation Steering: A LoRA (Low-Rank Adaptation) module is trained using a Mean Squared Error (MSE) loss to perturb the base model's representations in the direction of the preference vector, effectively "steering" the model's behavior at every layer.

Experimental Setup

The study utilizes several prominent open-source datasets: UltraFeedback for primary preference training, Anthropic’s HH-RLHF for fine-tuning Llama2-7B, and Toxigen for safety evaluation. Benchmarking was conducted on the Open LLM Leaderboard, AlpacaEval, and MT-Bench.

Key Results

RAHF demonstrates superior performance and efficiency compared to existing methods. On the Open LLM Leaderboard, RAHF-SCIT reached an average score of 57.27, the highest among all tested alignment methods.

Performance comparison of RAHF-SCIT and RAHF-Dual against baseline and other alignment methods on the Open LLM Leaderboard.

Further results include:

  • AlpacaEval: RAHF-SCIT achieved a win rate of 87.44% against text-davinci-003, outperforming DPO (83.68%) and RLHF-PPO (44.69%).
  • MT-Bench: RAHF-Dual and RAHF-SCIT dominated the multi-turn conversation benchmark, particularly in categories like "Roleplay," "STEM," and "Humanities."
  • Safety: RAHF-SCIT showed a significant improvement in the Toxigen safety benchmark (67.45% accuracy vs. DPO’s 59.26%).

Discussion and Insights

The authors identified that extracting representations from the middle layers (e.g., layer 20 of 32) is most effective, as early layers focus on raw text and final layers on token prediction. Additionally, RAHF-SCIT generally outperformed RAHF-Dual, likely because learning "good" and "bad" concepts within the same model ensures they share the same feature space, leading to more accurate difference vectors.

Unlike RLHF, which requires complex reinforcement learning loops, RAHF uses a simple MSE loss, making it significantly more stable and computationally efficient.

Conclusion

RAHF offers a potent, efficient path for aligning LLMs with human values by steering internal representations. Future work includes scaling to larger models (70B+) and exploring "folding" difference vectors directly into model weights to eliminate LoRA inference overhead.

Summary updated

BibTeX
@inproceedings{liu2024aligning,
  author = {Wenhao Liu and Xiaohua Wang and Muling Wu and Tianlong Li and Changze Lv and Zixuan Ling and Jianhao Zhu and Cenyuan Zhang and Xiaoqing Zheng and Xuanjing Huang},
  title = {{Aligning Large Language Models with Human Preferences through Representation Engineering}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.572},
}
Figure