<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Rohan Buluswar</title>
<link>https://rbuluswar.github.io/posts/</link>
<atom:link href="https://rbuluswar.github.io/posts/index.xml" rel="self" type="application/rss+xml"/>
<description></description>
<generator>quarto-1.9.38</generator>
<lastBuildDate>Tue, 13 Oct 2026 04:00:00 GMT</lastBuildDate>
<item>
  <title>Non-Universality of Line Break Features and Algorithms</title>
  <link>https://rbuluswar.github.io/posts/line-break-project/</link>
  <description><![CDATA[ 





<p>This is the long-form research writeup for a project I did, investigating whether line break mechanisms found in LLMs are naturally induced in toy models. The underlying experiments and notebooks live in the <a href="https://github.com/rbuluswar/Line-Break-Project">Line Break Project repository</a>.</p>
<section id="motivation" class="level2">
<h2 class="anchored" data-anchor-id="motivation">Motivation</h2>
<p>One of the most important conjectures in mechanistic interpretability is the notion of ‘universality’ - that is, that for any subtask which an LLM needs to perform, there exists some optimal, or as I like to think of it, “Platonic ideal”, collection of features/representations and circuits to solve it. Consequently, regardless of architectural details, any neural network should implement an imperfect version of that ideal representation. If this hypothesis holds, we should observe that independently trained models display similar behavior, and studying one model should allow us to understand any other. This would indeed be excellent news for the project of interpretability, to say nothing of its intriguing consequences on our understanding of intelligence.</p>
<p>Several lines of prior work have explored this idea by training small models, often on particular tasks. For example, toy models have been used to study superposition (Elhage et al., 2022) and small transformers trained on synthetic tasks have been shown to develop interpretable mechanisms for copying (Olsson et al., 2022), modular addition (Nanda et al., 2023), sorting and parsing (Weiss et al., 2021; Allen-Zhu &amp; Li, 2023), and even representing board states (Li et al., 2023). While small models are often interpretable, work by (Chughtai et al., 2023) on group composition revealed that mechanisms across models may belong to a family of solutions even though particular features and circuits are arbitrary. My project investigates this weaker notion of universality on the synthetic task of predicting line breaks.</p>
<p>Specifically, this project was inspired by <em>When Models Manipulate Manifolds: The Geometry of a Counting Task</em> (Gurnee et al., 2026), a paper authored at Anthropic that outlines a full mechanistic breakdown of line break prediction in Claude 3.5 Haiku. One major finding was that character count was not represented linearly, as features are often assumed to be, but on a curved low-dimensional manifold. They found attention heads that acted on this feature manifold to estimate the distance to the line boundary, enabling the model to determine when to break the line instead of writing the next textual token.</p>
<p>This works trains a small transformer purely on the task of predicting line breaks in an entirely synthetic setting in order to discover whether the model will implement similar mechanisms. We find provide a mechanistic breakdown of the algorithm the model uses and find similar motifs - a low-dimensional non-linear representation of character count that is acted on primarily by attention heads - but with several important differences.</p>
</section>
<section id="model-architecture-synthetic-data-and-training" class="level2">
<h2 class="anchored" data-anchor-id="model-architecture-synthetic-data-and-training">Model Architecture, Synthetic Data, and Training</h2>
<p>The model is a small causal Transformer with three layers and four attention heads per layer. Its residual stream has width 128, each head has dimension 32, and the MLPs have width 512. The model uses GELU activations, layer normalization, standard learned positional embeddings, and a vocabulary of 82 tokens. The context length is 150 tokens. This architecture is intentionally small enough to inspect directly, while still providing enough capacity to represent and manipulate the counting variable.</p>
<p>The training data are generated procedurally rather than stored in a fixed dataset. The vocabulary contains two special tokens, <code>BOS</code> and <code>_NEWLINE_</code>, plus 80 ordinary tokens divided evenly among eight token lengths: there are ten distinct token identities of each length from 1 through 8 characters. To generate one example, I first sample 150 ordinary tokens uniformly at random and prepend <code>BOS</code>. I then sample a line-width limit uniformly from the integers 50 through 100. Scanning from left to right, I accumulate the character lengths of the tokens; whenever the current line has reached the sampled limit, I insert <code>_NEWLINE_</code> before the next token and reset the line counter. The resulting sequence is cropped to the required context and shifted by one position to form the inputs and next-token targets. Thus, each example contains a fresh random token sequence and a single line-width limit shared by all of its lines, while the correct newline locations are determined exactly by the token lengths and the running count.</p>
<p>The model is trained with the standard autoregressive next-token objective: the mean cross-entropy between its predicted distribution and the target token at every position. Newline prediction is therefore learned as part of ordinary language modeling rather than through a separate binary newline objective. In the main configuration, batches contain 256 examples and are generated on the fly. I train for 10,000 optimization steps with AdamW, using a learning rate of <img src="https://latex.codecogs.com/png.latex?10%5E%7B-3%7D">, weight decay of <img src="https://latex.codecogs.com/png.latex?0.01">, gradient-norm clipping at 1, and a cosine learning-rate schedule with 500 warmup steps and a minimum learning rate of <img src="https://latex.codecogs.com/png.latex?10%5E%7B-4%7D">. Evaluation uses a fixed randomly generated batch so that changes in performance can be compared across training checkpoints.</p>
</section>
<section id="activations-at-each-layer" class="level2">
<h2 class="anchored" data-anchor-id="activations-at-each-layer">Activations at Each Layer</h2>
<p>The following plots show the activation trajectory for one example in a separate three-dimensional PCA space at the residual stream immediately before each attention layer. Each point corresponds to a token position, with the trajectory colored by cumulative character count. The PCA basis is fit separately for each layer, so the plots are useful for comparing the geometry within a layer rather than the absolute orientation of the spaces across layers.</p>
<section id="before-attention-layer-0" class="level3">
<h3 class="anchored" data-anchor-id="before-attention-layer-0">Before attention layer 0</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/activation-trajectories/pre_attention_layer_0_3d_pca.html" title="Activations before attention layer 0 in 3-D PCA space" style="display: block; width: 100%; height: 640px; border: none;" loading="lazy"> </iframe>
</div>
<figcaption>
Example 27 before attention layer 0. The three displayed principal components explain 35.7% of the activation variance.
</figcaption>
</figure>
</section>
<section id="before-attention-layer-1" class="level3">
<h3 class="anchored" data-anchor-id="before-attention-layer-1">Before attention layer 1</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/activation-trajectories/pre_attention_layer_1_3d_pca.html" title="Activations before attention layer 1 in 3-D PCA space" style="display: block; width: 100%; height: 640px; border: none;" loading="lazy"> </iframe>
</div>
<figcaption>
Example 27 before attention layer 1. The three displayed principal components explain 93.6% of the activation variance.
</figcaption>
</figure>
</section>
<section id="before-attention-layer-2" class="level3">
<h3 class="anchored" data-anchor-id="before-attention-layer-2">Before attention layer 2</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/activation-trajectories/pre_attention_layer_2_3d_pca.html" title="Activations before attention layer 2 in 3-D PCA space" style="display: block; width: 100%; height: 640px; border: none;" loading="lazy"> </iframe>
</div>
<figcaption>
Example 27 before attention layer 2. The three displayed principal components explain 92.0% of the activation variance.
</figcaption>
</figure>
</section>
</section>
<section id="activation-geometry-before-layer-2" class="level2">
<h2 class="anchored" data-anchor-id="activation-geometry-before-layer-2">Activation Geometry Before Layer 2</h2>
<p>The three-dimensional plots above suggest that the pre-layer-2 residual stream is highly structured. We therefore asked a more demanding question: how much of the activation can be predicted from a small number of interpretable variables, rather than from an arbitrary 128-dimensional vector? For each token position, we used the normalized within-line phase <img src="https://latex.codecogs.com/png.latex?u%20=%20%5Cfrac%7B%5Ctext%7Bcharacters%20seen%20so%20far%7D%7D%7B%5Ctext%7Bline%20width%7D%7D">, clipped to the range <img src="https://latex.codecogs.com/png.latex?%5B0,%201.5%5D"> so that positions beyond a line boundary were still represented. We expanded <img src="https://latex.codecogs.com/png.latex?u"> into a cubic B-spline basis with 12 knots and fit ridge regressions to the held-out activation vectors. In the first set of fits, the regressors also included the sampled line width, its interaction with the phase basis, the residual from the line boundary, and token position. In the decomposition experiments, we focused on the simpler and more interpretable alternatives: phase alone; phase plus a single learned line-number direction; phase plus a separate learned offset for each line; and a phase/line interaction model.</p>
<p>We evaluated both the geometry and the computation. The PCA-based models first predicted three global PCA coordinates and mapped them back into the full residual space; the full-space models predicted all coordinates directly. We also fit an unconstrained additive model and an orthogonal model in which the phase directions were projected to be orthogonal to the line-number direction. Every model was fit on one set of generated examples and evaluated on held-out examples. For the intervention metrics, we replaced the model’s pre-layer-2 activations with the fitted reconstructions and ran the remaining network. Activation MSE measures reconstruction error, while variance reduction is defined relative to the global-mean baseline as <img src="https://latex.codecogs.com/png.latex?1%20-%20%5Cmathrm%7BMSE%7D_%7B%5Ctext%7Bmodel%7D%7D/%5Cmathrm%7BMSE%7D_%7B%5Ctext%7Bmean%7D%7D">. Newline precision is the fraction of predicted newline tokens that are correct, and newline recall is the fraction of true newline positions recovered.</p>
<p>The results are summarized below. The clean row is the unmodified model, and the random-subspace row averages over 20 random three-dimensional subspaces. The latter provides a useful control: a low-dimensional representation is not automatically useful simply because it has three dimensions.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Approximation</th>
<th style="text-align: right;">Activation MSE</th>
<th style="text-align: right;">Variance reduction</th>
<th style="text-align: right;">Newline precision</th>
<th style="text-align: right;">Newline recall</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Clean model (no replacement)</td>
<td style="text-align: right;">—</td>
<td style="text-align: right;">—</td>
<td style="text-align: right;">0.519</td>
<td style="text-align: right;">1.000</td>
</tr>
<tr class="even">
<td style="text-align: left;">Global 3D PCA</td>
<td style="text-align: right;">0.558</td>
<td style="text-align: right;">88.4%</td>
<td style="text-align: right;">0.458</td>
<td style="text-align: right;">0.993</td>
</tr>
<tr class="odd">
<td style="text-align: left;">PCA-reconstructed phase-only spline</td>
<td style="text-align: right;">2.537</td>
<td style="text-align: right;">47.3%</td>
<td style="text-align: right;">0.219</td>
<td style="text-align: right;">1.000</td>
</tr>
<tr class="even">
<td style="text-align: left;">PCA-reconstructed phase + one line vector</td>
<td style="text-align: right;">1.808</td>
<td style="text-align: right;">62.4%</td>
<td style="text-align: right;">0.219</td>
<td style="text-align: right;">0.951</td>
</tr>
<tr class="odd">
<td style="text-align: left;">PCA-reconstructed separate line offsets</td>
<td style="text-align: right;">1.364</td>
<td style="text-align: right;">71.6%</td>
<td style="text-align: right;">0.181</td>
<td style="text-align: right;">0.503</td>
</tr>
<tr class="even">
<td style="text-align: left;">Full-space unconstrained phase + line</td>
<td style="text-align: right;">1.685</td>
<td style="text-align: right;">65.1%</td>
<td style="text-align: right;">0.235</td>
<td style="text-align: right;">0.977</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Full-space orthogonal phase + line</td>
<td style="text-align: right;">1.761</td>
<td style="text-align: right;">63.6%</td>
<td style="text-align: right;">0.228</td>
<td style="text-align: right;">0.932</td>
</tr>
<tr class="even">
<td style="text-align: left;">Random 3D subspace</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?4.721%20%5Cpm%200.051"></td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?2.3%5C%25%20%5Cpm%201.0%5C%25"></td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?0.350%20%5Cpm%200.393"></td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?0.211%20%5Cpm%200.348"></td>
</tr>
</tbody>
</table>
<p>The global PCA reconstruction captures most of the activation variance and preserves newline recall, but it is not behaviorally perfect: precision falls from 0.519 to 0.458. The more structured phase-and-line models recover a substantial fraction of the variance with only a few fitted degrees of freedom, and the additive full-space model preserves newline recall particularly well. At the same time, no single parameterization reproduces both the geometry and the behavior completely. In the phase-plus-one-line model, the learned phase coefficient matrix is itself approximately rank two: its first two singular directions capture about 95% of its variance. This is consistent with a picture of a curved, effectively two-dimensional phase trajectory accompanied by a separate line-number direction, while the random-subspace control suggests that this structure is task-relevant rather than an incidental consequence of projecting into three dimensions.</p>
</section>
<section id="how-layer-1-constructs-the-character-count-manifold" class="level2">
<h2 class="anchored" data-anchor-id="how-layer-1-constructs-the-character-count-manifold">How Layer 1 Constructs the Character Count Manifold</h2>
<p>The next experiment isolates the outputs of the four attention heads in layer 1. For each head, we record its raw <code>hook_z</code> output before the output projection, which lives in the head’s 32-dimensional space, and fit a separate three-dimensional PCA to the trajectory across token positions. The orange trajectory therefore shows how that head’s own output changes over the sequence after compression into three coordinates. Points are colored by cumulative character count, and the interactive plots expose the token position and count on hover.</p>
<p>We then measure the effect of each head on the residual stream by running the same example while replacing that head’s output with zero. The resulting trajectories are shown in a shared three-dimensional PCA basis so that the clean and zero-ablated paths can be compared in the same coordinates. These interventions change only the selected head’s <code>hook_z</code>; the rest of the network and the other heads remain active. The plots show the pre-attention trajectory, the clean post-attention trajectory, and the corresponding zero-ablated trajectory for each head.</p>
<section id="raw-layer-1-head-outputs" class="level3">
<h3 class="anchored" data-anchor-id="raw-layer-1-head-outputs">Raw layer-1 head outputs</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_0_raw_hook_z_pca.html" title="Layer 1 head 0 raw output in d-head PCA" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 0: raw <code>hook_z</code> output in its 32-dimensional head space, shown in a three-dimensional PCA.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_1_raw_hook_z_pca.html" title="Layer 1 head 1 raw output in d-head PCA" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 1: raw <code>hook_z</code> output in head space.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_2_raw_hook_z_pca.html" title="Layer 1 head 2 raw output in d-head PCA" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 2: raw <code>hook_z</code> output in head space.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_3_raw_hook_z_pca.html" title="Layer 1 head 3 raw output in d-head PCA" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 3: raw <code>hook_z</code> output in head space.
</figcaption>
</figure>
</section>
<section id="zero-ablation-trajectories" class="level3">
<h3 class="anchored" data-anchor-id="zero-ablation-trajectories">Zero-ablation trajectories</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_0_zero_ablation_pca.html" title="Layer 1 head 0 zero ablation" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 0 zero ablation in the shared residual-space PCA.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_1_zero_ablation_pca.html" title="Layer 1 head 1 zero ablation" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 1 zero ablation in the shared residual-space PCA.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_2_zero_ablation_pca.html" title="Layer 1 head 2 zero ablation" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 2 zero ablation in the shared residual-space PCA.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-outputs/head_3_zero_ablation_pca.html" title="Layer 1 head 3 zero ablation" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Layer 1, head 3 zero ablation in the shared residual-space PCA.
</figcaption>
</figure>
</section>
<section id="layer-1-attention-patterns" class="level3">
<h3 class="anchored" data-anchor-id="layer-1-attention-patterns">Layer-1 attention patterns</h3>
<p>The next plot shows the attention matrices for the four heads in layer 1 on one fixed example. Each panel is indexed by query position horizontally and key position vertically, with the causal mask leaving only the lower-triangular region available. The color indicates the normalized attention weight. This is a direct visualization of the pattern tensor, before considering the value vectors or the output projection.</p>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/attention-patterns/layer1_attention_patterns.html" title="Interactive layer-1 attention patterns" style="display:block;width:100%;height:720px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Interactive example layer-1 attention patterns for all four heads. Hover over a cell to see its query position, key position, and attention weight.
</figcaption>
</figure>
</section>
<section id="mean-ablation-metrics" class="level3">
<h3 class="anchored" data-anchor-id="mean-ablation-metrics">Mean-ablation metrics</h3>
<p>To measure the behavioral role of each head, notebook 13 replaces its output with a mean vector estimated from calibration sequences, then evaluates newline recall, newline precision, and newline prediction frequency. The three heatmaps report those quantities for every layer and head. This is a mean-ablation intervention, distinct from the zero-ablation trajectory plots above.</p>
<figure class="figure">
<img src="https://rbuluswar.github.io/posts/line-break-project/figures/deck-figures/layer1_mean_ablation_metrics.png" alt="Newline metrics under mean ablation of each attention head" style="display:block;width:100%;border-radius:16px;box-shadow:0 4px 18px rgba(0,0,0,0.12);" class="figure-img">
<figcaption>
Newline recall, precision, and prediction frequency under mean ablation of each attention head.
</figcaption>
</figure>
</section>
<section id="where-the-character-count-representation-emerges" class="level3">
<h3 class="anchored" data-anchor-id="where-the-character-count-representation-emerges">Where the character-count representation emerges</h3>
<p>Notebook 09 fits held-out linear probes for cumulative character count at several layer-1 sites. The probe is trained separately for each site and reports <img src="https://latex.codecogs.com/png.latex?R%5E2"> and mean absolute error (MAE), excluding BOS and newline positions. The comparison tracks how linearly readable the count becomes through the layer.</p>
<p>The head-wise probe values are:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">Head</th>
<th style="text-align: right;">Raw <img src="https://latex.codecogs.com/png.latex?z">: held-out <img src="https://latex.codecogs.com/png.latex?R%5E2"></th>
<th style="text-align: right;">Raw <img src="https://latex.codecogs.com/png.latex?z">: MAE</th>
<th style="text-align: right;">Residual contribution: held-out <img src="https://latex.codecogs.com/png.latex?R%5E2"></th>
<th style="text-align: right;">Residual contribution: MAE</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.0969</td>
<td style="text-align: right;">18.9593</td>
<td style="text-align: right;">0.0965</td>
<td style="text-align: right;">18.9556</td>
</tr>
<tr class="even">
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.9752</td>
<td style="text-align: right;">2.9050</td>
<td style="text-align: right;">0.9741</td>
<td style="text-align: right;">2.9576</td>
</tr>
<tr class="odd">
<td style="text-align: right;">2</td>
<td style="text-align: right;">0.1398</td>
<td style="text-align: right;">18.3749</td>
<td style="text-align: right;">0.1405</td>
<td style="text-align: right;">18.3515</td>
</tr>
<tr class="even">
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.1108</td>
<td style="text-align: right;">18.7098</td>
<td style="text-align: right;">0.1115</td>
<td style="text-align: right;">18.6876</td>
</tr>
</tbody>
</table>
<p>A single count probe is then trained on clean data and applied without refitting after each layer-1 head is zero-ablated:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Condition</th>
<th style="text-align: right;">Held-out <img src="https://latex.codecogs.com/png.latex?R%5E2"></th>
<th style="text-align: right;">MAE</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Clean post-layer-1 activation</td>
<td style="text-align: right;">0.9969</td>
<td style="text-align: right;">0.9902</td>
</tr>
<tr class="even">
<td style="text-align: left;">Head 0 zero-ablated</td>
<td style="text-align: right;">0.9896</td>
<td style="text-align: right;">1.9283</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Head 1 zero-ablated</td>
<td style="text-align: right;">−1.2870</td>
<td style="text-align: right;">29.9623</td>
</tr>
<tr class="even">
<td style="text-align: left;">Head 2 zero-ablated</td>
<td style="text-align: right;">0.9668</td>
<td style="text-align: right;">3.7937</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Head 3 zero-ablated</td>
<td style="text-align: right;">0.9282</td>
<td style="text-align: right;">5.2966</td>
</tr>
</tbody>
</table>
</section>
<section id="functional-form-of-the-head-1-output" class="level3">
<h3 class="anchored" data-anchor-id="functional-form-of-the-head-1-output">Functional form of the Head 1 output</h3>
<p>Notebook 12 tests whether the layer-1 Head 1 output can be represented as an affine function of simple sequence-level variables. The count-only model uses cumulative character count <img src="https://latex.codecogs.com/png.latex?c_t"> and line width <img src="https://latex.codecogs.com/png.latex?%5Cell">; the length-histogram model adds the counts <img src="https://latex.codecogs.com/png.latex?n_%7Bt,r%7D"> of tokens of each character length <img src="https://latex.codecogs.com/png.latex?r"> since the previous newline. A third model also includes position within the sequence. Each model predicts the raw 32-dimensional head output <img src="https://latex.codecogs.com/png.latex?z_t"> or its residual contribution <img src="https://latex.codecogs.com/png.latex?z_tW_O"> and is evaluated on held-out ordinary-token positions.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Model</th>
<th style="text-align: right;">Raw <img src="https://latex.codecogs.com/png.latex?z">: held-out <img src="https://latex.codecogs.com/png.latex?R%5E2"></th>
<th style="text-align: right;">Raw <img src="https://latex.codecogs.com/png.latex?z">: MSE</th>
<th style="text-align: right;">Residual contribution: held-out <img src="https://latex.codecogs.com/png.latex?R%5E2"></th>
<th style="text-align: right;">Residual contribution: MSE</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Count-only</td>
<td style="text-align: right;">0.8103</td>
<td style="text-align: right;">0.0551</td>
<td style="text-align: right;">0.9226</td>
<td style="text-align: right;">0.0526</td>
</tr>
<tr class="even">
<td style="text-align: left;">Length histogram</td>
<td style="text-align: right;">0.8105</td>
<td style="text-align: right;">0.0550</td>
<td style="text-align: right;">0.9226</td>
<td style="text-align: right;">0.0526</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Length histogram + position</td>
<td style="text-align: right;">0.8105</td>
<td style="text-align: right;">0.0550</td>
<td style="text-align: right;">0.9226</td>
<td style="text-align: right;">0.0526</td>
</tr>
</tbody>
</table>
</section>
<section id="incremental-output-and-token-length" class="level3">
<h3 class="anchored" data-anchor-id="incremental-output-and-token-length">Incremental output and token length</h3>
<p>The accumulator test also compares adjacent Head 1 outputs within a line segment. For each ordinary token, it measures the norm of the output increment associated with adding that token and groups the increments by the new token’s character length. The plot shows all held-out increments, their mean and standard deviation at each length, and three simple fits: linear, logarithmic, and square-root dependence on token length.</p>
<figure class="figure">
<img src="https://rbuluswar.github.io/posts/line-break-project/figures/deck-figures/head1_increment_vs_length.png" alt="Head 1 output increment versus token length" style="display:block;width:100%;border-radius:16px;box-shadow:0 4px 18px rgba(0,0,0,0.12);" class="figure-img">
<figcaption>
Held-out Head 1 output increments grouped by the character length of the new token.
</figcaption>
</figure>
<p>The held-out <img src="https://latex.codecogs.com/png.latex?R%5E2"> values for the linear, logarithmic, and square-root fits are 0.6338, 0.5734, and 0.6176, respectively. The corresponding test of adjacent output increments gives <img src="https://latex.codecogs.com/png.latex?R%5E2=0.5966">.</p>
</section>
<section id="pre-mlp-geometry" class="level3">
<h3 class="anchored" data-anchor-id="pre-mlp-geometry">Pre-MLP geometry</h3>
<p>Finally, notebook 11 examines the post-attention, pre-MLP residual stream, <code>blocks.1.hook_resid_mid</code>. It splits each sequence at newline tokens, keeps newline-free segments with at least four ordinary tokens, and visualizes their activation trajectories in a shared three-dimensional PCA basis. For the line-geometry regression, each segment’s 128-dimensional activations are projected onto their first principal component. We measure the fraction of variance captured by that one-dimensional line, then repeat the fit using alternating token positions as training data and evaluate the reconstruction error on the held-out positions. Across 1,143 usable segments, the mean in-sample <img src="https://latex.codecogs.com/png.latex?R%5E2"> is 0.926 and the mean held-out <img src="https://latex.codecogs.com/png.latex?R%5E2"> is 0.892.</p>
<figure class="figure">
<img src="https://rbuluswar.github.io/posts/line-break-project/figures/deck-figures/pre_mlp_geometry.png" alt="Post-attention pre-MLP line-segment geometry" style="display:block;max-width:760px;width:100%;margin:auto;border-radius:16px;box-shadow:0 4px 18px rgba(0,0,0,0.12);" class="figure-img">
<figcaption>
Post-attention, pre-MLP line-segment geometry in a shared PCA space.
</figcaption>
</figure>
</section>
<section id="layer-1-head-1-key-contribution-overlay" class="level3">
<h3 class="anchored" data-anchor-id="layer-1-head-1-key-contribution-overlay">Layer 1 Head 1 key-contribution overlay</h3>
<p>Notebook 06/12 decomposes the isolated residual-stream contribution of layer-1 Head 1 by key position. For a fixed query position <img src="https://latex.codecogs.com/png.latex?q">, the contribution from key <img src="https://latex.codecogs.com/png.latex?j"> is <img src="https://latex.codecogs.com/png.latex?a_%7Bqj%7D(v_j%20W_O)">, so the individual contributions sum to the head’s complete residual write. The final plot overlays the cumulative trajectories for several query positions in one common residual-space PCA, with a separate color for each query. This makes the per-key contributions and their running sums directly comparable across queries.</p>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/layer1-head-contributions/head_1_key_contribution_overlay.html" title="Layer 1 head 1 key contribution overlay" style="display:block;width:100%;height:660px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Overlay of Head 1 key-contribution trajectories for the selected query positions, in a common residual-space PCA.
</figcaption>
</figure>
</section>
</section>
<section id="how-layer-2-utilizes-character-counts-for-prediction" class="level2">
<h2 class="anchored" data-anchor-id="how-layer-2-utilizes-character-counts-for-prediction">How Layer 2 Utilizes Character Counts for Prediction</h2>
<p>The final-attention experiment examines how Head 3 forms its attention pattern from query and key embeddings. We take the residual-stream activation immediately before the final attention layer, apply that layer’s layer normalization, and project it through <img src="https://latex.codecogs.com/png.latex?W_Q"> and <img src="https://latex.codecogs.com/png.latex?W_K">. A joint PCA is fit to all query and key embeddings in the example, so the two sets of vectors appear in the same three-dimensional coordinate system. The normalized causal-attention heatmap shows the actual row-wise softmax weights cached from the model; entries above the diagonal are masked because a query cannot attend to future positions.</p>
<p>The two examples below use the same sampled sequence. At query position 58, the model’s top prediction is <code>_NEWLINE_</code>; at position 59, its top prediction is an ordinary token. For each query, the three plots show the joint 3-D Q/K geometry, the actual attention weights alongside attention reconstructed from the 3-D PCA coordinates, and the raw inner products between the query and key vectors in that PCA space. The reconstruction computes the PCA-space inner products, applies the usual <img src="https://latex.codecogs.com/png.latex?1/%5Csqrt%7B3%7D"> scaling, masks future keys, and applies a row-wise softmax. The attention plots include the current key position as well as the earlier causal prefix.</p>
<section id="joint-querykey-geometry-and-normalized-attention" class="level3">
<h3 class="anchored" data-anchor-id="joint-querykey-geometry-and-normalized-attention">Joint query/key geometry and normalized attention</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/joint_wq_wk_embeddings.html" title="Joint WQ and WK embeddings" style="display:block;width:100%;height:660px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
All final-layer Head 3 query and key embeddings in one joint three-dimensional PCA.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/normalized_causal_attention.html" title="Normalized causal attention" style="display:block;width:100%;height:600px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Cached normalized causal attention for final-layer Head 3.
</figcaption>
</figure>
</section>
<section id="query-position-58-predicted-newline" class="level3">
<h3 class="anchored" data-anchor-id="query-position-58-predicted-newline">Query position 58: predicted newline</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/query_58_predicted_newline_embeddings.html" title="Query position 58 Q K embeddings" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Query position 58, where the model predicts a newline: Q/K embeddings and the causal key prefix.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/query_58_predicted_newline_attention_comparison.html" title="Query position 58 attention comparison" style="display:block;width:100%;height:560px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Actual attention versus attention reconstructed from the global 3-D PCA Q/K coordinates.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/query_58_predicted_newline_raw_inner_products.html" title="Query position 58 raw QK inner products" style="display:block;width:100%;height:460px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Raw Q/K inner products in the same three-dimensional PCA space.
</figcaption>
</figure>
</section>
<section id="query-position-59-no-predicted-newline" class="level3">
<h3 class="anchored" data-anchor-id="query-position-59-no-predicted-newline">Query position 59: no predicted newline</h3>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/query_59_non_newline_embeddings.html" title="Query position 59 Q K embeddings" style="display:block;width:100%;height:640px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Query position 59, where the model does not predict a newline: Q/K embeddings and the causal key prefix.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/query_59_non_newline_attention_comparison.html" title="Query position 59 attention comparison" style="display:block;width:100%;height:560px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Actual attention versus attention reconstructed from the global 3-D PCA Q/K coordinates.
</figcaption>
</figure>
<figure class="figure">
<div style="border-radius: 16px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);">
<iframe src="figures/final-qk-geometry/query_59_non_newline_raw_inner_products.html" title="Query position 59 raw QK inner products" style="display:block;width:100%;height:460px;border:none;" loading="lazy"></iframe>
</div>
<figcaption>
Raw Q/K inner products in the same three-dimensional PCA space.
</figcaption>
</figure>
</section>
<section id="layer-2-head-3-output-interventions" class="level3">
<h3 class="anchored" data-anchor-id="layer-2-head-3-output-interventions">Layer-2 Head 3 output interventions</h3>
<p>Notebook 29 separately intervenes on the values and attention pattern of final-layer Head 3. Value interventions replace the head’s value vectors with their mean, shuffle them across positions, or set them to zero. Pattern interventions replace the attention distribution with attention concentrated on previous newline positions, a uniform distribution over those positions, or a distribution with newline attention removed. The model is then evaluated on newline precision, recall, and prediction frequency.</p>
<p>The attention-predictor analysis also reports the area under the ROC curve for using attention statistics to predict newline targets:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Attention statistic</th>
<th style="text-align: left;">Target</th>
<th style="text-align: right;">AUC</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Total attention to previous newline tokens</td>
<td style="text-align: left;">True newline</td>
<td style="text-align: right;">0.8634</td>
</tr>
<tr class="even">
<td style="text-align: left;">Attention to the most recent previous newline</td>
<td style="text-align: left;">True newline</td>
<td style="text-align: right;">0.8757</td>
</tr>
</tbody>
</table>
<p>For the pattern interventions, the held-out newline metrics are:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Intervention</th>
<th style="text-align: right;">Precision</th>
<th style="text-align: right;">Recall</th>
<th style="text-align: right;">Frequency</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Baseline</td>
<td style="text-align: right;">0.5220</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: right;">0.1029</td>
</tr>
<tr class="even">
<td style="text-align: left;">Attention to previous newline</td>
<td style="text-align: right;">0.4936</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: right;">0.1088</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Uniform attention over newline positions</td>
<td style="text-align: right;">0.5229</td>
<td style="text-align: right;">0.9209</td>
<td style="text-align: right;">0.0946</td>
</tr>
<tr class="even">
<td style="text-align: left;">Remove newline attention</td>
<td style="text-align: right;">0.5165</td>
<td style="text-align: right;">0.9735</td>
<td style="text-align: right;">0.1013</td>
</tr>
</tbody>
</table>
<p>The final table summarizes the same interventions on true newline targets, using changes in newline logit and newline margin. The absolute-change columns record the magnitude of the change without regard to sign.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Intervention</th>
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?%5CDelta"> NL logit</th>
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?%7C%5CDelta%7C"> NL logit</th>
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?%5CDelta"> NL margin</th>
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?%7C%5CDelta%7C"> NL margin</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Baseline</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: left;">Mean newline values</td>
<td style="text-align: right;">0.369</td>
<td style="text-align: right;">2.533</td>
<td style="text-align: right;">0.357</td>
<td style="text-align: right;">2.589</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Shuffled newline values</td>
<td style="text-align: right;">−0.061</td>
<td style="text-align: right;">2.853</td>
<td style="text-align: right;">−0.089</td>
<td style="text-align: right;">2.919</td>
</tr>
<tr class="even">
<td style="text-align: left;">Zeroed newline values</td>
<td style="text-align: right;">−1.137</td>
<td style="text-align: right;">2.754</td>
<td style="text-align: right;">−1.179</td>
<td style="text-align: right;">2.830</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Previous-newline attention</td>
<td style="text-align: right;">0.552</td>
<td style="text-align: right;">0.632</td>
<td style="text-align: right;">0.562</td>
<td style="text-align: right;">0.646</td>
</tr>
<tr class="even">
<td style="text-align: left;">Uniform newline attention</td>
<td style="text-align: right;">−2.091</td>
<td style="text-align: right;">2.256</td>
<td style="text-align: right;">−2.148</td>
<td style="text-align: right;">2.322</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Removed newline attention</td>
<td style="text-align: right;">0.103</td>
<td style="text-align: right;">1.981</td>
<td style="text-align: right;">0.088</td>
<td style="text-align: right;">2.025</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="conclusions" class="level2">
<h2 class="anchored" data-anchor-id="conclusions">Conclusions</h2>
</section>
<section id="further-directions" class="level2">
<h2 class="anchored" data-anchor-id="further-directions">Further Directions</h2>
</section>
<section id="my-takeaways" class="level2">
<h2 class="anchored" data-anchor-id="my-takeaways">My Takeaways</h2>


</section>

 ]]></description>
  <category>mechanistic interpretability</category>
  <guid>https://rbuluswar.github.io/posts/line-break-project/</guid>
  <pubDate>Tue, 13 Oct 2026 04:00:00 GMT</pubDate>
</item>
</channel>
</rss>
