6.3.8 · D1Interpretability & Explainability

Foundations — Sparse autoencoders for features

2,231 words10 min readBack to topic

This page assumes you have seen nothing. Every letter, arrow, and squiggle that appears in the parent note is built here from the ground up, in the order you need them.


0. The picture we are always describing

Before any symbol: the whole topic is one flow of arrows.

Something goes in (a list of numbers). A first machine turns it into a wider list of numbers where most entries are zero. A second machine tries to rebuild the original from that wide-but-mostly-zero list. If it can rebuild well and stay mostly-zero, the wide list must be capturing the real "parts" the input is made of. Keep this three-box picture in your head; every symbol below labels one arrow or box in it.


1. A vector — a list of numbers with a place to live

The picture. A vector is an arrow, or equivalently a point, in a space with one axis per slot. Two numbers → a point on a flat sheet. Three numbers → a point in a room. Sixty-four numbers → a point in a space we can't draw but reason about identically.

Why the topic needs it. The input to the autoencoder — an image patch, a word embedding — is exactly such a list. In the parent note means " is a list of 64 numbers." We must have the concept of "list of numbers as a point" before anything else can act on it.

Reveal check:

contains what?
Every possible list of three real numbers — i.e. every point in 3-D space.

2. Dimension and — how long the lists are

The picture. Input lives in a space of axes; the hidden representation lives in a roomier space of axes. More axes = more distinct "detectors" available.

Why the topic needs it. A normal autoencoder squeezes () to save space. A sparse autoencoder does the opposite: it wants a big shelf of specialist detectors and just uses a few. That "big shelf, few used" combination is the whole trick, and it needs .


3. Weights and biases — the tunable knobs

Why matrix multiply, not something fancier? Because a weighted sum is the simplest tunable way to let every input number influence every output number. Training just nudges the grid entries until useful mixtures emerge. The subscripts distinguish the two machines: = encoder knobs, = decoder knobs.

Reveal check:

If is and has 64 numbers, how long is ?
256 numbers.

4. The activation function / / ReLU — the "should I fire?" gate

Two you must know:

Why these two, and why here? ReLU's flat-zero left half means many neurons output literal zero — that is free sparsity, no penalty needed. Sigmoid's range lets us read an output as "fraction of the time this fires," which is exactly what the KL sparsity target compares against (Section 8). The parent uses sigmoid for image patches and ReLU for embeddings — now you know why.


5. Encoder and decoder — the two labelled machines

  • = the hidden / feature list ( numbers).
  • (x with a hat) = the reconstruction, the decoder's best guess at the original . A hat always means "estimate / rebuilt version," never the true thing.

Why a decoder at all? Without it, nothing forces to mean anything. The decoder is the honesty test: if features can rebuild the input, they captured its real content. This is the same idea underlying 5.2.03-Variational-autoencoders, minus the probability machinery.

Reveal check:

What does the hat in signal?
A reconstructed / estimated version, not the original.

6. Norms — measuring "how big" and "how many"

Norms are ways to squeeze a whole vector into a single "size" number. Three matter here.

Why three? is the honest goal ("keep few awake") but it is a step-count — flat everywhere, so gradient descent gets no slope to follow. is the closest smooth-enough stand-in whose "corner at zero" still pushes small values to exactly zero (see 4.1.07-L1-L2-regularization). only shrinks — never zeroes — which is precisely Mistake #1 in the parent note.


7. Sums , index , batch — averaging over data

Why average over ? One example might be a fluke. Sparsity is a habit — "on average, is this neuron mostly quiet?" — so we measure it across a batch, not one input.


8. Sparsity target and rate — the quota system

The picture. Imagine each neuron has a quota card: "you may light up 5% of the time." is the printed quota; is the neuron's actual attendance record. The penalty punishes any gap.

Why KL and not just subtract? Plain would treat over- and under-firing equally. KL leans against over-firing, which matches the goal "keep most neurons quiet." That's why the parent uses it for the probability-flavoured sigmoid case.

Reveal check:

When is the KL sparsity penalty exactly zero?
When the measured rate equals the target .

9. The greek control knobs and

The picture. Sliders on a mixing desk. Slide up → more silence pressure. But turn it too far and the representation starves (parent's Mistake #2). These are the trade-off dials of the whole loss.


10. Putting the symbols back together

Now every piece of the parent's headline loss is readable:

You can now name (the total badness score to minimise), each , each norm, , , , , the hats, and the subscripts. That is the entire vocabulary of the topic.


Prerequisite map

Vectors and R^n

Weights W and bias b

Norms L0 L1 L2

Encoder h = f of Wx plus b

Activation sigmoid or ReLU

Hidden features h

Decoder rebuilds x-hat

Reconstruction loss

Sparsity penalty L1

Firing rate rho-hat vs target rho

KL sparsity penalty

Total SAE loss

Knobs lambda and alpha

Interpretable features

This feeds forward into 6.3.02-Attribution-methods, 6.3.05-Concept-activation-vectors, and the 6.3.11-Superposition-hypothesis, which explains why overcomplete sparse dictionaries are needed at all.


Equipment checklist

Test yourself — you should be able to answer each before reading the main topic.

I can say what means in words and as a picture
is a point/arrow in -axis space, one axis per number in the list.
I can explain why (overcomplete) is on purpose
More detector-slots than inputs, so a few specialists can describe anything — sparsity, not compression, is the win.
I can describe what does
Mixes every input number into every output number (matrix), then shifts each by a baseline (bias).
I can distinguish sigmoid from ReLU and why each is chosen
Sigmoid squashes to (probability-like, pairs with KL); ReLU zeroes negatives (free literal sparsity).
I can say what the hat means in and
"Estimated / measured" — the rebuilt input, and the observed firing rate.
I know the difference between , ,
counts non-zeros (true goal), sums magnitudes and drives values to exact zero (trainable stand-in), only shrinks.
I can read every term of
Rebuild fidelity () + stay-quiet quota (KL/, scaled by ) + anti-cheat weight decay (, scaled by ).
I can say what vs represent
= target firing fraction you set; = neuron 's actual average firing over the batch.