Contrastive Covariance Subspaces for Activation Steering
A plain target-versus-neutral direction can carry nuisance variation, so Contrastive Covariance Steering builds a target-specific subspace that preserves target scatter while suppressing competing-class scatter, then projects the target’s grand-mean displacement into it.
Read the paper ↗What it is
- Target-specific subspace CCS finds directions where the target group varies strongly but competing groups vary less, then keeps the target’s movement only within those directions.
- Grand-mean displacement Instead of measuring the target against one neutral group, CCS measures it from the average of all class centers.
Why it matters
A simple target-minus-neutral vector can carry unrelated variation shared with other groups. CCS uses the competing groups’ spread to filter that vector, while retaining a closed-form additive steering direction.
Before getting into the mechanics, here’s the short version: CCS builds a steering direction for one target by looking not just at where the target sits, but at how target examples vary compared with competing examples. It then keeps the target’s mean displacement only in directions that distinguish that variation. That matters when a plain mean difference also picks up topic, style, or other incidental structure.
-
The baseline: A target-minus-neutral mean can depend heavily on which neutral class you picked. CCS instead measures the target from the grand mean—the average of all class means. The canonical example is a set of prompts labeled by several personas: measuring one persona against a single “neutral” persona can bake that particular comparison into the direction. The grand mean makes the reference collective, though it still depends on which classes your dataset includes.
-
The nuisance problem: Even a stable mean contrast can point along variation that is not really target-specific. Imagine target prompts that vary in both persona and topic, while competing prompts also vary by topic. A mean vector alone does not tell you which part of its direction is shared variability. CCS looks at class scatter around the common grand-mean center: that includes both how examples vary within a class and how far that class sits from the center.
So the real question is not only “where is the target?” but “which directions are more characteristic of the target than of the alternatives?” CCS rewards target scatter and penalizes the average scatter of the competing classes. In mechanism terms, it is like keeping notebook pages that contain target-specific information while suppressing pages the alternatives also fill in; unlike a literal notebook, these directions can overlap and are not cleanly labeled in advance. The penalty strength is the knob: turn it up, and shared nuisance variation counts more against a direction.
- The filter: Once those directions are identified, CCS projects the target’s grand-mean displacement into their span. Think of it as filtering a lookup direction: preserve the part aligned with target-specific variation and discard the rest. This is not the same as erasing all competing behavior; if classes overlap or the data have implicit imbalances, some incidental structure can remain.
What makes the method practical is that this is a spectral problem: the contrastive scatter matrix is symmetric, and its leading eigenvectors give the subspace. You do not need to learn the basis with gradient descent. The final vector is still additive steering, but the direction has been filtered using multiple classes’ second-order structure. What does that buy you, and what assumptions does the filter leave exposed? Overall, I like the move from a single contrast to a contrast shaped by alternatives, but I would not treat a subspace filter as a guarantee of behavioral independence.
Read the deep dive
Why People Wanted It
A difference between a target class and one neutral class can point in the right broad direction while also carrying topic, style, or other variation that the dataset happened to associate with the target. The problem is not only where the target mean sits; it is which directions vary for the target and which of those directions also vary for competing classes. So the real question was never just how to subtract a baseline. It was how to keep the target’s displacement while filtering out directions that look shared or nuisance-like across the alternatives.
The Core Move
Contrastive Covariance Steering (CCS) constructs a target-specific subspace by rewarding target scatter and penalizing average non-target scatter, then projects the target’s displacement from the grand mean into that subspace:
Here is the average scatter of the competing classes, controls its penalty, and projects onto the leading eigenspace of .
Why the Grand Mean Gives a Different Displacement
Here is the deeper version of the centering choice: CCS measures the target from the average of all class means, not from one chosen neutral class. For classes , define
So the reference is the center of the class means, and the target displacement is its offset from that center. This changes the baseline rather than the subspace: a single neutral reference can make the first-order contrast depend on that particular class, whereas the grand mean uses all class means. The activations are centered on when class scatter is computed, so the scatter includes both within-class variation and the class mean’s displacement from the common center.
Why the Scatter Difference Suppresses Shared Directions
Now the version for readers who want more of the machinery: the contrast is between projected energy, not merely a comparison of covariance matrices. Let contain class- activations centered on , scaled by . For a candidate orthonormal basis , is the class’s mean squared projected norm, with the scaling making it independent of class size. The target-specific objective is
In words, choose a -dimensional subspace where target activations have large projected energy and the typical competing class has little. Because the centering is at the grand mean, a competing class is penalized both for varying along a direction and for sitting away from the shared center along it. The knob sets how strongly that average nuisance energy counts. This leaves a practical question: how do you find the best subspace without searching over every possible basis?
Why One Eigensystem Produces the Steering Vector
Here is the part that gets technical: the projected-energy objective can be written as a trace, , where . Its maximizing orthonormal columns are the leading eigenvectors of the symmetric matrix ; placing them in gives the projector . Finally, : keep only the part of the grand-mean-centered target displacement that lies in the target-specific contrastive subspace. The remaining question is what this selective filter buys—and what it cannot promise.
Minimal Causal Code
This deliberately direct sketch makes the state—the current contrastive matrix and selected subspace—visible. It assumes you already have class means and grand-mean-centered activation matrices with the stated class-size scaling.
import torch
# centered[c]: [d, n_c], columns scaled by n_c**(-1/2)
# means[c]: class mean; target and nuisance labels are already chosen
S = {}
for c in classes:
S[c] = centered[c] @ centered[c].T
S_nuisance = sum(S[c] for c in nuisance) / len(nuisance)
A = S[target] - r * S_nuisance
# A is symmetric; take the eigenvectors with largest eigenvalues.
eigenvalues, eigenvectors = torch.linalg.eigh(A)
W = eigenvectors[:, -k:]
P = W @ W.T
mu_grand = torch.stack([means[c] for c in classes]).mean(dim=0)
delta = means[target] - mu_grand
v_ccs = P @ delta
What You Gain, and What You Lose
CCS stays in the closed-form additive-steering setting, but uses second-order information from multiple competing concepts to filter a mean displacement. The eigendecomposition avoids gradient-based subspace optimization. In return, you must choose the target, nuisance classes, subspace dimension , and contrastive weight ; the resulting filter is specific to that target and to the classes represented in the data. Suppressing average nuisance scatter is not a guarantee that every nuisance behavior is removed: class overlap and dataset imbalance can leave shared or incidental structure in the retained direction. The steering vector is a geometric filter, not a proof of behavioral independence.
CCS does not just point toward the target; it filters that displacement through directions where the target varies more than its competitors do.