TL;DR
LiSeCo (Linear Semantic Control) introduces a control-theoretic framework to guarantee that a Large Language Model's (LLM) internal activations stay within a user-defined "safe" semantic region. By solving a relaxed optimal control problem in closed form, it achieves precise, context-dependent attribute steering (such as toxicity reduction or language switching) with zero inference-time gradient overhead and excellent text quality.
What Problem Does This Paper Address?
Controllable text generation is essential for deploying LLMs safely in critical applications like content moderation. While existing methods can influence a model's output, they typically perform steering rather than true control.
Steering methods (like activation addition or prompt engineering) nudge internal representations in a general direction without verifying whether the constraint is actually met. This often leads to over-steering (which destroys text fluency) or under-steering (which fails to avoid the undesired attribute). This paper addresses the lack of formal performance guarantees in activation-based text generation by treating the sequence of hidden states as a continuous trajectory and applying classical control theory to enforce hard semantic constraints.
Methods
LiSeCo operates in two distinct phases:
- Offline (Probe Calibration): The authors train a linear probe ($f_t = \nu(W_t^\top x_t)$) at each layer $t$ using a labeled dataset. This probe maps the model's hidden activations ($x_t$) to a continuous attribute score (e.g., the probability of text being toxic). This assumes the Linear Representation Hypothesis—the idea that high-level concepts are linearly encoded within the LLM's latent space.
- Online (Optimal Control): During inference, text generation is modeled as a trajectory through the LLM's layers. LiSeCo formulates a constrained optimization problem to find the minimum $l_2$-norm perturbation vector ($\theta_t$) to add to the activation, ensuring the modified state lands within a safe pre-defined interval $[\alpha^{\min}, \alpha^{\max}]$.
To avoid the high latency of backpropagation or dynamic programming during text generation, the authors relax the global optimization problem into a per-layer local one. This yields a closed-form analytical solution based on Karush-Kuhn-Tucker (KKT) conditions. Crucially, if an activation naturally falls within the safe bounds, the intervention is exactly zero, minimizing unnecessary alterations to the model's natural generation.
Datasets
The authors validated LiSeCo across three distinct steering tasks using several open datasets:
- Toxicity Avoidance: Trained using 30k label-balanced natural language comments from Kaggle's Jigsaw dataset.
- Sentiment Steering: Trained on a combined 30k sample dataset spanning IMDb film reviews, TweetEval (Twitter), Yelp reviews, and Amazon reviews.
- Language Steering (English $\rightarrow$ Spanish): Trained using 2,010 parallel sentences from the FLORES-Plus dataset.
- Out-of-Distribution (OOD) Evaluation: To test robustness, the English $\rightarrow$ Spanish model was evaluated on three completely unseen domains: poetry from the Poetry Foundation dataset, European parliament proceedings (EuroParl), and code snippets from Stanford's CodeAlpaca.
Key Insights and Ideas
- Steering vs. Control: The authors formalize a crucial distinction: steering biases internal representations without guarantees, whereas control enforces hard numerical constraints with formal mathematical guarantees in the latent space.
- The Principle of Minimal Intervention: Because LiSeCo minimizes the magnitude of the perturbation vector, it only intervenes when an activation drifts into an "unsafe" zone. This context-dependent behavior preserves the naturalness and fluency of the text far better than static steering vectors.
- Representation vs. Generation: Even when activations are perfectly controlled in latent space, token-level outputs do not always achieve 100% compliance. This highlights a subtle gap in the Linear Representation Hypothesis, showing that linear decodability does not automatically translate to perfect linear controllability.
Key Results
- Guaranteed Activation Control: LiSeCo successfully bound latent activations to the exact user-specified target intervals across three state-of-the-art models: Llama-3-8B, Gemma-2-2b, and Mistral-7B.
- Superior Safety-Naturalness Trade-off: When evaluated on text naturalness (using perplexity measured by an independent model, Qwen-2.5-3B), LiSeCo consistently outperformed or matched strong baselines like Activation Addition (ActAdd) and Activation Transport (AcT).
- Granular Control Knob: By varying the target parameter $\alpha$, users can monotonically tune the proportion of generated tokens that exhibit the desired attribute, providing a highly predictable control mechanism.
- Strong OOD Generalization: For Llama and Mistral, the control vectors calibrated on standard text successfully transferred to complex OOD domains like poetry and code (e.g., forcing the model to write code comments in Spanish).
Limitations and Future Work
- Supervised Dependency: The method relies entirely on having a high-quality annotated dataset to train the linear probes offline.
- Linearity Constraint: LiSeCo is strictly limited to features and concepts that are linearly represented within the LLM's hidden states.
- Scalar/Binary Focus: The current framework handles scalar or binary attributes well (e.g., toxic vs. non-toxic) but needs extension to handle multi-class attributes simultaneously (e.g., steering text to be concurrently polite, professional, and in Spanish).
- Preemptive vs. Retroactive: The authors noted that LiSeCo works best as a preemptive guardrail. If a prompt is already highly toxic, it takes several token generation steps for the controller to successfully steer the model back into a safe state.
Summary updated