# Finding Sparse Linear Connections between Features in LLMs

TL;DR: We use SGD to find sparse connections between features; additionally a large fraction of features between the residual stream & MLP can be modeled as linearly computed despite the non-linearity in the MLP. See [linear feature section](https://www.lesswrong.com/editPost?postId=7fxusXdkMNmAhkAfc&key=e013388fad8122af1003041ca4ae7f#Sparse_Linear_Feature_Connections) for examples.

*Special thanks to fellow AISST member, Adam Kaufman, who originally thought of the idea of learning sparse connections between features & to Jannik Brinkmann for training these SAE’s.*

Sparse AutoEncoders (SAE)’s are able to turn the activations of an LLM into interpretable features. To define circuits, we would like to find how these features connect to each other. SAE’s allowed us to scalably find interpretable features using SGD, so why not use SGD to find the connections too?

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/809228e3c17babad5c4a0bfc46492666ca1cf009b9edbf70.png)

A layer in Pythia-70M, with SAE's before & after the MLP. Note, this is different than the typical Transformer Architecture, Pythia models have parallel MLP & Attn modules as opposed to sequential (this was to copy SOTA models which parallelized for more GPU utilization AFAIK)

We have a set of features before the MLP, F1, and a set of features after the MLP, F2.  These features were learned by training SAE’s on the activations at these layers. 

Ideally, we learn a linear function such that F2 = W(F1), & W is sparse (ie L1 penalty on weights of W). So then we can look at a feature in F2, and say "Oh, it's just a sparse linear combination of features of F1 e.g. 0.8*(however feature) + 0.6*(but feature)", which would be quite interpretable! 

However, we’re trying to replicate an MLP’s computation, which surely can’t be all linear![^pwepir8kf3] So, what’s the simplest computation from F1 to F2 that gets the lowest loss (ignoring L1 weight sparsity penalty for now)? 

Training on only MSE between F1 & F2, we plot the MSE throughout training across 5 layers in Pythia-70m-deduped in 4 settings:

Linear: $y= Wx$

Nonlinear: $y= Relu(Wx)$

MLP: $y= W_2 ReLU(W_1x)$

Two Nonlinear: $ReLU(W_2ReLU(W_1x))$

  
![](https://lh7-us.googleusercontent.com/OMegaT-6E3CqgLIRWVTXZN42PDeSNDvgbPgAzmntO0Lk613NWxjvR5hRrbdwNFa6GkftazAtwG-laqFEC5Ww1wAVtw8aI39O0548uADQyhq3S3iv5xl2Vn4yR2NNH19A0_fRBVdUX35Lugx8bgetOCk)

  
For all layers, training loss clusters along (MLP & two nonlinear) and (linear & nonlinear). Since MLP & linear are the simplest of these two clusters, the rest of the analysis will only look at those two. 

\[I also looked at bias vs no-bias: adding a bias didn’t positively improve loss, so it was excluded\]

Interestingly enough, the relative linear-MLP difference is huge in the last layer (and layer 2). The last layer is also much larger loss in general, though the L2 norm of the MLP activations in layer 5 are 52 compared to 13 in layer 4. This is a 4x increase, which would be a 16x increase in MSE loss. The losses for the last datapoints are 0.059 & 0.0038, which are ~16x different. 

What percentage of Features are Linear? 
----------------------------------------

Clearly the MLP is better, but that’s on average. What if a percentage of features can be modeled as linearly computed? So we take the difference in loss for features (ie for a feature, we take linear loss - MLP loss), normalize all losses by their respective L2-norm/layer, and plot them.

![](https://lh7-us.googleusercontent.com/KpwSG64DgAUQ1zUe0BvjNnN3Y-5BvDR7HxbpSmRrm6azyuiqYR5EM7HFsusmD4jyAD02q4fcH1PGMJrrmzLyn5geve9v4x32gUuRnu71GKJVddyx7aOrURBvd6WeTJ2yqTigxUqtVPuBRBIPACQKWqY)  
Uhhh… there are some huge outliers here, meaning these specific features are very non-linear. Just setting a threshold of 0.001 for all layers:

![](https://lh7-us.googleusercontent.com/MGSSTVKAH9R7466qojNO4laeqtBqSUCjiKvaQrgQHmBA6H8D84yelyC_977SEbIJZNwEDu4UKJUjBAr5MIYk75-eVauou2JpKWaGMEM1JGligPkriVjVl9-7syI0kVF3aX-GZcSw8SyxYxZ3D06L0Dw)  
  
 

| Layer | Percent of features < 0.001 loss-difference (ie can be represented linearly) |
| --- | --- |
| 1   | 78% |
| 2   | 96% |
| 3   | 97% |
| 4   | 98% |
| 5   | 99.1% |

Most of the features can be linearly modeled w/ a small difference in loss (some have a negative loss-diff, meaning linear had a \*lower\* loss than the MLP. The values are so small that I’d chalk that up to noise). That’s very convenient!

\[Note: 0.001 is sort of arbitrary. To make this more principled, we could plot the effect of adding varying levels of noise to a layer of an LLM’s activation, then pick a threshold that has a negligible drop in cross entropy loss?

Adding in Sparsity 
===================

Now, let’s train sparse MLP & sparse linear connections. Additionally, we can restrict the linear one to only features that are well-modeled as linear (same w/ the MLP). We’ll use the loss of:

Loss = MSE(F2 - F2\_hat) + l1\_alpha*L1(weights)

But how do we select l1\_alpha? Let’s just plot the pareto frontier of MSE loss vs l1 loss for a range of l1\_alphas:

![](https://lh7-us.googleusercontent.com/H5-w10_jpwv-QV5Tu66rNSrqWTw_gCXMlJZcjRwtFRhxH0U3jqUUI6WAltjFzpbY-wElxXkNoSTYBwNNnDlSZIdNNpCSwQzMrIAb4DUJddNWZe0_cxK1FEdsQkxpM3DFlXWJE-rnVFAciKnIO8jrGvI)

This was for l1\_alphas = \[1e-7, 1e-5, 1e-3, .1, 10, 100\], with the elbow of both lines for l1\_alpha=1e-3. It’s slightly higher MSE than I’d want, so I’m going to set it to 8e-4 for future runs. (A lower l1-penalty leads to higher l1 loss & lower MSE).

Sparse Linear Feature Connections
=================================

Restricting ourselves to just linear features, we retrained a sparse linear weight connection w/ l1_alpha=8e-4. 

Below we show some examples of sparse linear feature connections. For the curious reader, additional examples can be found [here](https://comet-scorpio-0b3.notion.site/More-Examples-ceaefc95cc924afba318dca1da37d4a4?pvs=4).

OR Example
----------

In Layer 1, we have:

$OF_{30} = 0.26IF_{2797} + 0.23IF_{259} + 0.10IF_{946}$

where OF is output feature (in MLP_out), and IF is input feature (in Residual Stream before the MLP)

Below is input feature 2797, activating strongly on the token “former”   
 

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/437c524befb14d03356ee1ad39e7889fbcacfe793e1ce23b.png)

This is 5 examples. For each ex, the top row of words are feature activation e.g. token " former" activated 9.4. Bottom blank row is: if we removed this feature, how much worse does the model get at predicting these tokens? e.g. Soviet is 5.5 logits worse when the model can't use this "former" feature.

Below is input feature 259, activating strongly on the token “old”![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/206f9bd6aa7c57139aeeec59888629b6522af1858fd89788.png)

Below is input feature 946, activating on the token “young”![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/8c0d1ea920aec0ecb4d07d0099c5b0ae1db4260b8d1c7aea.png)

In the output feature, we see the tokens former, old, and young all activate, with young activating about half as strongly as “former” and “old” as we would expect from the weight coefficients.

$OF_{30} = 0.26F_{former} + 0.23F_{old} + 0.10F_{young}$

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/03d100a407a8954b4d096fb41357652303368a09407fb25d.png)

We can view this computation as a weighted logical OR. Output Feature 30 activates on former OR old OR young (again, more examples are [here](https://comet-scorpio-0b3.notion.site/More-Examples-ceaefc95cc924afba318dca1da37d4a4))

Negative Weight Example
-----------------------

In Layer 1, we have:

$OF_{505} = 0.68IF_{3021} -0.21IF_{729}$

where OF is output feature, and IF is input feature.

Below is input feature 3021, activating strongly on tokens like “said” which in almost all cases appear not after a quote.![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/c618d76cf56c4a3007be9994e38cae117084b8c2dc9719c8.png)

Below is input feature 729, activating strongly on tokens like “said” when they appear shortly after a quote.![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/bf9af40d71d2aca89c1d928c9b8ee17cefeb09ff6aebc472.png)

Below shows how the activation for input feature 729 changes when we remove a certain context token. Critically, the activation goes does when the quote is removed, demonstrating that this feature activates when there is a quote, followed by “said”.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/276a10060fd31afec3fcbc32d876af460546923eedc31bb3.png)

This image typically confuses people. High level take away: anything that is red is important contextual tokens for this feature to activate (the blue isn't as important because it only adds up to 0.5 when removed, as opposed to -5.1). We're trying to communicate that removing the quotes makes the feature activation of the word " says" goes down by -5.1 to 0 feature activation.

Below we see the output feature activates on tokens like “said” that have no prior quote tokens. We’ve “subtracted out” with a large negative weight, so to speak, the examples where “said” appears after a quote, and now the feature only activates when “said” appears without any prior quotes.

$OF_{505} = 0.68F_{(\text{"said" in many contexts})} -0.21F_{(\text{"said" after quotes})}$![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/58400b90b88f4c9893274f4bf54be18a15c9c50576b0c82e.png)

We can view this computation as a weighted logical AND. Output Feature 505 activates on A AND ~B. In the case where A is a superset of B, this is the complement of B e.g. I have the set of all fruits and all yellow fruits, so now I can find all non-yellow fruits.

 (again again, more examples are [here](https://comet-scorpio-0b3.notion.site/More-Examples-ceaefc95cc924afba318dca1da37d4a4))

Sparse MLP Feature Connections
==============================

Let’s visualize these MLP features that have the worse losses:

Layer 5: Looking at the features w/ the largest loss-diffs between linear & MLP

(specifically \[1.5555, 0.0116, 0.0052, 0.0040, 0.0038\]) 

All 5 features are very high activations. The first one is generally weird (compared to your typical outlier dimension), and the next 4 are mostly weird tokens.   
 

![](https://lh7-us.googleusercontent.com/bZjTGLUlaF36S2RcqdfnLmzSLRawguNpY-ejb6ccYrn4lFKU1qBLnvmW2h6fYl_SAJpuwmep6bRI4SASwm6_4HAvvc9EUzKpr5txsxtyhcLniLVgcQdzIqEZuY4Y67IFRZTnyPp8vG8XfOD8CJC6w8Y)

![](https://lh7-us.googleusercontent.com/nCP7d2xl2k2fhUPnNgaH5OK31cz90vfuipomx92uy4F8dwjDG4Ouo_JmrvBpRQm2_n74_An3ojoaLfjoT1DlkDhIo9U0rQT9pB5JQEnh75YqeY-R82lHNaW4rdrK_VqsBZVnpIkcGBhlcExZ-_10_3g)

![](https://lh7-us.googleusercontent.com/fqY7Gz-Pkl9Try7yqqfnqqxEm4r-uxEcZA-MrUuFfL-nHiHZPXDk_EJ1KwEDGwPaT_yuwqrFM7tUBaijW_LleVHvhmBfEwMmkXsGUe7sjcIAHKq_FS4T1VxtFppGJPewHigjO4ygyQbwBg7Od7A-0lA)

![](https://lh7-us.googleusercontent.com/NIqlUxohM4fRXpgf6yV9c8G_5j5xSccB_-HE16GnTVHspnetk9wKV4tIKmY8uLy_USoMhHOETPfxXBZ9G-3yfgRLlQZYsMylf-2e7ppR-YPoSJQoJRgfr9BVgeqC_wvxcequoX-jglUaEPgQLpGSVMQ)

![](https://lh7-us.googleusercontent.com/yQf4KYLFD9zQRnVlQah0qEcS7EnYLyTk5SdZYxMrhlk3lwY1VL0us3y1KqYLnx0z5KrzteTToa6wFy8e7bZD7Fd_6btZcHGXh7km_k6v9E3uYNq2B1oVx-ZiD7LDDFKGPM0_w5QN-DylZDMGW_diNvc)

(As a general note: the last layer of LLMs are typically very weird! This also came up for the tuned lens paper, and was hypothesized by nostalgebraist to be an extended unembedding matrix)

Layer 4: loss-diffs \[0.0529, 0.0134, 0.0106, 0.0106, 0.0099\]

First & third are outlier features. What is typical for outlier features (from my experience) are: 

1) Very high activation (this explains the high L2 loss)

2) Activates on first couple of tokens

3) Activates on first delimiter (e.g. period or newline, which I represent as “\\n”)

(Why do these exist? Idk, literature & theories exist, but out of scope for this post)

![](https://lh7-us.googleusercontent.com/cd35yyVHkqWXIZcADGLnlxYt0yxenqP7SZx_B-R2jmqtPH5GTCJGhlWNcGqcDJt90lR02MtTPF9mRCkDTzBVpLH031GsfohllMxBq2kkmJjw1kZ9FC6j-1JIOfy0SQTvswaxI9YvcoTenuQ3DfYabKE)

![](https://lh7-us.googleusercontent.com/SQVWHQ_iNUmXbShbGzjTHSSsX5mjk_Uka2-PesuAgjsD4dyd_BNMT2MjSTCdXou_LbbI9IzB9u9kvvI5uWUrXY-2imX0hlook4ODTXAchLGWuWrj_Pno5NzB6QbzDU-T_GbcqK0ttlUlyCQSBQkh4co)

![](https://lh7-us.googleusercontent.com/hK4yIvD7a18av6RtmfEUwufhl3oeuTLWk6ERngi8tSwyoDGAFIzoPdwskAss3NhZf0ohRkzJ3fF3Adho0vJhzE8ePvF526EAFMoAXvMSE95GvVjPONa2JMzyysOgj59sSlxKsljr3gtXF7xeynRHpms)

![](https://lh7-us.googleusercontent.com/F8fqk5IOQkNeAwyulvt4mHSuH0s4pBnRRYvdjsH3f-xQAm_-VezGgQ1BwRfHalLbuFVhc4ZybOnCbj4STkVukFokbj26qIARxxHSDjRCrhQcdRUQRwrFaNi_Jothh7Gtwip8Hth_6mVJTokCpu7NOnk)

![](https://lh7-us.googleusercontent.com/wZJV-PRuKOGXYfhaOxS0Dkkfyce7A7aWmIER_48o9zmyQI8OszALMUhnUMCLGOwrM-iITSaFFR8XJ9GZdEUL_IIvsEbem3lRowcXOQsZ9KYa-AZxyPjX9Z0iAzQlElBF_Q1XfVAst-9Qn3BfFczpPaY)

Layer 3: loss-diffs \[0.0456, 0.0163, 0.0122, 0.0101, 0.0069\]

First & 5th are outlier features

![](https://lh7-us.googleusercontent.com/SAhtw7KIlN-WM2wHnm7utLmVw9rlbKqHaoXNydUPVIhtDcD-bln109nZQW-6Qu_jqYyY4V7BemXRdRrZGp7UPSR5nsT2YXvllwabxt6zLQ-_7_eHz2oYlQbKOoHm-V-jtoEugKRyES-mgEQeaiqdWss)

![](https://lh7-us.googleusercontent.com/EfL1URd8vA09X1wp4tm1ijsyAWKJQrrgCa3rWHMXf9R1j0nJrunC1axL5YG1WJujAZTl0oh6B2ortFkhIU8fme1Krm862vN76fKcIPY2YZJ7Ek1PXEhweKdcQhSmEho_UbAwQC_ZvQiyKU4iwySQNJw)

![](https://lh7-us.googleusercontent.com/ON1Omxa5w9Oh2U7u7xyzyD60oZbSogX-re-PiUMg-2dY11OTlsW5B0lBjzQYAGjjnt_SCMylxKWIl74gxZNhe2lWVOO_fH4vRJ1CCsZl1Zqy0ZM8w22KZbsozusqEX259b3_sbzRbDp-o0iGbKnSlpQ)

![](https://lh7-us.googleusercontent.com/1JOb-PkkwFjyuN59YfZ9m2lIvoyYzlFd215SoDHfym5nNI2etQ_FEbWggGSvVgfAV6l1_9oAdX4MMDuW5aar_gUP72-Jwq1GOn1xcphZNEjHLoDjVByTKhWjqM_LYyiEc4V3UwXTX4xJ18rKws9LsUQ)

![](https://lh7-us.googleusercontent.com/hAvRt2dAYjs_fPVH9CMD3sWYqEkIfrqU8NQCQsnLRT8sAMaRKE6fNxsBNI6bpkRjkxEiG4xKaqfYOVQb5PzTkkPKQ__h3pjXmkWl6sMFeLR5dUgkkhB5bJEbvrVcgQgTM_L_EZhba8Yo9p7uOhQOZLY)

Layer 2: loss-diffs \[0.3370, 0.3324, 0.2910, 0.1682, 0.1069\]

Four outlier Features

![](https://lh7-us.googleusercontent.com/ctvfeQi3wMrFpR9xBG1Gd3DVzGZNZanxJnw72TiBfJS8hQ-Fy1ZeXqksY1uXwr36wwkmIR2KQyTmzj7Y90qxUN8aw52Ul5bJOD44cJig3Y3AfPJ05aKms77J1c6fJ21RpBtbRkJcAsMTX4fwS2IkZJI)

![](https://lh7-us.googleusercontent.com/JQi_e53tSqlQijRwJ5VvrpCRAs8aUHaaP5kZ2YAJEN-cOkBSWR9ULdPLNSI4rz_U7Xr6tVSPw4GOilo146Qit0qfrPWbuq0qEcyM_Nf8zcjdZPyPhMxlmPqr2XB2d0-NamR7V9-ayK9Z4z9EqAMJ6Qw)

![](https://lh7-us.googleusercontent.com/q6NXyxa_iMyde3gw3V5AOm2cnyWW7sjmAbBf8iR-O30JxE4LGsXxeW0LmaWeHell9yH1S4TE-pk_AiP96eNyYJ_m4KldTBpy4w845auf31LZSVKsxZj88-ex3i80VxESTAHLTbAfJE4qfV1SrVhFWbo)

![](https://lh7-us.googleusercontent.com/InwHpsjyu_fM9AZOVnvjCQHdnVHWCzkqaLodadXkgyBupu70DBHm_Iv2d6l9udUmDKAyyxt3gGDXkDPTC39Th-ohqa1gPKtFjZkPt00xaS0cxefcFVvEKTyrOo90jD6E7ahhEtqwUlwAmzrxDLPOWwQ)

![](https://lh7-us.googleusercontent.com/0Y0igR9k0w7tjqaIqqW5fdJI0qqGkW9TX5bqMFw_yRK5ABp0rGZFSAcEWvLL8mCa48nTPYUzgaADHs_FCffZVL1WsUE0VX0QfNAXch8-js_00Z5P3GpPeFc2GfGD7t_KQPAcNoiwT9BXfMLOGH5iOJs)

Layer 1: loss-diffs \[0.1401, 0.0860, 0.0159, 0.0150, 0.0125\]

First Two features are outlier features

![](https://lh7-us.googleusercontent.com/5-yoHEC3sTHhVnvzKsinOBmY5-s0NC7E5C2ntdBcJdXkhwy2Wg73V26DbnzSfcjGbDVyrm76WQCZ1iTnMdSSO0PQWw-YQ8Q5U8kZ5g967KmJTUKW6zHU32MPtjd0JPHdXivLuCWCc8KdFwr_O5Ln5O0)

![](https://lh7-us.googleusercontent.com/-NFwnkEtIa3xrJqxDjntSFXqBt7yFdr76jkLO03knGYyMEoWR80MYwaFHfALhJmrRq_DMWPYIZyGC_2SrhTdpSyUvr7KHbKeIadeS4L-qfGEROZ4I4oNHYIloSyC-eO0_waCnXx3MkjI3vR_w-UjWiw)

![](https://lh7-us.googleusercontent.com/AOLTCRsusczATz3C6yyVK6RviW0Pr6DXjbnF0f6BplCD7-A0iHzTagYJeRDU-tir5GFXbF5QVudcjVMhlAwZ9kkZVkvAXAJ1kO7QKWziI0SDRa5OMmgR5tHfGw9kHxxBaqSu9Z0ZcGb64po4ZueWlcI)

![](https://lh7-us.googleusercontent.com/vZrxoDkfu5MT9vaGPfvKMy-uFzXD_fQy6D5BZRobliM0Fjbblq8uIrXOHPuYaGcKLN0jQWErwLraJXk3rbhtMOKAPpEtEJB3BpZOPcgaqdMKCRX9-EHtLbQkr7d7-uToST5ZkQ7LFraFJhrDYAaDcdI)

![](https://lh7-us.googleusercontent.com/8yf0qv_a_HNOJfcBwM8PPp2fkqYwA4YadpLDK5U3IeZk4jEH4po72OA1Ew4G0Jj8_mcpkM_OJHcW6NqgbjFPq4ssLtP7-kxTPF4wZPY3-aNLiF55PmV8idQ7yS6FHql3DovIFSQXpkDTslULYeUsqlo)

What about the specific weights for these features?

So, the MLP has two sets of linear weights: W2(relu(W1(x))).  Looking at W2, I noticed the features that had the largest loss had very many large positive & negative weights. Here’s the top 5 loss features (same that are visualized above). For positive weights:  
  
![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/6d1e426bfa90743145ab26b08037a9da8719a6eab214ade2.png)  
So the highest loss-diff feature in layer 4 had 112 weights connecting it that were > 0.1, where the median feature only had 9. 

For negative weights:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/862be66fcd641ea8ee884420261cb7c4b93c1ac64211a163.png)

Remember these are weights of W2, which connect the LLM’s MLP-out features & the hidden layer of the MLP-connector. We don’t really know what these mean.

But we could definitely just visualize them like we visualize the feature activations, maybe they’re interpretable, so … they were all pretty trash.

Outlier related: 8/30  
Polysemantic: 8/30  
Monosemantic:1/30  
(Basically) dead: 11/30

(These were for layer 3, but the layer 1 hidden features were surprisingly 80% monosemantic by default, w/ outlier features as well).

Wow, if only we had a method that made hidden layer activations more interpretable! So we could train the sparse MLP connector like a sparse AE: with an l1 penalty on the latent activation (basically an SAE connecting two SAE's).

SAEs on SAEs
------------

I use the same l1_alpha term for both l1 weights & hidden l1, and see the various losses for Layer 1. Overall:

loss = MSE + L1\_alpha*(L1(weights) + L1(hidden\_activations))

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/e8d21d0f34a2fb911998d5ebb461527ec910880d92826ca4.png)

Losses for various l1_alphas. "Hidden" is L1 loss on hidden activations. 

So I picked l1_alpha of 4e-4 as a compromise between MSE & the l1 losses. This corresponded to an L0 of 25 hidden latent activations (ie the other 3k were 0).

Looking at the top 30 max activating features, layer 3, 4, & 5 were all outlier dimensions (first tokens & first delimiter together) for the mlp. The SAE only had 10% outlier features. This makes sense since those outlier dimensions all activate for the same tokens (ie the first tokens & first delimiter), so would have high latent l1 activation. This would incentivize combining those dimensions more.

The features weren't significantly more monosemantic for the SAE than the MLP. This may be because I need to add a bias for the latent activation. Additionally, I'm confused on how to combine sparse weights w/ sparse latent activations (I specify more in "Help please"). I'll leave the rest of the empirical work to the future, and proceed w/ speculation.

Interpreting these features could be like the linear AND & OR statements from latent_features -> F2. From F1-> latent features is a ReLU, which, w/ a bias would be:

$Latent\_F = ReLU(w_1f_1 + w_2f_2 - bias)$

specifically

$Latent\_F_3 = ReLU(2.1*f_1 + 1.5*f_2 - 4)$

This could be either F1 OR F2 if they individually activate more than 4, or F1 AND F2 if they have to both activate together to be greater than 4.

This then makes it important to do feature activation statistics & clustering. It would be good to plot their co-activations (and color according to if it activations the latent feature)

But if I want to do more than 3 features, it's hard to plot their co-activations. Surely there's some statistical method here to gather the clusters of co-activations? 

Please Help
===========

This was mostly a "go fast & get results" set of experiments, which means many arbitrary choices were made, which I'd appreciate some feedback on. I do intend to research these questions myself (it's just currently late, and I wanted this post out end of this week).

1.  How should I take in consideration the different norms of the layers when training? For example, Layer 1 has a norm of (7,4) for (residual stream, mlp_out). Layer 5 has one of (16, 54). Atm, I'm dividing MSE by $\frac{(MLP\_out_{layer}\text{'s norm})^2}{\text{min norm}}$, and keeping the weight activation the same. 
    1.  How is this normally handled?
    2.  How would I handle adding in the latent activation l1 penalty? This isn't squared, so it would be $\frac{MLP\_out_{layer}\text{'s norm}}{\text{min norm}}$? I suspect this should consider the MLP_in norm though
    3.  If I instead normal
2.  Any relevant literature on sparse weightw & sparse latent activation
3.  Stats question: these weight-connections are estimating an estimate (ie the SAE's are reconstructing the layer's activations, and the weights are reconstructing the SAE's reconstruction). Is there some "mean error is the same, but variance is higher" argument here?
4.  What's the typical tool/algorithm for finding clusters of co-activations? I think correlation is *close*, but it wouldn't capture the case of A & B causing the feature, but sometimes A is very large & B is small, and others it's the reverse. 
    1.  I could also cache all input-feature activations when the latent feature activates, and cluster those. Though I also want input features that cause the latent feature to NOT activate. 
    2.  I also have sparse weights, which should be all the relevant information.

The Grand Plan
==============

If we can define circuits, we can concretely specify important model circuits such as truthfulness, deception, british-english, self-awareness, and personality traits. We will of course argue about if one's operationalization actually captures what we want, but we would could then *actually specify* them now to have that argument.

I'm excited about finding features that are causal to each other (this work is correlational). This could be done with gradients or causal interventions. Once we have these causal connections, we still need to find how these features are computed. This work shows many of those connections are linearly computed, and the nonlinearly computed ones are these outlier dimension features (which is useful for an LLM to do text prediction but not useful for model steering).[^3po7l3myi4l]

For attention features, we can also work on [QK/OV](https://transformer-circuits.pub/2021/framework/index.html) circuits between features in the residual stream & those after attention. This also requires taking in consideration feature activation statistics, but seems very doable!

So if we have the connections between features from Residual & MLP\_out and Residual & attention\_out, then we can also compute the features from the next layer Residual as a sparse linear combination of the previous layer features:  
$$$R_{layer+1} = R_{layer} +W_1*MLP\_out_{layer} + W\_2*Attn\_out_{layer}$

That's all the connections covered.

There's plenty of work left to do, but its on the difficulty level of "Normal Academia Can solve it" as opposed to "Prove P !=NP"; this is a much nicer timeline than I thought we were in last year.

If you'd like to work on any Sparse AE projects, feel free to join us on the EleutherAI discord channel (>25k members, so can easily lurk) in the #sparse-coding channel (under interp): [https://discord.gg/eleutherai](https://discord.gg/eleutherai)

Feel free to reach out to me (Logan) on discord: loganriggs, dm's on LW, or the comments below. 

Code
====

For code replication, see my [repo](https://github.com/loganriggs/sparse_coding/tree/main) at the "static*" files

static-all\_sparse\_weights - notebook for training & comparing linear vs nonlinear  
static-interpret\_sparse\_weights - notebook for visualizing linear or nonlinear features   
static-train\_sparse\_sae_connector - training the SAE (MLP w/ l1 latent activation penalty)  
static-interpre\_sparse\_weights_mlp - minimal notebook for interpreting the sparse SAE's latent activations & comparing w/ the MLP's. 

\[Note: I haven't had time to comment or clean up these notebooks. Please message me if you run into any issues\]

Appendices
==========

Here are extra experiments that didn't pan out or were just weird.

Failed MLP sweep
----------------

I also tried to reduce the hidden layer size of the MLP, but there was still an increase in MSE. This was without restricting the MLP to only MLP features.  
 

![](https://lh7-us.googleusercontent.com/ZMxMWWH7H9vmIYooiW_I98c7sjmQUIFrDpDHtRjUzcR4mZK0IxiqeyX5Zbg-LMqusf0Cajaii7N7phmK1-0gvIu3ZYtLABdHtUwbf6yKc552RSk8sk6OXm6Qvj5AYXRcL9ifEiT_NFs7uyLIV4UhA3A)

  
 

Attention
---------

Also, what if we did the same analysis but on attention? 

  
 

![](https://lh7-us.googleusercontent.com/aLmZ2VH2sw2O4NvjLDUYdXkEDVfxeBU-l4MK9DTQ8dgZsQ0K88JEyXctad0soCjuD-1n9D2FdSrKrZzZX-7-KfstFuxgqpCqdB2qmSA4egHQkICrhzDoa4KSnk9SqmRTUE5yaP5FzYZEyBYW48jKKkw)

Layer 4 should be ignored, since it’s mostly dead features, but overall this is pretty weird! I haven't normalized the loss like I did for MLP, but it seems like many features can be linearly reconstructed by features. This means that attention isn't really *doing* attention for a lot of features. 

By this I mean attention normally takes in all the features in previous token positions. If we have 200 tokens per example & ~20 features/datapoint, then attention has access to all 20*200 features at the 200th position. Here however, it only has access to the 20 features *at the current position*. Weird.  
 

![](https://lh7-us.googleusercontent.com/jcVYOJZj5Oz3LiSwWQ-Jn2wgSVOFGDutdIAk_05aLl6AbrTsVsygMS2G0Tdina5i8w7DBAdDPVdzWixidlCt2voURgMJInA-v8bjoItOWLARK3SCDNMzZbBF8VaMbdw4yc3eQPp3VKeP3JeRDaQfb2I)

![](https://lh7-us.googleusercontent.com/Cec_g95KOwYonPPR8Uudt4DuZwgVGQfTZfBIccyMZaEGECocZnq-XzsHffPDYzLoi2gDbHpqsSuZ7shTACSwce8bnwO-qAopSe9-Ou8xJg4Sgssjd7ULicmsC_k6c31c72ESTOwbXEefeowcxN-1afY)

  
 

[^pwepir8kf3]: Additionally, the full computation between features F1 & F2 must include the decoder from SAE_1, the MLP, & encoder + ReLU from SAE_2. F2 = relu(linear(linear(gelu(linear(linear(F1)))))) = relu(linear(gelu(linear(F1))) [Since two linear functions can be equivalent to 1 linear function) 

[^3po7l3myi4l]: I do think it'd be valuable to figure out what causal role these outlier dimensions play.