Table of Contents
Fetching ...

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

TL;DR

The core of the method is to view a pre-trained autoregressive LLM as a discrete-time stochastic dynamical system and train a value function directly on the hidden states according to the Bellman equation, enabling gradient-based optimization to obtain the optimal control signals at test time.

Abstract

Aligning large language models (LLMs) with human objectives is crucial for real-world applications. However, fine-tuning LLMs for alignment often suffers from unstable training and requires substantial computing resources. Test-time alignment techniques, such as prompting and guided decoding, do not modify the underlying model, and their performance remains dependent on the original model's capabilities. To address these challenges, we propose aligning LLMs through representation editing. The core of our method is to view a pre-trained autoregressive LLM as a discrete-time stochastic dynamical system. To achieve alignment for specific objectives, we introduce external control signals into the state space of this language dynamical system. We train a value function directly on the hidden states according to the Bellman equation, enabling gradient-based optimization to obtain the optimal control signals at test time. Our experiments demonstrate that our method outperforms existing test-time alignment techniques while requiring significantly fewer resources compared to fine-tuning methods. Our code is available at https://github.com/Lingkai-Kong/RE-Control.

Aligning Large Language Models with Representation Editing: A Control Perspective

TL;DR

The core of the method is to view a pre-trained autoregressive LLM as a discrete-time stochastic dynamical system and train a value function directly on the hidden states according to the Bellman equation, enabling gradient-based optimization to obtain the optimal control signals at test time.

Abstract

Aligning large language models (LLMs) with human objectives is crucial for real-world applications. However, fine-tuning LLMs for alignment often suffers from unstable training and requires substantial computing resources. Test-time alignment techniques, such as prompting and guided decoding, do not modify the underlying model, and their performance remains dependent on the original model's capabilities. To address these challenges, we propose aligning LLMs through representation editing. The core of our method is to view a pre-trained autoregressive LLM as a discrete-time stochastic dynamical system. To achieve alignment for specific objectives, we introduce external control signals into the state space of this language dynamical system. We train a value function directly on the hidden states according to the Bellman equation, enabling gradient-based optimization to obtain the optimal control signals at test time. Our experiments demonstrate that our method outperforms existing test-time alignment techniques while requiring significantly fewer resources compared to fine-tuning methods. Our code is available at https://github.com/Lingkai-Kong/RE-Control.
Paper Structure (42 sections, 12 equations, 7 figures, 13 tables)

This paper contains 42 sections, 12 equations, 7 figures, 13 tables.

Figures (7)

  • Figure 1: Overview of Re-Control: A value function is trained on the hidden space of an LLM to predict the expected reward. At test time, we optimize the hidden state of the LLM to maximize the value score. Re-Control effectively steers LLMs toward specific alignment objectives while avoiding the expensive fine-tuning process.
  • Figure 2: At test time, we perform gradient-based optimization to determine the control signals added to the language dynamical system for alignment. The color represents the value score on the state space, with darker colors indicating higher scores. Our goal is not to update the state to the global optimum but to control the state to achieve a better value score while remaining close to the original state.
  • Figure 3: Comparison with LoRa-based fine-tuning methods using Vicuna-7B as the base model on HH-RLHF.
  • Figure 4: Testing on out-of-distribution data HarmfulQA. The win rate is measured by GPT-4 as the rate at which responses are better than those of the base model, since the test set of HarmfulQA does not provide reference responses.
  • Figure 5: The influence of step size $\alpha$ and the number of updates $n$ at test time on diversity, coherence, and average reward. We use Vicuna-7B as the base model.
  • ...and 2 more figures

Theorems & Definitions (1)

  • Definition 4.1: Language dynamical system