Self-Control of LLM Behaviors by Compressing Suffix Gradient into Prefix Controller

Min Cai, Yuchen Zhang, Shichang Zhang, Fan Yin, Dan Zhang, Difan Zou, Yisong Yue, Ziniu Hu · Submission to ICLR 2025 · Rejected

TL;DR

SelfControl steers Large Language Model (LLM) behaviors at inference time by taking gradients from the model’s own self-evaluation (e.g., asking itself via a suffix whether its draft output was toxic, angry, or untruthful) and modifying its latent activations. To avoid the computational overhead of iterative gradient updates during generation, the authors compress these updates into $\text{SelfControl}_{\text{prefix}}$—a lightweight prefix adapter that enables real-time, zero-latency inference and supports composing multiple behaviors simultaneously.

What Problem Does This Paper Address?

Aligning LLMs via Reinforcement Learning from Human Feedback (RLHF) or Direct Preference Optimization (DPO) requires expensive human annotations, risks catastrophic forgetting, and lacks on-the-fly flexibility when a user wants ad-hoc behavioral steering. Conversely, test-time interventions like constrained decoding (CD) often degrade text fluency and increase perplexity, while existing representation engineering (RepE) methods usually depend on hand-curated contrastive prompt pairs.

The authors tackle a central challenge: How can we precisely, adaptably, and efficiently control LLM behaviors without human supervision or parameter fine-tuning?

Methods

[Prompt] ---> Generate Output ---> [Prompt + Output + Suffix Question]
                                                   |
                                       Probe P(Yes) vs. P(No)
                                                   |
      Update Latents H <--- Gradient ∇_H (Suffix Score)
  1. Instance-Level SelfControl:
  2. Suffix Probing: An initial draft is generated for an input prompt. A behavioral question (a suffix string, such as "Was the last response toxic? Yes or No?") is appended to the input and generated response.
  3. Suffix Score: The model evaluates its own response by comparing the next-token likelihood ratio of behavior-aligned tokens: $$\mathcal{S}_{\text{suffix}} = \text{sigmoid}\left(\log P(\text{"Yes"}) - \log P(\text{"No"})\right)$$
  4. Latent Steering via Gradients: Rather than searching in discrete token space or updating model weights, SelfControl computes the gradient $\Delta H = \nabla_H \mathcal{S}_{\text{suffix}}$ with respect to the input prompt's Key-Value hidden states $H$, updating representations iteratively with a dynamic line-search step size $\gamma$.
  5. Across-Instance Distillation ($\text{SelfControl}_{\text{prefix}}$):
  6. Iterative test-time optimization adds latency (~10× slower than greedy decoding).
  7. To fix this, the authors generate pairs of inputs and gradient-optimized latents $\{(x_i, H_i^*)\}$, and train a parameter-efficient prefix adapter ($\text{PrefixController}$) using mean squared error (MSE) loss.
  8. The learned prefix runs in a single forward pass with zero inference latency overhead compared to the base model.
  9. Composability: Multiple behavior adapters (e.g., Detoxification + Privacy Protection, or Happier + Calmer) can be linearly interpolated at runtime.

Datasets

The authors evaluated SelfControl across multiple behavioral and cognitive dimensions:

  • Detoxification: RealToxicityPrompts (measured via the Perspective API).
  • Privacy Protection: DecodingTrust privacy evaluation (5-shot demonstrations inducing the model to leak private email addresses).
  • Emotion Steering: RepE emotion benchmarks covering five tones: anger, fear, happiness, surprise, and disgust (evaluated using GPT-3.5-turbo scorers).
  • Truthfulness (In-Context Learning): Synthetic true/false facts on world geography (cities and neg_cities).
  • Helpful & Harmless (HH) Dialogue: Anthropic-HH (harmless-base and helpful-base) evaluated by GPT-4 win-rates.
  • Mathematical Reasoning: GSM8K grade-school arithmetic problems.

Key Insights and Ideas

  • Self-Evaluation as a Differentiable Learning Signal: Models that fail to generate aligned outputs often still maintain the internal capacity to recognize violations when probed with binary choices. Turning this recognition into a loss function creates a completely self-supervised control loop.
  • Layer-Specific Behavioral Footprints: Inspecting gradient norms across layers reveals where behaviors live in the Transformer:
  • High-level cognitive and reasoning tasks (GSM8K, Harmless/Helpful) apply gradients predominantly to early/low-level layers to guide comprehension.
  • Behavioral suppression tasks (toxicity, privacy redaction, emotion moderation) apply gradients almost exclusively to deep/final layers to filter token emission.
  • Restructuring vs. Rotating Latent Geometry: Principal Component Analysis (PCA) reveals that traditional contrastive activation addition merely shifts and rotates representations (biasing the model toward outputting "True" regardless of factuality). In contrast, SelfControl fundamentally reorganizes the latent space into separable clusters, boosting accuracy on challenging negated statements (neg_cities).

Key Results

  • Detoxification: On LLaMA-2-7b, SelfControl reduces toxicity from 0.440 to 0.285 (and 0.314 for $\text{SelfControl}_{\text{prefix}}$) while keeping perplexity low (~2.12 vs. >3.7 in Model Arithmetic). On Mistral-7B, $\text{SelfControl}_{\text{prefix}}$ reaches a toxicity score of 0.259 (vs. 0.427 baseline).
  • Privacy Leakage: On DecodingTrust, base LLaMA-2 leaked the exact email in 58% of cases and the correct domain in 99%. Both SelfControl and $\text{SelfControl}_{\text{prefix}}$ drove both metrics to 0%, completely eliminating privacy leakage.
  • Reasoning and Factuality: On GSM8K with Mistral, SelfControl boosted accuracy from 26.61% (greedy decoding) to 37.30%. On true/false classification, it lifted average accuracy from 73.7% to 76.8%, avoiding the severe drop seen with Contrast Vectors on negative queries.
  • Inference Speed: While iterative SelfControl takes 54.6s per query, $\text{SelfControl}_{\text{prefix}}$ runs in 5.82s, nearly matching standard unconstrained decoding (5.79s).

Limitations and Future Work

  • Probe Design Constraints: The framework currently relies on binary ("Yes"/"No") logit differentials; multi-token or open-ended self-evaluation signals are not yet supported.
  • Adapter Architecture: The prefix controller relies on standard off-the-shelf parameter-efficient fine-tuning (PEFT) architectures, which may not be the optimal mechanism for capturing representation gradients.
  • Mechanistic Understanding: Although the authors trace layer-wise gradient magnitudes, deeper mechanistic interpretability of how suffix gradients modify specific attention heads and MLP circuits remains an open question.

Summary updated

BibTeX
@misc{cai2024self,
  author = {Min Cai and Yuchen Zhang and Shichang Zhang and Fan Yin and Dan Zhang and Difan Zou and Yisong Yue and Ziniu Hu},
  title = {{Self-Control of LLM Behaviors by Compressing Suffix Gradient into Prefix Controller}},
  year = {2024},
  eprint = {2406.02721},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.02721},
}
Figure