Aligning Large Language Models with Representation Editing: A Control Perspective

Lingkai Kong, Haorui Wang, Wenhao Mu, Yuanqi Du, Yuchen Zhuang, Yifei Zhou, Yue Song, Rongzhi Zhang, Kai Wang, Chao Zhang

Abstract

Aligning Large Language Models (LLMs) with human values typically requires a trade-off between the high computational costs of fine-tuning and the significant inference-time latency of guided decoding. This paper introduces RE-CONTROL, a novel framework that treats autoregressive LLMs as discrete-time stochastic dynamical systems. By training a lightweight value function to predict future rewards from internal hidden states, RE-CONTROL applies real-time "control signals" to steer the model toward desired behaviors. Our results demonstrate that RE-CONTROL achieves alignment performance comparable to or exceeding state-of-the-art methods while operating 20 times faster than traditional guided decoding techniques.

Introduction

The alignment of LLMs—ensuring they are helpful, harmless, and honest—is a central challenge in AI safety. Current approaches generally fall into two categories: fine-tuning (e.g., RLHF, DPO) and test-time interventions (e.g., prompting, guided decoding). While fine-tuning is effective, it is computationally intensive and results in static weights that are difficult to adapt quickly. Conversely, test-time methods like guided decoding offer flexibility but suffer from extreme latency, as they often require evaluating reward models for every potential token at every generation step.

RE-CONTROL proposes a "middle way" through Representation Editing. Instead of modifying the model's weights or filtering its output probabilities, RE-CONTROL dynamically perturbs the internal hidden states of the LLM during the forward pass. This approach bridges the gap between classical control theory and modern natural language processing.

The RE-CONTROL Framework

LLMs as Dynamical Systems

The core innovation of RE-CONTROL is the conceptualization of an LLM as a stochastic dynamical system. In this formulation, the hidden states and logits represent the system's "state," while the sampling of a new token introduces stochasticity. By viewing generation through this lens, we can apply principles from control theory to manage the trajectory of the model’s internal representations.

The Value Function

To guide the model, we train a small, 2-3 layer Multi-Layer Perceptron (MLP) known as the value function. This function is trained using the Bellman equation—a fundamental principle of reinforcement learning—to estimate the expected future reward based on the current hidden state. Because this value function is significantly smaller than the base transformer, it can be evaluated with minimal overhead.

Control Signals and Steering

During inference, RE-CONTROL does not simply allow the LLM to follow its default path. Instead, it performs gradient ascent on the hidden states. The value function calculates the direction in the representation space that maximizes the predicted reward. A small "nudge" or control signal is then applied to the hidden state before it is passed to the next layer or used to generate the next token.

To prevent "reward hacking"—where the model achieves high scores by sacrificing linguistic coherence—RE-CONTROL employs implicit regularization. By limiting the step size and the number of updates, the framework ensures the model remains close to its original distribution while steering toward the alignment objective.

Experimental Evaluation

Datasets and Benchmarks

We evaluated RE-CONTROL across several standard alignment benchmarks:

  • HH-RLHF (Anthropic): Focused on helpfulness and harmlessness.
  • Stanford SHP: Human preferences across diverse domains like legal and culinary advice.
  • HarmfulQA: Used for Out-of-Distribution (OOD) testing to evaluate the robustness of the value function against unseen harmful prompts.

Performance and Efficiency

Using GPT-4-based win-rate evaluations, RE-CONTROL consistently outperformed prompting and existing test-time techniques (such as CD-prefix) across multiple model backbones, including Vicuna, Falcon, and Llama-3.

Crucially, RE-CONTROL addresses the latency bottleneck of guided decoding. It is approximately 20 times faster than Controlled Decoding (CD). While CD requires multiple passes through a reward model for candidate tokens, RE-CONTROL only requires a few passes through its tiny MLP. Furthermore, RE-CONTROL supports efficient batching, making the inference overhead negligible as batch sizes increase.

Generalization

One of the most significant findings is the framework's ability to generalize. When trained on HH-RLHF and tested on the OOD HarmfulQA dataset, RE-CONTROL maintained high win rates. This suggests that the value function identifies general "safety directions" within the representation space rather than simply memorizing training samples.

Discussion and Limitations

While RE-CONTROL represents a significant step forward in efficient alignment, several areas for future work remain:

  1. Layer Specificity: Current experiments primarily target the final layers. Future research could explore multi-layer editing for more granular control.
  2. Multi-Objective Alignment: Real-world safety often involves balancing conflicting goals (e.g., being helpful vs. being concise). Extending RE-CONTROL to multi-objective optimization could help identify a "Pareto frontier" in the representation space.
  3. Policy Iteration: Moving beyond one-step policy iteration to multi-step training could further refine the accuracy of the steering signals.

Conclusion

RE-CONTROL offers a high-performance, computationally efficient alternative to traditional LLM alignment methods. By treating representation editing as a control problem, it provides a scalable way to steer model behavior at test-time without the prohibitive costs of fine-tuning or the latency of guided decoding.

Summary updated

BibTeX
@inproceedings{kong2024aligning,
  author = {Lingkai Kong and Haorui Wang and Wenhao Mu and Yuanqi Du and Yuchen Zhuang and Yifei Zhou and Yue Song and Rongzhi Zhang and Kai Wang and Chao Zhang},
  title = {{Aligning Large Language Models with Representation Editing: A Control Perspective}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=yTTomSJsSW},
}
Figure