# Characterizing stable regions in the residual stream of LLMs

*This research was completed for London AI Safety Research (LASR) Labs 2024. The team was supervised by* [*@Stefan Heimershiem*](https://www.lesswrong.com/users/stefan42) *(Apollo Research). Find out more about the program and express interest in upcoming iterations* [*here*](https://www.lasrlabs.org)*.*

*This* [*video*](https://drive.google.com/file/d/1ji1LDrMHl2aPaEPCpNx65EjSO6MKmUfj/view?usp=drive_link) *is a short overview of the project presented on the final day of the LASR Labs. Note that the paper was updated since then.*

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/animations/50bb15be675ca9ec3bbd009bad91a38caf41618ac44ecb5a.gif)

Visualization of stable regions in OLMo-7B during training. Colors represent the similarity of model outputs to those produced by three model-generated activations (red, green, blue circles). Each frame shows a 2D slice of the residual stream after the first layer at different stages of training. As training progresses, distinct regions of solid color emerge and the boundaries between them sharpen. See [here](https://drive.google.com/drive/folders/1xQnyULfZp0MvkOK-3IWFBS9jJq3gB_h1?usp=sharing) for more animations in better quality.

We study the effects of perturbing Transformer activations, building upon recent work by [Gurnee](https://www.alignmentforum.org/posts/rZPiuFxESMxCDHe4B/sae-reconstruction-errors-are-empirically-pathological), [Lindsey](https://transformer-circuits.pub/2024/april-update/index.html#ablation-exps), and [Heimersheim & Mendel](https://www.lesswrong.com/posts/LajDyGyiyX8DNNsuF/interim-research-report-activation-plateaus-and-sensitive-1). Specifically, we interpolate between model-generated residual stream activations, and measure the change in the model output. Our initial results suggest that:

1.  The residual stream of a trained Transformer can be divided into *stable regions*. Within these regions, small changes in model activations lead to minimal changes in output. However, at region boundaries, small changes can lead to significant output differences.
2.  These regions emerge during training and evolves with model scale. Randomly initialized models do not exhibit these stable regions, but as training progresses or model size increases, the boundaries between regions become sharper.
3.  These stable regions appear to correspond to *semantic distinctions*. Dissimilar prompts occupy different regions, and activations from different regions produce different next token predictions.
4.  While further investigation is needed, these regions appear to be much larger than polytopes studied by [Hanin & Rolnick](https://proceedings.mlr.press/v97/hanin19a.html) and [Black et al.](https://www.lesswrong.com/posts/eDicGjD9yte6FLSie/interpreting-neural-networks-through-the-polytope-lens)

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

Sharpness of boundaries (y-axis) between stable regions seems to increase with the number of parameters (colors) and number of training tokens (x-axis). On y-axis we plot the maximum slope of the relative change in the output as we interpolate between two prompts. Data is aggregated across 1,000 randomly sampled pairs of prompts, dots represent the median, and error bars represent 25th and 75th percentiles.

We believe that studying stable regions can improve our understanding of how neural networks work. The extent to which this understanding is useful for safety is an active topic of discussion [1](https://www.lesswrong.com/posts/pmz3HpJrHcWhkLqS5/three-ways-interpretability-could-be-impactful)  [2](https://www.lesswrong.com/posts/FDrgcfY8zs5e2eJDd/charbel-raphael-and-lucius-discuss-interpretability)  [3](https://www.lesswrong.com/posts/tEPHGZAb63dfq2v8n/how-useful-is-mechanistic-interpretability).

You can read the paper [on arxiv](https://arxiv.org/abs/2409.17113).