Sam Babichenko

Reading notes / Superposition

Toy Models of Superposition

Elhage et al., 2022

Context. Many neurons in trained networks are polysemantic, firing for unrelated things, and the leading explanation was the superposition hypothesis: a network represents more features than it has dimensions by giving each feature its own direction and tolerating interference between directions that are not orthogonal. It rested on analogies, and nobody had shown gradient descent doing it. The paper trains tiny autoencoders on synthetic sparse features and maps when superposition appears, its geometry, and when neurons become polysemantic. Behind a ReLU, interference costs something only when two features are active together, which happens with probability about p2p^2 for features active with probability pp, while leaving a feature out costs its contribution every time it is active, and a negative bias filters the small interference that remains. A linear readout incurs interference on every input where another feature is active, so it never superposes and keeps the mm most important features, an importance-weighted PCA.

Setting. Features x∈Rnx\in\mathbb R^n have independent coordinates, xi=0x_i=0 with probability SS (the sparsity; 1−S1-S is the density) and xi∼U[0,1]x_i\sim U[0,1] otherwise, with importances IiI_i. The hidden layer h=Wx∈Rmh=Wx\in\mathbb R^m, m<nm\lt n, is decoded with the same matrix, and the two basic models differ only in the readout: x′=W⊤Wx+b  (linear),x′=ReLU(W⊤Wx+b)  (ReLU output),L=E∑iIi(xi−xi′)2.x'=W^\top Wx+b\ \ \text{(linear)},\qquad x'=\mathrm{ReLU}(W^\top Wx+b)\ \ \text{(ReLU output)},\qquad L=\mathbb E\sum_iI_i(x_i-x'_i)^2. Column WiW_i is feature ii's direction, of norm near 1 if the feature is represented and near 0 if not, and the feature dimensionality Di=∥Wi∥2∑j(W^i⋅Wj)2D_i=\frac{\|W_i\|^2}{\sum_j(\hat W_i\cdot W_j)^2} is 1 for a dedicated dimension, 1/21/2 for an antipodal pair (Wj=−WiW_j=-W_i) and 0 for a dropped feature, while D∗=m/∥W∥F2D^*=m/\|W\|_F^2 counts dimensions per represented feature overall. Superposition means more represented features than dimensions. All findings are empirical, apart from closed-form losses of a few candidate configurations.

Main findings. The linear model learns the mm most important features as an orthogonal basis at every sparsity. The ReLU output model does the same on dense data, but as features get sparser it represents more of them in superposition, least important first. Whether a feature is dropped, superposed or given its own dimension changes abruptly with sparsity and relative importance, identical features settle into uniform polytopes, and with a ReLU on the hidden layer neurons turn polysemantic as sparsity increases and can compute in superposition.

Step 1

A ReLU readout superposes sparse features and a linear readout does not. With n=20n=20, m=5m=5 and Ii=0.7iI_i=0.7^i, the linear model always learns the top five features, as PCA would. The ReLU output model matches it at density 1, but already at density 0.3, and more so below, it represents extra features through non-orthogonal directions, least important first and in antipodal pairs. Since the two models share architecture, data and loss, superposition needs the output nonlinearity together with sparsity; sparsity alone does nothing for a linear readout.

Step 2

The loss is feature benefit against interference, and sparsity makes interference rare. For the linear model with Gaussian inputs (as in Saxe et al. on deep linear networks) the loss is, up to constants, ∑iIi(1−∥Wi∥2)2+∑i≠jIj(Wj⋅Wi)2\sum_iI_i(1-\|W_i\|^2)^2+\sum_{i\ne j}I_j(W_j\cdot W_i)^2: a benefit for each represented feature and a penalty for every overlap, so representing more than mm features never lowers the loss. For the ReLU model, split the expectation by which features are active; as S→1S\to1 inputs with one active feature dominate (the all-zero input only penalizes positive biases), with loss L1=∑i∫01Ii(xi−ReLU(∥Wi∥2xi+bi))2dxi+∑i≠j∫01Ij ReLU((Wj⋅Wi) xi+bj)2dxi.L_1=\sum_i\int_0^1I_i\big(x_i-\mathrm{ReLU}(\|W_i\|^2x_i+b_i)\big)^2dx_i+\sum_{i\ne j}\int_0^1I_j\,\mathrm{ReLU}\big((W_j\cdot W_i)\,x_i+b_j\big)^2dx_i. The ReLU makes negative interference cost nothing, a negative bias turns small positive interference negative, and with unit norms, zero bias and equal importances the interference term is a Thomson-type energy for points on a sphere. The smallest case shows the orders of magnitude (my computation, not in the paper; Monte Carlo agrees). With n=2n=2, m=1m=1, b=0b=0, density pp and importance rr for the second feature, compare dropping that feature with the antipodal pair W=[1,−1]W=[1,-1], which is exact when one feature is active and loses the smaller one from both outputs when both are: Ldrop=rp3,Lantipodal=(1+r) p2 Emin⁡(U,V)2=(1+r)p26,L_{\rm drop}=\frac{rp}3,\qquad L_{\rm antipodal}=(1+r)\,p^2\,\mathbb E\min(U,V)^2=\frac{(1+r)p^2}6, so the pair wins exactly when p<2r/(1+r)p\lt2r/(1+r). Through a linear readout it costs (1+r)p/3(1+r)p/3, or (1+r)(p/3−p2/4)(1+r)(p/3-p^2/4) with the best bias, against r(p/3−p2/4)r(p/3-p^2/4) for dropping, so it loses at every density.

Step 3

The choice between dropping, superposing and dedicating a dimension changes abruptly. The optimal loss is the minimum of a few smooth curves, one per candidate configuration, so where two cross its derivative jumps, a first-order transition. For two features in one dimension, across importance and density, the trained diagram has three regions with sharp borders (extra feature dropped, antipodal pair, extra feature given the dimension) and matches the one built from the closed-form losses of W=[1,0]W=[1,0], [0,1][0,1], [1,−1][1,-1]. "Phase change" here means a jump in the optimum of a finite system, with no large-system limit. The candidate list is not complete: an external replication solved the bias-free two-feature case exactly and found a further phase with similar weights, and regions where the optimum moves continuously.

Step 4

Identical features settle into uniform polytopes, and unequal ones deform them. With n=400n=400 identical features in m=30m=30 dimensions, D∗D^* stays at 1 and at 1/21/2 over wide ranges of sparsity, and the individual DiD_i cluster at 3/43/4 (tetrahedron), 2/32/3 (triangle), 1/21/2 (antipodal pair), 2/52/5 (pentagon), 3/83/8 (square antiprism) and 0. Each value is m/nm/n for nn points in mm dimensions, and the reason is a tight frame (my gloss; the paper reads the shapes as Thomson-problem solutions): the denominator of DiD_i is W^i⊤WW⊤W^i\hat W_i^\top WW^\top\hat W_i, so for points of equal norm Di=m/nD_i=m/n at every vertex exactly when WW⊤=(n/m)ImWW^\top=(n/m)I_m. Polytopes whose vertices differ appear split into smaller polytopes in orthogonal subspaces, with no interference across factors. Unequal features deform the shapes. Five features in two dimensions form a regular pentagon; making one denser pushes the others away from it, and making it sparser lets them move closer to it until the pentagon changes abruptly into two antipodal pairs with that feature dropped. Correlated features prefer orthogonal directions, and with too little room collapse onto their sum (a+b)/2(a+b)/\sqrt2, as PCA would; anticorrelated features prefer to be antipodal.

Step 5

With a ReLU on the hidden layer, neurons become polysemantic and can still compute. In h=ReLU(Wx)h=\mathrm{ReLU}(Wx), x′=ReLU(W⊤h+b)x'=\mathrm{ReLU}(W^\top h+b), neurons are monosemantic on dense data and turn polysemantic as sparsity grows, and both kinds coexist in one model. This is a weak test, since the model gains nothing from the hidden ReLU and avoids using it when it can, say with positive biases that make every neuron linear. Computing ∣x∣|x| requires the hidden ReLU: in h=ReLU(W1x)h=\mathrm{ReLU}(W_1x), y′=ReLU(W2h+b)y'=\mathrm{ReLU}(W_2h+b) with active inputs uniform on [−1,1][-1,1], the target ∣x∣=ReLU(x)+ReLU(−x)|x|=\mathrm{ReLU}(x)+\mathrm{ReLU}(-x) needs two neurons per feature, and with n=3n=3, m=6m=6 the model learns exactly that. With n=100n=100, m=40m=40 it is monosemantic on dense data and on sparse data computes ∣x∣|x| for more features than it has neurons, so superposition supports computation as well as storage. Many neurons carry one primary feature with a large weight and a few secondary ones with small weights, so their strongest activations look clean and their weaker ones mixed, as in language-model neurons.

Step 6

Superposition predicts vulnerability to adversarial inputs, and feature dimensionalities change in jumps during training. In superposition a feature's end-to-end weights look like (W⊤W)i=(1,ϵ,−ϵ,…)(W^\top W)_i=(1,\epsilon,-\epsilon,\ldots), and the off-diagonal entries give an attacker a direction that moves feature ii's output without activating it. With the optimal L2L_2 attack in closed form, vulnerability rises more than threefold as superposition forms and tracks features per dimension, 1/D1/D. During ordinary training, feature dimensionalities jump between the polytope values, each jump with a small drop in the loss. Both observations are correlational and confined to the toy model.

Consequences and limits. Polysemanticity becomes a predicted outcome: whether a feature is superposed depends on its importance and sparsity, so superposition should be heavy where many sparse distinctions share few dimensions. An appendix bounds how much. If the decoder returns every kk-sparse input to small error and WW has the restricted isometry property, a deterministic compressed-sensing lower bound gives m=Ω(klog⁡(n/k))m=\Omega(k\log(n/k)), and with k≈(1−S)nk\approx(1-S)n this reads m=Ω(−n(1−S)log⁡(1−S))m=\Omega(-n(1-S)\log(1-S)): linearly many features in mm, with a factor that grows as features get sparser. Interpreting a model then requires enumerating its features, either by training without superposition or by finding an overcomplete basis afterward with sparse coding, the route of Bricken et al. The authors name the limits (synthetic, independent, uniform features and a reconstruction task) and expect superposition and the mix of monosemantic and polysemantic neurons to carry over, the polytopes much less. The decoder is also far weaker than compressed sensing allows: one matrix and a ReLU in place of an ℓ1\ell_1 program.

Terms

Sparsity SS
probability a feature is zero; density 1−S1-S
Importance IiI_i
weight of feature ii in the squared-error loss
ReLU output model
x′=ReLU(W⊤Wx+b)x'=\mathrm{ReLU}(W^\top Wx+b); superposes sparse features, the linear readout never does
Feature dimensionality DiD_i
∥Wi∥2/∑j(W^i⋅Wj)2\|W_i\|^2/\sum_j(\hat W_i\cdot W_j)^2: 1 dedicated, 1/2 antipodal, 0 dropped
D∗=m/∥W∥F2D^*=m/\|W\|_F^2
dimensions per represented feature; stays at 1 and 1/2 over wide ranges
Antipodal pair
Wj=−WiW_j=-W_i: exact when one is active, loses the smaller when both are
Uniform polytope
equal features as a tight frame, Di=m/nD_i=m/n: triangle 2/3, pentagon 2/5
Tegum product
polytopes in orthogonal subspaces; no interference across factors
Privileged basis
coordinates made special by a nonlinearity, so neurons can align with features
Asymmetric superposition
write [2,−12][2,-\tfrac12], read [12,2][\tfrac12,2], plus an inhibitory neuron
Superposition capacity bound
with RIP, m=Ω(klog⁡(n/k))m=\Omega(k\log(n/k)), k≈(1−S)nk\approx(1-S)n

Quiz

  1. In the ReLU output model on inputs with one active feature, why is negative interference free?
  2. Why does the linear model never represent more features than dimensions?
  3. Two correlated features compete for room that fits only one. Why does the model represent (a+b)/2(a+b)/\sqrt2?
  4. The appendix bound gives m=Ω(−n(1−S)log⁡(1−S))m=\Omega(-n(1-S)\log(1-S)). Why does it allow only linearly many features in mm, not exponentially many?

Sources