Abstract
Language models often exhibit undesirable behavior, e.g., generating toxic or gender-biased text. In the case of neural language models, an encoding of the undesirable behavior is often present in the model's representations. Thus, one natural (and common) approach to prevent the model from exhibiting undesirable behavior is to steer the model's representations in a manner that reduces the probability of it generating undesirable text. This paper investigates the formal and empirical properties of steering functions, i.e., transformation of the neural language model's representations that alter its behavior. First, we derive two optimal, in the least-squares sense, affine steering functions under different constraints. Our theory provides justification for existing approaches and offers a novel, improved steering approach. Second, we offer a series of experiments that demonstrate the empirical effectiveness of the methods in mitigating bias and reducing toxic generation.
Introduction
Large language models (LLMs) frequently manifest societal biases or produce toxic content, a consequence of these patterns being embedded within their high-dimensional internal representations. While "concept erasure"—the complete removal of specific information—is a common mitigation strategy, it can inadvertently degrade model performance or "guardedness." For instance, erasing the concept of toxicity might prevent a model from recognizing and thus avoiding toxic outputs.
This paper proposes steering as a more surgical alternative. Steering involves shifting representations from a "source" concept (e.g., toxic) toward a "target" concept (e.g., non-toxic). We provide a rigorous mathematical foundation for this process, identifying the optimal affine transformations that achieve behavioral change with minimal modification to the original representation space.
Theoretical Framework: Affine Steering Functions
We focus on affine transformations of the form $f(h) = Wh + b$, where $h$ is a hidden representation. The goal is to find $W$ and $b$ that minimize the expected squared difference between the original and transformed representations, subject to constraints that align the source and target distributions.
Mean Matching
The simplest approach, Mean Matching, uses a pure translation ($W=I$). It ensures that the mean of the transformed source distribution matches the mean of the target distribution. This is equivalent to the popular "steering vector" method.
MiMiC: Minimally Modified Counterfactuals
Our primary contribution, MiMiC, extends this by matching both the mean and the covariance of the representations. By aligning second-order moments, MiMiC ensures that the geometric "shape" of the data distribution is preserved. This is formally linked to Optimal Transport theory, specifically the Bures-Wasserstein distance between Gaussians.
Key Insights: The Importance of Covariance
A critical finding is that Mean Matching often fails to fully "hide" the source concept because it ignores the local geometry of the data. Even if means are aligned, data points may still cluster in a way that allows the model to distinguish between the original classes—a phenomenon we call "bias by neighbors."
By matching covariances, MiMiC aligns the entire distribution, making the source and target representations indistinguishable to subsequent layers of the model. This "minimal surgery" approach preserves the model's general capabilities while precisely targeting the undesirable behavior.
Empirical Evaluation
We validated MiMiC across several benchmarks:
- Gender Bias (Bios Dataset): We evaluated the "True Positive Rate (TPR) gap" in profession classification. MiMiC reduced the bias gap in BERT-base from 0.155 to 0.093, outperforming state-of-the-art erasure methods like LEACE while maintaining high classification accuracy.
- Dialect Fairness: In sentiment analysis of tweets from the Blodgett et al. (2016) dataset, MiMiC successfully decoupled sentiment predictions from African-American English (AAE) vs. Standard American English (SAE) dialects.
- Toxicity Mitigation: Applied to GPT-2 (large) using Real Toxicity Prompts, MiMiC reduced the expected maximum toxicity of generated text by approximately 25% without requiring expensive fine-tuning.
Conclusion
MiMiC provides a theoretically grounded and empirically effective method for steering language model behavior. By framing steering as a constrained optimization problem, we show that matching higher-order moments like covariance is essential for robust bias and toxicity mitigation. Future work will explore non-linear generalizations of this framework to capture even more complex conceptual relationships.
Summary updated