CodeRigor

FREE LESSON

Activation probes & controlled interventions

Training-only directions, projection removal and distinguishing predictive probes from causal evidence.

A probe asks whether information can be predicted from a representation. Predictive success does not establish that the original model uses that information causally. A probe may exploit a confounder, memorized split, or information that is present but ignored by downstream computation.

A simple direction is the difference between the positive and negative class mean activations, normalized to unit length. Fit it on training activations only. Evaluate its predictions on held-out examples and compare a baseline.

Fitting a direction and testing it on held-out examples are separate operations.

Train a simple representation probe
Fit the positive-minus-negative mean direction only on training activations. Evaluate its predictive information on separate examples; decodability alone does not show causal use.
Train a simple representation probe
Fit the positive-minus-negative mean direction only on training activations. Evaluate its predictive information on separate examples; decodability alone does not show causal use.
Python
import numpy as np

positive = np.array([[2.0, 0.0], [4.0, 0.0]])
negative = np.array([[0.0, 0.0], [0.0, 0.0]])
direction = positive.mean(0) - negative.mean(0)
direction /= np.linalg.norm(direction)
print(direction.tolist())

Removing a unit direction d from activation h computes h - (h·d)d. It removes one component while retaining orthogonal components. Normalize arbitrary nonzero directions before applying this formula; otherwise direction scale changes the intervention. A zero direction has no defined orientation.

Python
import numpy as np

h = np.array([[3.0, 4.0]])
d = np.array([1.0, 0.0])
residual = h - (h @ d)[:, None] * d
print(residual.tolist())

An intervention can move activations off-distribution and change unrelated behavior. Compare matched random directions, multiple seeds, task performance and intervention magnitude before a causal claim. In this small build we verify algebraic properties, not a claim about real model internals.

Removing one component keeps the orthogonal remainder. This algebraic property is much narrower than a causal claim about a model.

Projection and residual in two dimensions
For h=(3,4) and unit d=(1,0), the parallel component is (3,0) and the residual is (0,4). Removing the same direction again changes nothing.
Projection and residual in two dimensions
For h=(3,4) and unit d=(1,0), the parallel component is (3,0) and the residual is (0,4). Removing the same direction again changes nothing.

Test projection idempotence, scale invariance of direction, orthogonality of residuals and unchanged input storage. Probe fitting must require both classes and a nonzero mean difference. In the final lab, document what a toy probe result can and cannot establish before trying any external model study.

Watch & read

Free lectures, talks and readings that cover this skill from another angle. All resources →

Compare attribution-based model understanding with this lesson’s held-out linear probe and direction removal. Captum is optional viewing context; the graded probe uses NumPy and requires no extra package.