A probe is a small classifier that reads one property out of a network's hidden activations. The network stays frozen, and only the classifier is trained. It is the simplest way to ask what a trained model carries inside it, and one of the most used tools in interpretability. It is also the easiest one to over-read. A probe that succeeds shows that a property can be decoded from one place in the network. It does not show that the network uses the property, and much of this section is about telling the two apart.
Here is a question a probe can answer. Li et al. (2022) trained a small GPT, a Transformer that predicts the next token, on nothing but lists of Othello moves. Each move is a square name such as "C4", so a game is a list like "C4, E3, F6". The model never sees a board. Its only job is to name a legal next move, and its top guess is illegal only 0.01 percent of the time. To play that well it seems to need the board, which squares are black, which are white, and which are empty. We cannot ask the model whether it keeps a board. We can record its activations on thousands of games and train a classifier to predict each square's color from them. If that classifier succeeds at layer 6, what have we learned about the model?
§23.1 led to this question. Its tools, the input attributions, say which input tokens an output depended on. They never say what the model computed from those tokens, and to see that we have to read the activations. That section also ranked evidence on a ladder of four rungs. From weakest to strongest they are association, direct effect, causal effect, and mechanism. A probe stands on the lowest rung. It shows that something in the activations tracks a property, without changing anything inside the model.
The section runs in this order. We train a linear probe honestly and ask what its accuracy means, which leads to control tasks. We derive the best linear probe and find that the most accurate reading direction is not the direction the model writes the concept along. We erase a concept in closed form and prove that no linear classifier can recover it. We state the linear representation hypothesis, which explains why linear probes work as often as they do, with its evidence and its counterexamples. We end with probes that need no labels, probes as safety monitors, the statistics of probing many layers, and a probe on every layer of a small Transformer in PyTorch.
A probe is a classifier on frozen activations
A probing experiment has three steps. First, pick a trained model and one place in it, called a site, such as the residual stream after layer 6 at the last token. Second, run the model on many inputs and record the activation vector at that site for each one. Third, label each input with the property you care about, and train a classifier that maps activation to label. The model's weights never change.
The site is usually the residual stream. §5.1 described it as the running sum that every block of a Transformer reads from and adds its output to. Throughout this chapter, xt(ℓ)∈Rd is the residual stream at position t after ℓ blocks, in a model of width d. So xt(0) is the token embedding plus the position embedding. And xt(L), after all L blocks, is the last stream before the final normalization LNf, as in §5.6.
Activations are rows. A dataset of N of them stacks into a matrix X∈RN×d, one activation per row, and a probe's weight vector w∈Rd scores a row as x⋅w. Inside derivations we write vectors as columns, as the papers do, so the same score is written x⊤w.
In plain words, a probe asks whether a property can be read off one place in the network by a reader of fixed, usually tiny, capacity. Only the reader is trained, never the network. Here is a linear probe with numbers. Take d=2, w=(2,−1), and b=0.5. The activation x=(1,0.5) gets the score 2−0.5+0.5=2 and the probability σ(2)=0.88, so the probe says the property is present.
The words "held out by the unit the claim is about" matter. If the claim is about games, the test games must be games the probe never saw in training, not just new positions from the same games.
Training a linear probe
A linear probe is logistic regression with activations as its inputs. It is trained to make its predicted probabilities match the labels, with a small penalty that keeps the weights from growing large. §0.2 derived the key gradient. The sigmoid is the softmax of the two logits (0,z), so the derivative of one example's cross-entropy with respect to its logit z is p^n−yn, predicted minus observed. A probe adds a bias b and an L2 penalty on the weights. The loss is the mean cross-entropy plus the penalty,
In plain words, every example pushes the weights along its own activation, in proportion to how wrong its predicted probability is, and the penalty pulls the weights back toward zero.
Two facts from Chapter 0 say how to set this fit and why to trust it. First, the penalty is a prior belief that the weights are small. §0.4 showed that an L2 penalty is maximum a posteriori (MAP) estimation under a Gaussian prior. Multiply the mean loss by N and the penalty becomes the negative log of independent N(0,τ2) priors on the weights, with λ=1/(Nτ2). So a larger λ is a tighter prior. Second, the loss is convex, a bowl with no false bottoms. §0.2 showed that the Hessian of the cross-entropy part is X⊤DX/N, with D diagonal and nonnegative, which is positive semidefinite. With λ>0 the loss is strictly convex, and with both labels present it has a minimum, which is then unique. Gradient descent with a small enough step converges to it from any start.
Five habits separate a probing result from a probing artifact.
Split by the unit of the claim. If test sentences are near copies of training sentences, or share a game, a template, or a document with them, the probe can succeed by recognizing the item rather than reading the property.
Standardize with training statistics only. Centering and scaling with the test set's mean and standard deviation leaks the test distribution into the probe.
Choose the regularization on a validation split, never on the test set.
Report more than accuracy. Give the majority-class rate next to it, the accuracy of always guessing the more common label. Give the AUROC, the probability that a random positive example scores above a random negative one, which needs no threshold. And give an interval (§0.11).
Compare against baselines. Run the same probe on the input embeddings (ℓ=0), on a randomly initialized copy of the model, and on a control task, which the next subsection builds.
To try this we need activations where we know the truth. The cell builds the planted-feature stream, a synthetic stand-in for a residual stream that this chapter uses as its laboratory. Each activation is a sum of fixed feature directions with random strengths, plus a little noise,
x=i=1∑naigi+ϵ.
The gi are n=192 random unit vectors in d=48 dimensions. Each strength ai is zero with probability 0.9 and otherwise uniform on [0,1], and ϵ is Gaussian noise with standard deviation 0.05 per coordinate. There are more features than dimensions, which is the situation §23.5 studies. The concept we probe for is feature 0. It is on for half the examples, with a strength uniform on [0.5,1.5], and off for the rest. We train the probe by full-batch gradient descent, check it against scikit-learn, and report accuracy, AUROC, and a bootstrap interval. The bootstrap resamples the 1,000 test examples with replacement 200 times and reports the middle 95 percent of the AUROCs it gets.
Python · cell 1
The probe reads the concept well. Held-out accuracy is 0.934 against a majority rate near 0.5, and the AUROC is 0.982, with a bootstrap interval from 0.976 to 0.988. Gradient descent lands on scikit-learn's solution. The last line holds a puzzle that we return to below. The probe's weight vector has cosine only 0.864 with g0, the direction the concept was planted along. The plain difference between the two class means has cosine 0.997.
Warm-up
A logistic probe from scratch
Implement train_probe(X_tr, y_tr, X_te, y_te, lam, steps, lr), a logistic probe trained by hand.
Compute the per-coordinate mean mu and standard deviation sd (divisor N, NumPy's default) of X_tr alone, and use them to standardize both splits.
Start from w=0 and b=0. Run steps steps of full-batch gradient descent with step size lr on the mean cross-entropy plus 2λ∥w∥2, with λ = lam. Do not penalize the bias.
Return (w, b, mu, sd, acc). Here w and b act on standardized inputs, and acc is the held-out accuracy of the rule "predict class 1 when p^>0.5".
The tests shift the test set, so standardizing with the wrong statistics changes the answer.
Tests, hints, verified solutions, and AI help, with Pro at $7.99 a month.
In practice, a probe result without its baseline and its interval is the first thing a reviewer or an interviewer will challenge. The next question is subtler. Even with a clean split and a good interval, how much of the accuracy belongs to the representation, and how much to the probe?
Control tasks show how much a probe memorizes
A probe is not a passive meter. It is a learner, and a flexible learner can learn the property by itself from almost any representation that keeps the inputs apart. Two words help here. A word type is an entry in the vocabulary, such as "dog". A token is one occurrence of a type in the text, so "the dog saw the cat" has five tokens and four types.
Here is a tiny case. A corpus has three word types, "the", "dog", and "barks", tagged determiner, noun, and verb. If each type's vector is distinct, a probe that memorizes "this vector is the, so determiner" tags every token correctly. It would also score perfectly on any other fixed assignment, say the as a verb and barks as a determiner. A perfect score then says only that the vectors tell the words apart. It says nothing about whether they encode part of speech.
Contextual word vectors are close to this case, because each one is nearly a unique fingerprint of its word. A large probe can reach high part-of-speech accuracy by memorizing word identities. Hewitt and Liang (2019) turned the arbitrary assignment into a measurement, called a control task.
In plain words, the control task has the same outputs and the same label frequencies as the real task, but its labels have nothing to do with language. The only way to solve it is to recognize each word's identity from its vector and memorize an arbitrary label for it. So control accuracy measures how much this probe can memorize on this representation. Selectivity is the part of the task accuracy that memorization cannot explain.
For this to work, train and test must share word types, as they do in the usual splits of the Penn Treebank, the standard corpus of tagged English sentences. A type never seen in training has an unpredictable control label. So control accuracy is capped at the fraction of test tokens whose type appears in training, plus chance on the rest.
Hewitt and Liang measured selectivity on ELMo, a language model built from two layers of bidirectional LSTMs. They compared linear probes with MLP probes, which have one hidden layer of ReLU units.
The control task also changed a conclusion about ELMo. Probes on its first layer beat probes on its second at part-of-speech tagging, the "lower layers are syntactic" finding of §3.4. Hewitt and Liang found the second layer more selective, 31.4 against 26.0 for the linear probe, at accuracies of 96.6 against 97.2. They proposed that the first layer's lead may come partly from word identity being easier to read off it, since it sits closer to the word embeddings. So an accuracy difference between layers is a difference in what the probe could exploit, not only in what each layer encodes.
The cell reproduces the effect on synthetic data. Four hundred word types each get a random vector in 32 dimensions. A binary property of each type is written along one direction g, and every token gets its own context noise. Both kinds of probe are ridge classifiers, least squares on targets of plus or minus one, which is faster than logistic regression and about as good here. The linear probe reads the raw activations. The MLP probe passes them through a fixed random layer of ReLU units and trains only the readout on top, a cheap stand-in for a trained one-hidden-layer network of the same width.
Python · cell 2
The linear probe gets 0.936 on the task and 0.575 on the control task, a selectivity of 0.361. As the MLP probe widens to 1,024 units, its task accuracy creeps up to 0.972 while its control accuracy climbs to 0.855, and selectivity falls to 0.117. That is the same shape as Hewitt and Liang's table.
The widget runs the same experiment with 48 word types, at four layers of a made-up network. In layer 0 the property is the product of two random signs, an XOR. Tokens that have it sit in two opposite corners of a plane, and tokens that lack it sit in the other two, so no single direction separates them. Layer by layer the property is rewritten, and by layer 3 it lies along one direction. The right panel draws each test token minus its word's own vector, so what is left is the property's code plus the token's context noise. The switch sets how many training tokens each word type gets.
When does a probe measure the representation, and when does it learn the task itself?
48 word types, each with a binary property. Probes are trained on a few tokens per type and tested on new ones.
Loading interactive figure…
Core
Control tasks and selectivity
Word types are the integers 0..V-1, and t_tr, t_te give the type of each token.
Implement control_map(types, y, V, rng). It returns an array of shape (V,) with one control label per type. Draw each label independently with rng from the empirical distribution of the token labels y.
Implement selectivity(probe, X_tr, t_tr, y_tr, X_te, t_te, y_te, V, rng) and return (acc_task, acc_control, sel). The argument probe(X_tr, labels_tr, X_te) trains a probe and returns its predictions on X_te. Build the control map once, from the training tokens, and use that one map to label both splits.
The setup provides a logistic probe, a 1-nearest-neighbour probe that can memorize anything, and a token generator.
Tests, hints, verified solutions, and AI help, with Pro at $7.99 a month.
In practice, use the simplest probe that works, and report a control task or another capacity check whenever the probe is more than linear. Interviewers ask what a control task is, and why an MLP probe with higher accuracy can be the worse experiment.
Three ways to choose the probe's direction
A linear probe is a direction plus a threshold. It scores an activation by its dot product with w and compares the score with the threshold. There are three standard ways to choose the direction. The difference of means takes the average activation of class 1 minus the average activation of class 0. Linear discriminant analysis (LDA) first undoes the spread that both classes share, then takes the difference of means. Logistic regression fits the direction by gradient descent, as in the first cell.
Now back to the puzzle from that cell. The logistic probe and the difference of means pointed in noticeably different directions, and the difference of means was closer to where the concept was planted. Four points in the plane show why.
Python · cell 3
The general statement is a classical theorem, which goes back to the statistician Ronald Fisher in 1936. It says when a linear probe is the best possible classifier, and which direction that probe uses. Write π1=P(y=1) and π0=1−π1 for the class priors, the fractions of each class, and Φ for the standard normal cumulative distribution function.
∂ Proof of the three parts
Part 1. The Gaussian log-density is logN(x;μ,Σw)=−21(x−μ)⊤Σw−1(x−μ)−21logdet(2πΣw). By Bayes' rule the log-odds are logπ1−logπ0 plus the difference of the two log-densities. The determinant terms are equal and cancel because the covariance is shared. Expanding the quadratics, the terms x⊤Σw−1x also cancel, and what is left is
using μ1⊤Σw−1μ1−μ0⊤Σw−1μ0=(μ1+μ0)⊤Σw−1(μ1−μ0), which holds because Σw−1 is symmetric. The posterior is the sigmoid of these log-odds, which is the logistic model with parameters (w⋆,b⋆). Since the logistic family contains the true conditional, its maximum-likelihood estimate is consistent and converges to (w⋆,b⋆) as N grows.
Part 2. The score s=x⊤u is Gaussian in each class, with means u⊤μ1 and u⊤μ0 and the same variance u⊤Σwu. With equal priors and equal variances the best threshold is the midpoint m. A class-1 point is classified correctly with probability P(s>m)=Φ((u⊤μ1−m)/u⊤Σwu)=Φ(21u⊤δ/u⊤Σwu), and by symmetry a class-0 point with the same probability. Since Φ is increasing, maximize J(u)=(u⊤δ)2/(u⊤Σwu), Fisher's criterion. Put a=Σw1/2u and c=Σw−1/2δ, so that u⊤δ=a⊤c and u⊤Σwu=∥a∥2. By Cauchy-Schwarz, J=(a⊤c)2/∥a∥2≤∥c∥2=κ2, with equality exactly when a∝c, that is, u∝Σw−1δ.
Part 3. By part 2 the direction δ is optimal exactly when it is a positive multiple of Σw−1δ, which says Σwδ=cδ for some c>0. ∎
In plain words, the best linear reader of a concept first whitens away the spread that the concept does not cause, then reads along the mean difference. To whiten is to change coordinates linearly so that a covariance becomes the identity (§0.10). Here the change is Σw−1/2, after which each class is a round cloud and the difference of means is optimal by part 3. Undoing the change turns that direction into Σw−1δ in the original coordinates. The number κ is the Mahalanobis distance between the means, their distance measured in units of the within-class spread.
Part 2 makes the four points quantitative. Pretend each class were a Gaussian with the covariance Σw just computed. The difference of means u=(2,0) has u⊤δ=4 and u⊤Σwu=16, so its accuracy would be Φ(21⋅4/4)=Φ(0.5)=0.69. LDA reaches κ2=δ⊤Σw−1δ=(2,0)⋅(25,−14)=50 and accuracy Φ(50/2)=Φ(3.54)=0.9998. The same means and the same spread give 69 percent along one direction and near certainty along the other.
One more identity says that it does not matter which covariance we whiten with, and erasure will use it.
Proof. The law of total covariance splits Σ into the average within-class covariance, Σw, plus the covariance of the class means about the overall mean, which is π1π0δδ⊤. Multiplying out, Σ(Σw−1δ)=δ+π1π0δ(δ⊤Σw−1δ)=(1+π1π0κ2)δ. Divide by the scalar and multiply by Σ−1. ∎
How does the logistic probe fit in? Its L2 penalty decides where it lands. A strong penalty pulls it all the way to the difference of means, and a weak one lets it reach the LDA direction.
∂ Proof of the strong-L2 limit
Setting the gradient to zero gives two conditions, λwλ=N1∑n(yn−p^n)xn and ∑n(yn−p^n)=0. Comparing the minimum with w=0 gives 2λ∥wλ∥2≤minbL(0,b)≤log2, so wλ→0. Every p^n then tends to the same value σ(bλ), and the bias condition forces that value to yˉ. Substituting p^n→yˉ in the first condition gives the limit. Finally, N1∑n(yn−yˉ)xn=yˉμ^1−yˉ(yˉμ^1+(1−yˉ)μ^0)=yˉ(1−yˉ)(μ^1−μ^0). ∎
In plain words, a heavily penalized probe barely moves away from predicting the base rate, and its first small step from there is along the class-mean difference. So the penalty slides a logistic probe between the difference of means and the LDA direction. The next subsection shows that these two play different roles, one marks where the concept is written and the other is the best way to read it. When you compare probe directions across layers or papers, you must know where on that slide each one sits.
The most accurate probe is not the direction the model writes
The four points already showed that the best classifier can point away from the mean difference. Now we ask what each direction does when we add it to the activations. We need a toy where we know the answer. A concept is written along a unit vector gc. A nuisance feature, unrelated to the label, is written along a unit vector gf that overlaps it, gc⋅gf=0.5. Overlaps like this are typical when a network stores more features than it has dimensions (§23.5). Each activation in R32 is
x=(y−21)gc+zgf+ϵ,z∼N(0,4),ϵ∼N(0,0.09I).
Here y∈{0,1} is the label and z is the nuisance's random strength. Suppose the network downstream reads each feature with a readout that recovers that feature's value exactly and ignores the other. For two overlapping directions these readouts are the dual vectorsgc∗ and gf∗, defined by gc∗⋅gc=1, gc∗⋅gf=0, and the same with the roles swapped.
We fit the three probes. Then we steer with each one, which means adding a vector to the activations, as §23.7 does at scale. We read what the step does to both features through their dual vectors. Each step θ points along the probe's own direction. It is scaled so that it moves the probe's score by the gap between the class means, as Marks and Tegmark (2023) do.
Python · cell 4
The difference of means points along gc (cosine 0.998) but classifies poorly, 0.674, as part 2 of the theorem predicts (0.673). LDA and logistic regression tilt away from the nuisance and reach about 0.92, against a prediction of 0.925. Steering moves the concept by its full class gap in every case. Along the LDA or logistic direction, though, it also moves the nuisance by about half a unit (minus 0.49) for every unit the concept moves. The difference of means leaves the nuisance nearly alone, and its 0.05 is sampling error in the estimated means.
So the accurate probe is the right reader, and the difference of means is the right writer. They coincide only when the nuisance spread is orthogonal to the concept, which is part 3 of the theorem again.
The next cell checks the strong-L2 theorem on the same data. scikit-learn sets the penalty through C=1/(λN), so a small C is a strong penalty.
Python · cell 5
The regularization sweep confirms the strong-L2 theorem. At C=10−5, the strongest penalty, the logistic probe is the difference of means (cosine 1.000). As the penalty weakens it rotates to the LDA direction, reaching cosine 0.999 at C=0.1 and 0.997 at C=10.
The widget below runs the same comparison in two dimensions. The black dashed arrow is where the concept is written, the grey dotted one is the nuisance, and each colored arrow is one probe's direction. The bars give each probe's accuracy on new points and how far steering along it moves the nuisance for every unit it moves the concept.
Do the most accurate probe and the direction the model writes point the same way?
Each probe is fit on 600 points, tested on 600 new ones, then used to steer.
Loading interactive figure…
Interview
Difference of means, LDA, and their thresholds
Implement mean_diff_probe(X, y) and lda_probe(X, y, shrink=0.0). Each returns (w, b) for the rule "class 1 when x⋅w+b>0", with the threshold at the projected midpoint of the two class means. The first uses w=μ1−μ0. The second uses w=Σs−1(μ1−μ0). Here Σw is the pooled within-class covariance, built from the deviation of every point from its own class mean with divisor N. The shrunk covariance Σs=(1−s)Σw+sdtrΣwI pulls it toward a multiple of the identity by the amount shrink=s. One test has more dimensions than examples, where Σw alone cannot be inverted.
import numpy as np
def mean_diff_probe(X, y):
raise NotImplementedError
def lda_probe(X, y, shrink=0.0):
raise NotImplementedError
Tests, hints, verified solutions, and AI help, with Pro at $7.99 a month.
This distinction is a favorite interview question. Expect to be asked when the difference of means is Bayes-optimal, to derive LDA from two Gaussians, and to explain why the best classifier is not the best steering vector.
Erasing a concept to test whether it is used
A probe shows that a property is decodable. To ask whether the network uses it, remove the property from the activations and check whether the network's behavior changes. Elazar et al. (2021) called this amnesic probing. It raises a precise question first. What does it mean for a concept to be gone?
One natural answer is that no linear probe can find it anymore. That is the definition below. It quantifies over every linear probe and every reasonable training loss at once.
In plain words, after erasure no linear probe, trained with cross-entropy, squared error, hinge loss, or any other convex loss, can do better than ignoring x and predicting the base rate. That is a strong statement. The useful fact is that it reduces to one vector being zero. Write
σxy=Cov(x,y)=E[xy]−E[x]E[y]∈Rd
for the cross-covariance of the activations with the label.
∂ Proof of the equivalence
(1 and 2.) Since E[xy]=π1μ1 and E[x]=π1μ1+π0μ0, we get σxy=π1μ1−π1(π1μ1+π0μ0)=π1π0(μ1−μ0), and π1π0>0.
(1 implies 3.) Take any affine η(x)=x⊤w+b and any loss ℓ convex in its first argument. Condition on the class and apply Jensen's inequality to the convex function x↦ℓ(η(x),y),
where the last step uses μ1=μ0=μ. So η is no better than the constant c.
(3 implies 2.) Use the logistic loss, one of the convex losses that guardedness covers. Its best constant is b0=log(π1/π0), where σ(b0)=π1. Move from (0,b0) a distance t along the weights w=σxy. The derivative of the expected loss at t=0 is E[(σ(b0)−y)x⊤σxy]=−σxy⊤σxy, using E[(π1−y)x]=−σxy. If σxy=0 this is negative, so a small step beats the best constant and x does not guard y. ∎
In plain words, a linear reader can beat a constant guess only if the two classes sit at different average positions. Make the class means equal and every linear reader is blind. Many affine maps, a matrix times x plus a vector, make the means equal. Which one changes the representation least? The answer is called LEACE, for least-squares concept erasure.
In plain words, LEACE reads the concept with the whitened reader Σ−1σxy and subtracts exactly that much along σxy. By the proof of the equivalence above, σxy is a positive multiple of the mean difference δ, the direction the concept is written along. By the total-covariance theorem above, Σ−1σxy points along the LDA direction, the best reader. So LEACE removes the concept where it is written, by the amount the best probe reads. The four points from before make this concrete.
Python · cell 6
∂ Proof of LEACE, and why the binary formula is the general one
Guardedness and the mean. Covariance is linear and constants do not change it, so Cov(r(x),y)=σxy−σxyσxy⊤Σ−1σxy/(σxy⊤Σ−1σxy)=0, and E[x−μ]=0 gives E[r(x)]=μ. By the previous theorem r(x) linearly guards y.
Optimality. Any affine map can be written x↦x−Q(x−μ)+c for some matrix Q and vector c, and its output guards y exactly when Qσxy=σxy. The mean squared change is E∥Q(x−μ)∥2+∥c∥2, because the cross term has mean zero, so take c=0. What remains is tr(QΣQ⊤)=∑iqi⊤Σqi over the rows qi⊤ of Q, and the constraint says, row by row, that qi⊤σxy=σi, the i-th entry of σxy. The rows decouple. For each one, Cauchy-Schwarz applied to Σ1/2qi and Σ−1/2σxy gives
σi2=(qi⊤σxy)2≤(qi⊤Σqi)(σxy⊤Σ−1σxy),
with equality exactly when qi∝Σ−1σxy. The constraint fixes the constant, qi=σiΣ−1σxy/(σxy⊤Σ−1σxy). Stacking the rows gives Q=σxyσxy⊤Σ−1/(σxy⊤Σ−1σxy), which is the map r, and summing the bounds gives the minimum ∑iσi2/(σxy⊤Σ−1σxy).
The general formula. With one concept, Σxy=σxy and P=vv⊤/(v⊤v) for v=Σ−1/2σxy. Then Σ1/2PΣ−1/2=σxyσxy⊤Σ−1/(σxy⊤Σ−1σxy), the same Q. Read the general formula right to left and it says whiten (§0.10), project out the concept's direction in whitened space, and unwhiten. ∎
The matrix Q=σxya⊤ in LEACE satisfies Q2=Q but is not symmetric. It is an oblique projection, one that removes a direction while measuring along a different one, and that is how it beats every orthogonal projection. Two simpler erasers make the comparison concrete.
Mean projection is the orthogonal projection that removes the unit vector along δ. It also equalizes the means, so it also guards linearly. But it throws away all the variance along δ, the nuisance's included. Its mean squared change is σxy⊤Σσxy/∥σxy∥2. By Cauchy-Schwarz on Σ1/2σxy and Σ−1/2σxy, that is never less than LEACE's, with equality only when σxy is an eigenvector of Σ.
Projecting out the probe's weight vector removes the reading direction, so it destroys that one probe. But (I−w^w^⊤)σxy=0 unless σxy is parallel to w, so a freshly trained probe finds what is left. Iterative nullspace projection, INLP (Ravfogel et al. 2020), repeats the step. It trains a new probe and projects out its direction, again and again, until accuracy reaches the majority rate. It gets there, but each round removes a whole direction, so it usually deletes far more than the concept.
The cell runs all three erasers on the toy from the last subsection, the concept and the overlapping nuisance.
Python · cell 7
LEACE and mean projection both drive the cross-covariance to rounding error and a freshly trained probe to 0.501, chance. LEACE does it with a mean squared change of 0.378, against 1.470 for mean projection, nearly four times less. Projecting out the logistic probe's direction changes the data least, 0.271, and fails, since a fresh probe still reaches 0.575.
Interview
Erase a concept in closed form
Implement leace_binary(X, y, ridge=1e-9) for activations X of shape (N, d) and binary labels y. Estimate from the data the mean μ, the total covariance Σ (divisor N, plus ridge times the identity), and the cross-covariance σxy. Return a function erase(Z) that applies r(x)=x−σxyσxy⊤Σ−1(x−μ)/(σxy⊤Σ−1σxy) to every row of a new array Z, using those fitted statistics. The tests check zero cross-covariance, a fresh probe at chance, an unchanged mean, a smaller change than orthogonal mean projection, and the formula on new data.
import numpy as np
def leace_binary(X, y, ridge=1e-9):
raise NotImplementedError
Tests, hints, verified solutions, and AI help, with Pro at $7.99 a month.
What does erasure prove? Erasing a concept and then running the rest of the model is an intervention, so it climbs the ladder to the causal rung. If the model's behavior degrades on exactly the inputs where the concept matters, the model was using it. §23.4 develops this kind of evidence with patching, and erasing a direction at every position becomes the directional ablation of §23.7.
Erasure has three limits. First, linear erasure removes only linearly available information, as the four points showed. A nonlinear probe may still succeed unless the two class-conditional distributions become identical. They do for shared-covariance Gaussians. An affine r maps each class to a Gaussian, makes the two means equal, and keeps the two covariances equal, so the two classes end up with the same distribution. Second, a later layer may recompute an erased concept from other features. Third, an erased activation may lie off the distribution the model was trained on, so a change in behavior can come from the damage rather than from the missing concept.
In an interview, expect to be asked how LEACE differs from projecting out a probe's weights, and why the answer involves whitening. In practice, erasure is how a probing claim becomes a claim about use.
Why linear probes work so often
Why should a linear probe work at all? A network is free to store a concept in any curved, tangled way it likes. The linear representation hypothesis is the claim that many concepts a network uses are carried as directions in its activation space, so that how strongly a concept is present is how far the activation reaches along its direction. §1.5 found the first hint in word vectors. In the analogy vking−vman+vwoman≈vqueen, the relation male to female is one direction. §1.6 warned how easily two-dimensional pictures of such geometry mislead.
At the very end of a language model, linearity is exact. The logits are zv=h⋅uv. Here h=LNf(xt(L)) is the normalized last stream, and uv=(WU):,v is the column of the unembedding matrix for token v (with no output bias, as in GPT-2). For two tokens a and b the softmax's shared denominator cancels, so
logp(b)p(a)=za−zb=h⋅(ua−ub).
If za=3.1 and zb=1.1, the model puts e2≈7.4 times as much probability on a as on b, whatever the other logits are. So, conditioned on the next token being a or b, the log-odds of a are a linear probe with weight ua−ub. Every binary choice between tokens is linearly readable from the last layer, by construction. The hypothesis is that concepts are linear in the middle of the network too, where nothing forces it.
"Concept is a direction" can mean three different things, and Park, Choe, and Veitch (2023) separated them. One needs a term first. Two concepts are causally separable when each can be changed without changing the other. Gender and language are causally separable. Changing "king" to "queen" changes the gender and keeps the language, and changing "king" to "roi" changes the language and keeps the gender.
The three versions are different claims. The unembedding version is about outputs. The embedding version is about what an edit to the stream does. The probing version is about what a classifier can read. Park et al. show that the unembedding version yields a linear probe, on the logit scale, for each counterfactual pair, which generalizes the last-layer identity above. They also show that the embedding version is the property that steering relies on, the subject of §23.7. So a probing result alone tests only the third version, which says nothing about outputs or edits.
Whether real networks are linear in the middle is an empirical question. The evidence for it is strong, and the clearest case is Othello.
Othello-GPT has become the standard example in the debate over whether sequence models trained only to predict build internal models of the world that produced their data. A probe alone could not settle it. The interventions did.
The same pattern appears in models trained on text. Marks and Tegmark's truth directions generalize across datasets of true and false statements, and they flip the model's judgments when added. Gurnee and Tegmark (2023) fit ridge-regression probes on the last token of the names of places, people, and events in Llama-2 7B, 13B, and 70B. In Llama-2-70B at 60 percent of its depth, they recovered the latitude and longitude of world places with out-of-sample R2=0.911, the fraction of the variance on held-out names that the probe explains, and the death years of historical figures with R2=0.835. Probes with a hidden layer added little (0.926 for world places). Tigges et al. (2023) found one sentiment direction in GPT-2 and Pythia models. Ablating it removed 76 percent of the above-chance zero-shot accuracy on the Stanford Sentiment Treebank.
There are also clear counterexamples. Engels et al. (2024) used sparse autoencoders, dictionaries of sparse features learned from activations (§23.6), to search GPT-2 and Mistral 7B. They found features that are irreducibly two-dimensional, the days of the week and the months of the year arranged on circles. Interventions in Mistral 7B and Llama 3 8B showed that the circles are what the models use for modular arithmetic on days and months. A circle cannot be one direction. A linear probe can still read "is it Tuesday" from it, but the variable the model computes with, the position on the circle, lives in a plane. Othello's colors show a subtler failure. A concept can be linear in one choice of variables and nonlinear in another, and the hypothesis gives no rule for finding the right variables. In practice, finding them is most of the work, and a failed linear probe is not proof that a concept is absent.
An interviewer will ask you to state the hypothesis and to give one piece of evidence and one counterexample. The strongest answer names the three versions, uses Othello-GPT for the evidence and the circular days for the counterexample, and says which version each one tests.
Unsupervised probes find what is salient, not what is true
Every probe so far needed labels. Labels are exactly what we lack when we want to know what a model believes, rather than what we believe. Burns et al. (2022) proposed finding truth without labels by using its logical structure. A statement and its negation cannot both be true. So turn each yes-or-no question qi into a contrast pair of two texts, xi+ ending in "Yes" and xi− ending in "No". Exactly one of the two is true, so a probe for truth should give them probabilities that add to one. The method searches for a probe with that property, and is called contrast-consistent search, CCS for short.
In plain words, the loss has two terms. The first is consistency. It asks a statement and its negation to have probabilities that add to one. Alone it is minimized by p=0.5 everywhere, so the second term, confidence, asks the probe to be sure about one of the two. For a pair with p(x+)=0.9 and p(x−)=0.2, the consistency term is (0.9−0.8)2=0.01, the confidence term is 0.22=0.04, and the pair's loss is 0.05.
The per-side normalization matters. The most salient difference within each pair is that one text ends in "Yes" and the other in "No". A probe that read only that would satisfy both terms perfectly, and subtracting each side's own mean removes it. Across six models and ten question-answering datasets, CCS beat zero-shot prompting by 4 percent on average, and it stayed accurate when prompts pushed the models toward wrong answers.
Proof. The consistency term is (h−(1−(1−h)))2=0, and the confidence term is min(h,1−h)2=0 because one of h and 1−h is 0. Both terms are nonnegative, so 0 is the minimum. ∎
The theorem says the objective is underspecified. It does not say CCS will find a bad feature, since a linear probe on real activations can express only some of these h. Their experiments showed that it often does. In one, they appended one of two random words, "Banana" or "Shed", to movie-review prompts, according to a random split of the questions. In another, they inserted "Alice thinks it is positive" or "negative" into the prompts. Both times CCS learned the distractor instead of the review's sentiment. So did two simpler unsupervised baselines, one that thresholds the top principal component of the activations and one that splits them into two clusters with k-means. The probe finds whatever binary feature flips most saliently between the two members of a pair. The research exercise reproduces this.
Research
Contrast-consistent search and its failure
Implement three functions.
ccs_loss(p_pos, p_neg) returns the CCS loss for two arrays of probabilities, one entry per pair.
normalize_pairs(Phi_pos, Phi_neg) centers each side of the pairs with its own mean.
fit_ccs(Xp, Xn, steps, lr, seed) fits (θ,b) by full-batch gradient descent on the CCS loss and returns (theta, b). Start from theta = rng.normal(size=d) / np.sqrt(d) with rng = np.random.default_rng(seed), and b = 0. Derive the gradient by hand. When p+=p− exactly, let the confidence term act on p+.
The setup builds contrast pairs whose activations contain three directions. One is "ends in Yes", one is truth, and one is a distractor that also flips sign between the two members of a pair. It also provides best_of_restarts, which keeps the lowest-loss fit over several seeds. The last test reproduces the finding of Farquhar et al. When the distractor is more salient than truth, CCS finds the distractor.
Tests, hints, verified solutions, and AI help, with Pro at $7.99 a month.
There is a deeper problem. A model may represent several candidate truths at once, its own belief, what a character in the text believes, and what a typical writer would say. All of them are consistent, so a consistency loss cannot tell them apart. That is why interviewers ask what CCS finds, and why the honest answer is "the most salient consistent feature". In practice, an unsupervised probe is a way to find candidate directions, which then need labeled checks and interventions like any other probe.
Probes as safety monitors
Probes are cheap, one dot product per token, which makes them attractive as safety monitors that read a deployed model's activations and raise a flag. §19.6 described linear probes, built from generic contrast pairs, that flagged when deliberately backdoored "sleeper agent" models were about to act on their hidden trigger. §19.8 described semantic entropy probes, which predict from the hidden states of one generation whether the model is making an answer up.
Two cautions come with every such number. First, set the threshold on the data the monitor will actually see, at a fixed false-positive rate. §0.11 explains why a high AUROC can still mean many false alarms when the behavior is rare. Second, a monitor can be evaded once something optimizes against it. Bailey et al. (2024) showed that probes, sparse autoencoders, and out-of-distribution detectors on activations are all vulnerable to obfuscated activations, internal states that keep a harmful behavior while looking harmless to the monitor. Against probes trained to detect harmful requests, their attacks often cut recall from 100 percent to 0 while keeping a 90 percent jailbreak success rate.
The same holds for training. A model trained with a probe in its loss can learn to satisfy the probe instead of changing its behavior. A probe is a good monitor as long as nothing has been trained to beat it. In practice, that means a probe monitor is kept out of the training loop and its threshold is checked on fresh traffic. An interviewer will ask how you would validate one, and the last interview question below gives an answer. §23.6 returns to monitors when it compares probes with sparse-autoencoder features on the same detection task.
Doing the statistics honestly
A probing study usually tests many sites. Suppose you probe 32 layers at 3 token positions with 5 seeds, 480 probes in all, and report the best. Two questions decide whether the result means anything. How many test examples does one accuracy need, and how much does choosing the best of 480 inflate it? The cell answers both, the second by simulating 480 independent probes that are all at chance.
Python · cell 8
Real probes on neighboring layers are correlated, which shrinks the inflation but does not remove it. There are two remedies, and they can be combined. Pick the layer and position on a validation split and report the test accuracy of that one choice. Or correct for the number of comparisons. Interviewers like this question because it separates people who have run probing studies from people who have read about them.
Probing every layer in PyTorch
In a real model the activations come from forward hooks. A hook is a function PyTorch calls with a module's input or output during the forward pass, so it can record activations without changing the model (§0.9). The block below trains a two-layer Transformer on sequences of 12 tokens drawn from 6. At every position it must say whether more 0s than 1s have appeared so far. Then it probes x(0), x(1), and x(2) for a related variable that the training labels never mention, whether a 0 occurred at an earlier position. It does this for the trained model and for an untrained copy.
🔥 In PyTorchfor a machine with PyTorch
The trained model's probes read the variable with accuracies 0.740, 0.966, and 0.962 at the three sites, against a majority rate of 0.539. Two baselines make those numbers interpretable. At x(0) the probe already beats the majority rate, because the position embedding is there and later positions are more likely to have seen a 0. Both models score 0.740 there, which is what the best rule that sees only the position scores on these test sequences. A position with t tokens before it has seen a 0 with probability 1−(5/6)t, which first passes one half at t=4, so that rule says "yes" from the fifth position on. And the untrained model reaches 0.893 and 0.913 after its blocks, because even random attention averages the earlier tokens' embeddings into each position. The trained model adds about five to seven points on top. Without the untrained baseline, "layer 1 represents whether a 0 occurred" would have credited learning with what the architecture does for free. In practice, every layer-by-layer probing plot should carry the same curve for an untrained copy of the model, and an interviewer who sees a plot without it will ask for it.
Choosing a method
method
what it measures
strengths
weaknesses
logistic probe
linear decodability at one site
standard, convex, gives a calibrated probability
weight vector is a reading direction, not the concept's direction
difference of means
the direction the classes differ in
no training, best steering vector, matches the write direction
poor classifier when nuisances overlap the concept
LDA (whitened) probe
Bayes-optimal linear reading for shared-covariance Gaussians
closed form, accurate, shrinkage handles d>N
needs a covariance estimate, same reading-direction caveat
MLP probe
nonlinear decodability
finds information that is there but not linear
can learn the task itself, low selectivity
control task and selectivity
how much of the accuracy is memorization
simple, interpretable
needs labels that belong to word types
description length (MDL)
how easily the property is extracted
works for any labels, stable
more training runs, less familiar
sparse probe
whether a few neurons carry the property
localizes to neurons
assumes neurons are meaningful units, which §23.5 questions
CCS
a consistent binary feature, without labels
needs no labels
finds the most salient flipped feature, which need not be truth
LEACE, INLP, amnesic probing
whether removing the property changes behavior
causal, closed form (LEACE)
linear only, can push activations off distribution
The sparse probe in the table is that of Gurnee et al. (2023), a linear probe allowed to use only k neurons. In Pythia models from 70 million to 6.9 billion parameters, they found early layers representing many features with sparse combinations of neurons, and middle layers with neurons that seem dedicated to single features. It was an early sight of the superposition that §23.5 explains.
Belrose et al. (2023). LEACE: Perfect linear concept erasure in closed form. The equivalence of linear guardedness and zero cross-covariance, the optimal eraser for every inner-product norm, and concept scrubbing.
🎬 Probing Classifiers: A Gentle Intro (Explainable AI for Deep Learning) · Jay AlammarA short visual introduction to how probes are trained on sentence and token representations, ending with why control tasks are needed (from 9:48).🎬 Geometry of Truth · Arize AISamuel Marks explains his truth-direction datasets, mass-mean probing, and why the most accurate probe is not the most causal direction.🎬 What does AI believe is true? · Samuel AlbanieA careful walkthrough of contrast-consistent search (Burns et al.), to watch before reading the critique and doing Exercise 23.2e.