6.3.5 · D2Interpretability & Explainability

Visual walkthrough — Probing classifiers

3,692 words17 min readBack to topic

Prerequisite ideas we lean on live in Probing classifiers (the parent), and it will help to have met Attention Mechanisms (where the representations come from) and Fine-tuning vs. Feature Extraction (why we freeze the model).


Step 1 — A representation is just a point in a room

WHAT. A neural network, when it reads a word like "cat", does not store a word — it stores a list of numbers. Say the list has numbers. We write it . That bold-h is called an activation or a representation.

WHY. We cannot argue about "what the model knows" until we agree on where that knowledge lives. It lives as a location. If , the location is a dot on a flat sheet of paper: is how far right, is how far up. If it's a dot in a room. Real networks use in the hundreds — same idea, more directions than we can draw, so we always draw and trust the picture generalizes.

PICTURE. Below, three different sentences each become one black dot. The two axes are the two numbers in the representation. A "representation" is nothing more mysterious than an address.

Figure — Probing classifiers

Step 2 — A property colours the points

WHAT. Now attach a label to each dot. For the property subject–verb agreement, each dot's label is either agree or disagree. We colour every agree dot with our accent colour and leave every disagree dot black.

WHY. The whole question of probing — "did the model encode the property ?" — becomes a question about colour geometry: are the red dots and black dots in separate regions, or are they hopelessly mixed? If they sit in separate regions, the property is "in there" as a shape you could point at.

PICTURE. Same room as Step 1, now the dots are coloured by their property label. Notice the reds have drifted to one side. That drift is the model encoding the property.

Figure — Probing classifiers

Step 3 — The linear probe is a straight cut

WHAT. A linear probe tries to separate the two colours with a single straight cut — a line in 2-D, a flat sheet (a hyperplane) in higher . The cut is described by an arrow (which way is "more red") and an offset (how far from the origin the cut sits):

  • ::: the dot product, which measures how far along the direction the point sits.
  • ::: the exact set of points sitting on the cut.
  • on one side, on the other side.

WHY a straight cut and not a wiggly one? Because we are testing whether the information is easy to read out. A wiggly boundary (an MLP) could carve out any clump of reds no matter how scrambled — so it would tell us nothing about whether the model organised the property. Insisting on a straight cut is what makes a high score meaningful: only a genuinely organised representation can be split by a plane.

WHY the dot product? We need one number per point that says "which side, and how far?" The dot product is precisely the length of 's shadow along . It answers the question "project this point onto the red-ward direction — where does it land?" No other simple operation gives a clean side-and-distance in one scalar.

PICTURE. The accent line is the cut. The accent arrow points from the cut toward the red side. Every point's shadow onto is its score .

Figure — Probing classifiers

Step 4 — Turning a score into a probability, then a class

WHAT. The score runs from to . We squash it into a probability with the sigmoid :

From probability to a hard class. The accuracy in the top definition needs a discrete prediction, not a probability. We threshold at — which, since , is the same as reading off the sign of the score:

A point is correctly classified exactly when , i.e. when the true label and the side of the cut agree. The accuracy is just the fraction of held-out points for which this holds.

WHY the sigmoid and not just "sign of "? Two reasons. (1) We want a smooth readout so training has a slope to follow. The hard function is not differentiable at — it jumps from straight to with no slope there and zero slope everywhere else, so gradient descent has nothing to follow. The sigmoid is smooth everywhere. (2) The value at being exactly matches the cut being the "no idea" boundary from Step 3. So turns the geometry (which side, how far) into confidence — and thresholding turns that confidence back into a class for scoring.

PICTURE. The S-shaped curve: horizontal axis is the raw score , vertical axis is the probability. The accent point marks , sitting right on the cut; the dashed threshold at shows where the class prediction flips.

Figure — Probing classifiers

Step 5 — The margin: how far the nearest point sits from the cut

WHAT. Many straight cuts might separate the colours. Which is "best"? The one that leaves the biggest empty gap. The margin is the distance from the cut to the closest point:

  • ::: point 's signed score (Step 3).
  • ::: the numeric label from Step 2 ( red, black); multiplying by it makes a correctly placed point give a positive product (right sign × right side = ).
  • ::: divides out the arrow's length so is a true distance in the room, not just a raw score (doubling must not "double" the margin — it's the same cut).
  • ::: we care about the worst (closest) point — that's the weakest link.

WHY care about the gap? A wide gap means the reds and blacks are in firmly separate territories — the property is robustly, unmistakably encoded. A razor-thin gap means the probe barely works: a whisker of noise flips points across. So margin size measures how confidently the layer encodes , beyond just "did the cut succeed."

WHY margin controls accuracy on unseen points. Held-out accuracy is about points the probe never trained on. Picture wrapping a tube of radius around the cut: no training point lies inside it. A fresh test point that is a genuine sample of the same colours must land near its own colour's cloud; to be misclassified it would have to jump all the way across that empty tube. The wider the tube (bigger ), the more a test point can wander and still stay on the correct side — so larger margin ⇒ fewer test-time flips ⇒ higher . This is the intuition behind the classical bound "test-error (something)": generalization error shrinks as the margin grows.

PICTURE. Two parallel dashed lines hug the cut; the accent double-arrow between them is . The circled points touching the dashed lines are the closest points that set the margin. The shaded empty tube is the room a test point may wander in without being misclassified.

Figure — Probing classifiers

Step 6 — Edge case A: the colours overlap (no straight cut exists)

WHAT. Sometimes no straight line separates the colours — a red dot sits deep in black territory or vice-versa. Then the best line still makes mistakes.

WHY show this? The parent said "low accuracy means the info is absent or requires complex nonlinear extraction." This is the picture of that sentence. When points overlap, a straight cut cannot score no matter how you place it. Two very different situations produce this:

  1. Absent: the layer genuinely didn't encode — reds and blacks are fully mixed, like salt and pepper.
  2. Nonlinearly encoded: the reds sit in a ring around the blacks. A straight cut fails, yet a curved boundary (an MLP probe, Disentangled Representations) would succeed. The info is present but entangled.

PICTURE. Left half: salt-and-pepper mix — even the best straight cut misclassifies ~half. Right half: a red ring around a black core — no line works, but the accent dashed curve does. This is exactly why Worked Example 2 saw MLP linear.

Figure — Probing classifiers

Step 7 — Edge case B: a degenerate cut (all one colour, or )

WHAT. Two degeneracies to name so you're never surprised:

  1. One colour only. If every point in is red, a probe that always says "red" scores — but has learned nothing. This is class imbalance, and accuracy alone lies.
  2. The zero cut, . Then for every point — the score ignores entirely. The "cut" collapses; there's no direction, so the probe just outputs the majority class.

WHY. Both are traps that inflate accuracy without any real encoding. The fix for (1) is a majority-class baseline: only accuracy above the baseline counts. Case (2) is what the L2 regularizer from Step 4 can accidentally cause: recall its gradient pulls toward . Here is a hyperparameter (a knob we choose before training). A little is healthy — it stops the probe memorising noise. But too much crushes toward , collapsing the cut and measuring nothing. So must be tuned, not maxed out.

PICTURE. Left: all-red cloud with a "trivial 100%" flag. Right: , the accent shows a collapsed cut that every point sits on the same side of — no separation possible.

Figure — Probing classifiers

Step 8 — Putting numbers on it: reproducing the layer trend

WHAT. The parent reported BERT POS-probe accuracy climbing then dipping across three depths: at layer (raw word embeddings), at the middle layer , and at the final layer . Read off the picture, this is the margin widening into the middle layers, then shrinking slightly at the output.

WHY the shape? Early layers () only know word identity — reds and blacks partly overlap (margin small, so ). Middle layers () add context that spreads the colours apart (margin widest, , the peak). The output layer () re-tangles things to serve the training objective, so the gap closes a touch (). The trend is non-monotone: it rises from to , then dips to — the peak is in the middle, not at the end.

PICTURE. Accuracy vs. layer , with the accent peak at the middle layer . Below each dot, a mini-cloud shows the margin: narrow → wide → narrow, mirroring the accuracy numbers.

Figure — Probing classifiers

The one-picture summary

Everything above collapses into a single flow: input → representation (a point) → colour it by the property → find the widest straight cut → threshold the sigmoid into a class → the margin measures how confidently the property is encoded and how high held-out climbs → if no cut works, it's either absent or curved (entangled).

Figure — Probing classifiers

gamma large

gamma tiny or cut fails

MLP probe wins

input x

representation h in R^d

colour points by property y

fit straight cut w and b

measure margin gamma

high held-out accuracy

absent or entangled

present but nonlinear

Recall Feynman retelling — say it back in plain words

A network is a stack of stages called layers, numbered ; each stage turns the sentence it reads into a dot in a big invisible room — that dot is just the list of numbers the stage scribbled down. To ask "did layer learn about, say, subject–verb agreement (my property )?", I paint every agree dot red (label ) and every disagree dot black (label ). Then I try to slide a single straight ruler between the colours. If one clean slice keeps all reds on one side and all blacks on the other, the network organised the property — it's linearly in there. The dot product is just each dot's shadow onto the "red-ward" arrow, telling me which side and how far. I squash that distance through the smooth S-curve to get a confidence, then I threshold at (same as reading the sign) to get a hard red/black guess — and the fraction of held-out dots I guess right is the accuracy . I actually find the ruler by minimising a cross-entropy loss (smooth, so gradient descent has a slope to chase) with a little penalty that gently shrinks the ruler's arrow toward zero. The margin is the empty tube around the ruler — a wide tube means fresh test dots can wander a lot and still land on the right side, so accuracy stays high; a paper-thin tube means a whisker of noise flips them. If the colours are salt-and-pepper mixed, either the network never learned it, or — the sneaky case — the reds form a ring around the blacks, so no straight ruler works but a curved one does; then the info is there but tangled up. If all my dots are one colour, a lazy "always red" ruler scores 100% while knowing nothing — so I only trust a probe that beats the majority-guess baseline. Layer by layer the margin (and so ) rises into the middle then dips at the end.

Recall Checklist of every case we covered

Separable, wide margin ::: explicit linear encoding — high linear accuracy Separable, thin margin ::: barely-there encoding, test points flip, near baseline Overlapping (salt & pepper) ::: information absent Overlapping but curved-separable (ring) ::: present but entangled — MLP beats linear All one colour ::: trivial 100%, must check majority baseline (over-regularised, big ) ::: cut collapses, measures nothing Many labels ::: one-vs-rest hyperplanes or softmax over classes