Dissecting AI
From the paper: Contrastive Covariance Subspaces for Activation Steering

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 ↗
The short version

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.

  1. 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.

  2. 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.

  1. 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:

At=St−rSNt,vCCS=Pt(μt−μG).A_t = S_t - rS_{N_t}, \qquad v_{\mathrm{CCS}} = P_t(\mu_t-\mu_G).

Here SNtS_{N_t} is the average scatter of the competing classes, r≥0r\geq 0 controls its penalty, and PtP_t projects onto the leading eigenspace of AtA_t.

Quiz
What does CCS do after computing the target’s displacement from the grand mean?
Finds the subspace by gradient descent over steering vectors.
Projects it into a subspace that rewards target scatter and penalizes average nuisance scatter.
Adds every competing class mean to the target displacement.
Uses only the within-class covariance of a single neutral class.

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 c∈Cc\in\mathcal C, define

μG=1∣C∣∑c∈Cμc,δt=μt−μG.\mu_G = \frac{1}{|\mathcal C|}\sum_{c\in\mathcal C}\mu_c, \qquad \delta_t=\mu_t-\mu_G.

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 μG\mu_G 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 Hc′H'_c contain class-cc activations centered on μG\mu_G, scaled by nc−1/2n_c^{-1/2}. For a candidate orthonormal basis WW, ∥W⊤Hc′∥F2\|W^\top H'_c\|_F^2 is the class’s mean squared projected norm, with the scaling making it independent of class size. The target-specific objective is

max⁡W⊤W=Ik  ∥W⊤Ht′∥F2−r 1∣Nt∣∑c∈Nt∥W⊤Hc′∥F2.\max_{W^\top W=I_k}\;\|W^\top H'_t\|_F^2-r\,\frac{1}{|N_t|}\sum_{c\in N_t}\|W^\top H'_c\|_F^2.

In words, choose a kk-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 rr 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, tr⁡(W⊤AtW)\operatorname{tr}(W^\top A_tW), where At=St−rSNtA_t=S_t-rS_{N_t}. Its maximizing orthonormal columns are the kk leading eigenvectors of the symmetric matrix AtA_t; placing them in WtW_t gives the projector Pt=WtWt⊤P_t=W_tW_t^\top. Finally, vCCS=Ptδtv_{\mathrm{CCS}}=P_t\delta_t: 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 kk, and contrastive weight rr; 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.

Quiz
Which limitation follows from CCS using average nuisance scatter to shape its subspace?
It requires a separate neutral reference class for every token.
It does not guarantee removal of every nuisance behavior, especially when classes overlap or data are imbalanced.
Its steering vector is not additive.
It cannot use second-order information from competing classes.
Core Takeaway

CCS does not just point toward the target; it filters that displacement through directions where the target varies more than its competitors do.