Linearly Controlled Language Generation with Performative Guarantees

Emily Cheng, Marco Baroni, Carmen Amo Alonso · Submission to ICLR 2025 · Rejected

TL;DR

Steering language models (LMs) away from generating toxic or undesirable text usually requires heavy fine-tuning, brittle prompts, or slow decoding algorithms. Linear Semantic Control (LiSeCo) reframes controlled generation through the lens of optimal control theory, modeling generation as a trajectory in continuous latent space. By solving a constrained optimization problem in closed form, LiSeCo applies lightweight, per-layer activation steering at inference time that is mathematically guaranteed (in probability) to keep latent states within safe boundaries with negligible computational overhead.

What Problem Does This Paper Address?

Language models deployed in critical settings need guardrails to avoid generating toxic, biased, or off-topic outputs. Existing control approaches each suffer from distinct trade-offs:

  • Instruction-tuning & weight editing are computationally expensive, require massive data, and permanently alter model weights.
  • Prompt engineering is brittle and restricted to discrete text space.
  • Decoding-time methods (e.g., FUDGE) score candidate tokens using an external model, inflating per-token generation latency by orders of magnitude.
  • Existing activation steering (e.g., Activation Addition) relies on heuristic perturbation vectors without guarantees that outputs will actually land in the desired semantic region.

The authors ask: Can we steer an LM’s internal representations away from forbidden concepts online, with theoretical guarantees, while introducing virtually no inference latency?

Methods

LiSeCo models language generation as a trajectory through the continuous hidden activation spaces across Transformer layers. Building on the linear representation hypothesis—the observation that high-level concepts are linearly decodable in model activations—the framework operates in two stages:

  1. Semantic Probe Identification: For each layer $t$, a lightweight linear probe (logistic regression) $f_t(x_t) = \sigma(W_t^\top x_t)$ is trained on hidden states to predict the probability of an undesired attribute. A forbidden region is defined as $\mathcal{R}_t := \{x \mid \sigma(W_t^\top x) \ge p\}$ for a chosen probability threshold $p \in [0, 1]$.
  2. Optimal Latent Control (Closed-Form): During token generation, if an activation $x_t$ enters the forbidden region ($\sigma(W_t^\top x_t) > p$), an optimal perturbation $\theta_t \in \mathbb{R}^d$ is added. To preserve text fluency, LiSeCo minimizes the perturbation's $L_2$ norm subject to the hard constraint that the updated activation lies in the safe region: $$\min_{\theta_t} \|\theta_t\|_2^2 \quad \text{s.t.} \quad \sigma(W_t^\top (x_t + \theta_t)) \le p$$ Using the Karush-Kuhn-Tucker (KKT) conditions, the authors derive a closed-form solution for $\theta_t^*$: $$\theta_t^* = \frac{\log(1/p - 1) - w_t^\top x_t}{\|w_t\|_2^2} w_t$$ where $w_t$ is the difference between probe weight columns. Because the solution is analytic, steering requires no test-time backpropagation or external scoring models. The paper also extends this formulation to continuous attribute tuning (e.g., controlling formality).

Datasets

The authors evaluate using paired constraint (probe training) and task (generation evaluation) datasets:

  • Toxicity Avoidance: Probes are trained on 30k balanced comments from Kaggle’s Jigsaw Toxic Comment dataset. Evaluation uses a 300-prompt subset (150 toxic continuations, 150 non-toxic) from RealToxicityPrompts.
  • Sentiment / Negativity Avoidance: Probes are trained on a 30k balanced corpus combining samples from IMDb, TweetEval, Yelp, and Amazon Reviews. Evaluation uses 300 neutral prompts from OpenWebText.
  • Formality (Continuous Tuning): Probes are trained on 11,270 crowdsourced human ratings from the Formality-scores dataset (Pavlick & Tetreault, 2016).

Evaluated models include Llama-3-8B, Mistral-7B, and Pythia-6.9B, along with instruction-tuned variants.

Key Insights and Ideas

  • Control Theory Meets Latent Space: Posing controlled text generation as a constrained optimization problem bridges empirical prompt/activation engineering with classical control theory.
  • Intervention Without Latency: Because the per-layer optimal steering vector is computed analytically, it operates as a modular, gradient-free layer wrapper.
  • Interpretability via Threshold $p$: Unlike heuristic steering multipliers, $p$ represents an explicit upper bound on the probe’s estimated probability of the unsafe concept, giving practitioners an intuitive dial for control.
  • Sample-Efficient Probe Training: Probes achieve ~90% accuracy in mid-to-late layers. A stress test revealed that training on as few as 250 examples still yielded >80% probe test accuracy.

Key Results

  • Negligible Latency: LiSeCo generates tokens in ~0.11–0.17s, virtually identical to the unsteered baseline (~0.10–0.16s). In contrast, FUDGE required ~3.4–3.6s per token (~20–30× slower).
  • Detoxification with High Naturalness: On prompts prone to producing toxic continuations, LiSeCo reduced external toxicity scores from 100% toxic to 7–17% ($p = 0.01$), rivaling or exceeding instruction-tuned models while preserving human-evaluated naturalness (Likert scores ~4/5).
  • Failure Mode Avoidance: Unlike Activation Addition (ActAdd), which frequently collapsed into degenerate repetitive text at strong intervention magnitudes, LiSeCo remained coherent because the perturbation vector is bounded to the minimal shift necessary to reach the decision boundary.

Limitations and Future Work

  • Dependence on Probe Quality: Guarantees are relative to the linear probe's decision boundary. If the probe fails to generalize to out-of-domain text (as observed with Pythia, where probe–scorer correlation was near zero, $\rho = 0.06$), empirical safety degrades.
  • Linearity Assumption: The method assumes the semantic attribute is linearly separable in latent space.
  • False Positive Interventions: Overly sensitive probes can trigger interventions on benign text, occasionally inducing unnatural completions.
  • Future Directions: Applying LiSeCo across joint multiple constraints (e.g., maintaining formality while avoiding toxicity) and exploring non-linear decision boundaries.

Summary updated

BibTeX
@article{cheng2025linearly,
  author = {Emily Cheng and Marco Baroni and Carmen Amo Alonso},
  title = {{Linearly Controlled Language Generation with Performative Guarantees}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=a3o2pzZuvE},
}
Figure