Jet Expansions of Residual Computation

## Abstract

Abstract We introduce a framework for expanding residual computational graphs using jets , operators that generalize truncated Taylor series.
Our method provides a systematic approach to disentangle contributions of different computational paths to model predictions.
In contrast to existing techniques such as distillation, probing, or early decoding, our expansions rely solely on the model itself and requires no data, training, or sampling from the model.
We demonstrate how our framework grounds and subsumes logit lens ,
reveals a (super-)exponential path structure in the recursive residual depth and opens up several applications.
These include sketching a transformer large language model with n 𝑛 n italic_n -gram statistics extracted from its computations, and indexing the models’ levels of toxicity knowledge.
Our approach enables data-free analysis of residual computation for model interpretability, development, and evaluation. The project website can be found here .

## 1 Introduction

Machine learning models, particularly large-scale foundation models, have become increasingly prevalent and impactful across a wide range of domains (Wei et al., ; Bommasani et al., ; Touvron et al., ).
While delivering strong results, their black-box nature has led to the development of techniques to assess their behavior and gain insights into their internal mechanisms.
In this space, mechanistic interpretability (MI) (see e.g. Bereska & Gavves, ; Ferrando et al., , for recent surverys)
has emerged as an alternative to more classic local attribution methods such as SHAP (Lundberg, ) or integrated gradient (Sundararajan et al., ).
Contrary to these methods, which seeks to trace output behavior back to the network input, MI focuses on tracing behavior back to the model itself.
It seeks to uncover learned “algorithms” that are embedded in the model weights and computational structure, with the aim of developing a global understanding of – and, ultimately, to reverse engineer – neural computation.

The great majority of MI work uses a hypothesis-and-dataset-driven approach (see for example Goldowsky-Dill et al. ()), in that it first formalizes a hypothesis, then chooses or curates a dataset to probe the model, it applies techniques such as path patching (Wang et al., ) or causal tracing (Meng et al., ), and then possibly refines the initial hypothesis.
While this approach to MI is valuable, it can limit the ability to perform open-ended exploration-driven studies aimed at uncovering global behavior and charting “maps” that connect computation to behavior.
In this regard, studies such as Veit et al. () or Elhage et al. () focus on the intrinsic computation that is carried out by a model, offering complementary views to the hypothesis-and-dataset-driven approach.
Yet, these studies often make unrealistic assumptions of the model, making it unclear how much of the derived understanding can be transferred to real-world models and applications.

This paper contributes to this latter direction, presenting a general-purpose framework to manipulate the computational graph of a neural model with the aim of identifying individual input-to-output computational paths, which we can then further analyze to extract behavior.
Our method is based on the simple observation that we can recursively expand the computation of a network by selectively applying jet operators (Ehresmann, ), which one can think of as the functional counterpart of truncated Taylor series.
This process, which we call the jet expansion of a model, gives rise to a class of equivalent functional rewritings of the original network into the sum of polynomial terms (which we see as input-to-output functions and dub jet paths) and non-linear remainders.
The framework does not make particular assumptions on the input model and, as it operates in the space of functions (rather than function evaluations), it requires no input data.
For transformer language models, we also show how specific instantiations linked to $n$-gram models make it feasible to exhaustively evaluate the jet paths over the entire input space, enabling end-to-end data-free global interpretability studies.

In this work, we focus on residual networks (He et al., ) – particularly transformers (Vaswani et al., ) – and operate at the granularity of residual blocks (e.g., self-attention or MLP blocks).
This approach simplifies our presentation, while aligning with previous literature such as (Veit et al., ), and maintains practical relevance given the prevalence of residual networks for real-world applications.
We describe several instantiations of our framework in Section 4, showing how it encompasses previously proposed interpretability tools such as the logit lens (nostalgebraist, ).
Based on these instantiations, we present an extensive set of case studies on several auto-regressive large language models (LLMs) from varying families and sizes, including GPT, Llama and OLMo.
Our case studies demonstrate jet expansion offers a suite of powerful tools – jet lens, jet paths and jet $n$-grams – to perform multi-scenario LLM interpretability: i) understanding the inner working of an LLM (Section 5.1); ii) debugging the pretraining dynamic (Section 5.2); and iii) examining fine-tuning effects (Section 5.3), which are useful for improving transparent and responsible usages of LLMs.
We close with a discussion about the potential directions of future research that this work opens, alongside its current limitations.

## 2 Residual networks and their rewritings

We start by reviewing the archetypal computational structure of residual networks and discuss the case of linear residual networks as a canonical example of functions that are intrinsically expanded.

#### Residual networks.

We focus on network architectures whose main body consists of multiple recursive residual blocks, while the input and output are managed respectively by an encoding and a decoding module.
Let $\mathcal{Z}$ be an input space (e.g., sequences of tokens), $c\in\mathbb{N}^{+}$ be the number of classes (e.g., a vocabulary size), $\mathcal{Y}=\mathbb{R}^{c}$ be a space of output logits and $d\in\mathbb{N}^{+}$ be a hidden dimension.
Formally, we are concerned with functions $q:\mathcal{Z}\to\mathcal{Y}$ described as follows:

$$ $q=\upsilon\circ h_{L},\quad\text{where }\,h_{L}:\mathcal{Z}\to\mathbb{R}^{d}, \;\;h_{L}=\bigcirc_{l=1}^{L}\beta_{l}\circ\eta,$ (1) $$

where $L\in\mathbb{N}^{+}$ is the number of residual blocks (e.g. recursive depth), $\eta:\mathcal{Z}\to\mathbb{R}^{d}$ is an input encoding module (e.g. token embedding layer), $\bigcirc$ denotes repeated functional composition, and

$$ $\displaystyle\textstyle\beta_{l}$ $\displaystyle:\mathbb{R}^{d}\to\mathbb{R}^{d}\quad\text{for }\,l\in[L]$ $\displaystyle\beta_{l}$ $\displaystyle=\mathrm{id}+\gamma_{l},$ $\displaystyle\gamma_{l}:\mathbb{R}^{d}\to\mathbb{R}^{d},$ (2) $\displaystyle\upsilon$ $\displaystyle:\mathbb{R}^{d}\to\mathcal{Y}$ $\displaystyle\upsilon(x)$ $\displaystyle=U\,\gamma_{L+1}(x)$ $\displaystyle U\in\mathbb{R}^{c\times d},\,\gamma:\mathbb{R}^{d}\to\mathbb{R}^ {d},$ (3) $$

are respectively residual blocks with nonlinearities $\gamma_{l}$’s (e.g., input-normalized causal self-attentions or MLPs), and the output decoding module (e.g., an unembedding projection $U$ after a layer normalization $\gamma_{L+1}$); $\mathrm{id}$ is the identity map.
We leave all parameters implicit and assume all functions are $C^{\infty}$.
Optimized for classification (e.g., next token prediction for autoregressive language models), the function $q$ outputs unnormalized conditional probabilities (or logits) in that $\mathbb{P}_{q}(\text{``$z$ belongs to class $i$''}|z)=\mathrm{Softmax}[q(z)]_{i}$, for $z\in\mathcal{Z}$.
In residual networks, the recursive links allow the “storage” of computation from all previous layers and the embedded input, leading to an accumulation of information across depths.
This is highlighted by unrolling the computation of Equation 1 up to a block $l\in[L]$, setting $h_{0}=\eta$:

$$ $\textstyle h_{l}=\bigcirc_{j=1}^{l}\beta_{j}\circ\eta=\eta+\sum_{j=1}^{l} \gamma_{j}\circ h_{j-1};\quad q=\upsilon\circ\eta+\sum_{l=1}^{L}\upsilon\circ \gamma_{l}\circ h_{l-1}$ (4) $$

Elhage et al. () introduces the term residual stream to describe $h_{l}$, a concept that can be traced back to Hochreiter & Schmidhuber () and Srivastava et al. ().
Veit et al. () describe and study the unrolled structure of the final residual stream $h_{L}$, which reveals a number of paths from the input to the decoder that grows linearly with the network depth.

#### Linear residual networks.

The presence of non-linearities at each block (and at the decoding module) prevents us from directly expanding the input-to-output computation further.(^1^11One can still recover an exponential expansion of gradient paths when considering $\nabla q$, e.g. to analyze behavior during training, as Veit et al. () do. In this work, however, we solely focus on the forward dynamic of the network.)
Linear residual networks, represented in Equation 5,
do not have this impediment. Indeed, if $\gamma_{i}(x)=A_{i}x$ for some $A_{i}\in\mathbb{R}^{d\times d}$, $\eta=E$ and $\gamma=\mathrm{id}$, we have that

$$ $\textstyle q=U(\sum_{S\in 2^{[L]}}\prod_{j\in S}A_{j})\,E=\sum_{S\in 2^{[L]}}q _{S}$ (5) $$

where $2^{[L]}$ is the power set of $[L]=\{1,\dots,L\}$ and the $q_{S}=U(\prod_{j\in S}A_{j})E=UW_{S}E$, with $W_{\emptyset}=I$. Equation 5 writes (“expands”) the linear network into a combination of $2^{L}$ input-to-output paths $q_{S}:\mathcal{Z}\to\mathcal{Y}$, themselves linear functions. This enables a detailed analysis of each path’s contributions (e.g. one may look at the norm of each $W_{S}$ as a measure of global path importance), roles, and interactions, as well as understanding global input-output relationships.

Figure: Figure 1: Various equivalent representations of a two-blocks linear residual network. In particular (b) highlights the residual stream of eq. 4; (d) highlights the exponential rewriting of Equation 5.
Refer to caption: x1.png

## 3 Recursive expansion of residual networks with jets

To tackle non-linearities and enable expansions in general residual networks similar to that of Equation 5, we turn to jets (Ehresmann, ), which generalize Taylor expansions. In this section, we first introduce key concepts pertaining jets that are instrumental in developing our framework. Then we move to develop jet_expand, the general algorithm for expanding residual nets into atomic input-output computational paths.

#### Jet operators and their convex combinations

We recall that, for a function $f\in C^{k+1}(\mathbb{R}^{d},\mathbb{R}^{d})$ and $x,y\in\mathbb{R}^{d}$, Taylor’s theorem asserts that

$$ $\textstyle f({\color[rgb]{0,0,1}y})=f({\color[rgb]{1,0,0}x})+\textstyle\sum_{j =1}^{k}(j!)^{-1}\mathrm{D}^{j}f({\color[rgb]{1,0,0}x})({\color[rgb]{0,0,1}y}-{ \color[rgb]{1,0,0}x})^{\otimes j}+O(\|{\color[rgb]{0,0,1}y}-{\color[rgb]{1,0,0 }x}\|^{k+1})$ (6) $$

where ${\color[rgb]{1,0,0}x},{\color[rgb]{0,0,1}y}$ are respectively the center and variate, $\mathrm{D}^{j}$ denotes the $j$-th differential, $(y-x)^{\otimes j}$ denotes the $j$-fold tensor product, and $O(\|y-x\|^{k+1})$ denotes the class of functions that vanish at least as fast as a degree-$(k+1)$ polynomial $M\|y-x\|^{k+1}$ as $y\to x$ for some $M>0$.
The $k$-th order jet operator of a function $f$ maps vectors to equivalence classes of degree-$k$ polynomial functions (we denote the resulting quotient space by $P^{k}$ in the equation below, details in the appendix) as follows:

$$ $\textstyle\mathrm{J}^{k}f:\mathbb{R}^{d}\to\mathrm{P}^{k}\quad\quad\mathrm{J}^ {k}f({\color[rgb]{1,0,0}x})=f({\color[rgb]{1,0,0}x})+\textstyle\sum_{j=1}^{k}( j!)^{-1}\,\mathrm{D}^{j}f({\color[rgb]{1,0,0}x}).$ (7) $$

Evaluating the jet at a variate ${\color[rgb]{0,0,1}y}\in\mathbb{R}^{d}$ yields the truncated Taylor expansion $\mathrm{J}^{k}f({\color[rgb]{1,0,0}x})({\color[rgb]{0,0,1}y})\in\mathbb{R}^{d}$, that is, Equation 6 without the “$O$” term.
The main advantage of working with jets rather than Taylor expansions is that we can work directly with functions rather than vectors.
We will make extensive use of the following lemma, of which the proof can be found in the appendix, along with further details about jets.

###### Lemma 1 (Convex combinations of jets) .

Let $f\in C^{\infty}(\mathbb{R}^{d},\mathbb{R}^{d})$, $k\in\mathbb{N},N\in\mathbb{N}^{+}$, $\{{\color[rgb]{1,0,0}x_{i}}\}_{i\in[N]}$ be a set of *jet centers*, $w\in\triangle^{N-1}\subset\mathbb{R}^{N}$ be a set of *jet weights*, and
$r=\max_{i}\{w_{i}\|x_{i}-\sum_{j}x_{j}\|\}$. Then

$$ $\textstyle\mathrm{J}^{k}f\left({\color[rgb]{1,0,0}\sum_{i=1}^{N}x_{i}}\right)= \sum_{i=1}^{N}w_{i}\mathrm{J}^{k}f({\color[rgb]{1,0,0}x_{i}})+O(r^{k+1}).$ $$

###### Remark 1 (Jet centers and variates as functions) .

We will often want to trace the computation of a jet back to the input space $\mathcal{Z}$.
In such cases, we interpret the jet centers ${\color[rgb]{1,0,0}x}$’s and the variates ${\color[rgb]{0,0,1}y}$’s as functions of the original network input $z\in\mathcal{Z}$ onto $\mathbb{R}^{d}$ or $\mathcal{Y}$.
Thus, we have that $\mathrm{J}^{k}f({\color[rgb]{1,0,0}x})({\color[rgb]{0,0,1}y}):\mathcal{Z}\to
\mathbb{R}^{d}$ (or $\mathcal{Y})$ which evaluates as follows: $\mathrm{J}^{k}f({\color[rgb]{1,0,0}x})({\color[rgb]{0,0,1}y})(z)=\mathrm{J}^{k
}f({\color[rgb]{1,0,0}x(z)})({\color[rgb]{0,0,1}y(z)})$.

###### Lemma 1 (Convex combinations of jets) .

###### Remark 1 (Jet centers and variates as functions) .

#### Exponential expansion of a two-blocks network.

Before introducing the main algorithm, we start with a minimal example of an expansion of a network with two residual blocks into four input-to-output paths. The network, represented in Figure 2 (a) and (a-bis), is given by:

$$ $q=\upsilon\circ h;\quad h_{2}=\beta_{2}\circ\beta_{1}\circ\eta=\eta+\gamma_{1} \circ\eta+\gamma_{2}\circ(\eta+\gamma_{1}\circ\eta)$ (8) $$

The final residual stream $h_{2}$ is a sum of three terms (input-to-hidden-space functions).
In a transformer network, $\gamma_{1}$ could represent a self-attention block and $\gamma_{2}$ an MLP block – typically both transformations being input-normalized.
Critically, the last term $\gamma_{2}\circ(\eta+\gamma_{1}\circ\eta)$ does not allow us to directly single out contributions that involve $\gamma_{2}$ and $\eta$ or $\gamma_{1}\circ\eta$ alone.

Figure: Figure 2: Representation of a two-blocks residual net (a, a-bis) and its exponential expansion steps (b, c).
Refer to caption: x2.png

To recover such paths, we can jet-expand $\beta_{2}$ and apply Lemma 1 choosing as centers $x_{\emptyset}=\eta$ and $x_{\{1\}}=\gamma_{1}\circ\eta$, obtaining:

$$ $\displaystyle\mathrm{J}^{k}\beta_{2}(x_{\emptyset}+x_{\{1\}})=$ $\displaystyle w_{1}\mathrm{J}^{k}\beta_{2}(x_{\emptyset})+w_{2}\mathrm{J}^{k} \beta_{2}(x_{\{1\}})+O(r^{k+1})$ (9) $\displaystyle=$ $\displaystyle x_{\emptyset}+x_{\{1\}}+w_{1}\mathrm{J}^{k}\gamma_{2}(x_{ \emptyset})+w_{2}\mathrm{J}^{k}\gamma_{2}(x_{\{1\}})+O(r_{\beta_{2}}^{k+1}),$ $$

where the last equality holds for $k\geq 1$. (^2^22For $k=0$ the weights apply also to the center terms since $\mathrm{J}^{0}\mathrm{id}(x_{\{1\}}+x_{\{2\}})=w_{1}x_{\{1\}}+w_{2}x_{\{2\}}+O (r^{1})$.)
This operation is represented in Figure 2 (b).
These terms still do not yield input-to-output paths, as in general $\gamma_{3}\neq\mathrm{id}$ (in transformer architecture this is typically a normalization operation, e.g. layer norm).
We can again proceed with a jet expansion, this time of the decoding module $\upsilon=U\,\gamma_{3}$.
Continuing with our example, we apply Lemma 1 using as centers the outputs of the previous expansion, namely $x_{\emptyset}$, $x_{\{1\}}$, $x_{\{2\}}=w_{1}\mathrm{J}^{k}\gamma_{2}(x_{\emptyset})$ and
$x_{\{1,2\}}=w_{2}\mathrm{J}^{k}\gamma_{2}(x_{\{1\}})$, obtaining

$$ $\textstyle\mathrm{J}^{k}\upsilon(x_{\emptyset}+x_{\{1\}}+x_{\{2\}}+x_{\{1,2\}} )=\sum_{S\in 2^{[2]}}\omega_{1}U\,\mathrm{J}^{k}\gamma_{3}(x_{S})+O(r_{ \upsilon}^{k+1})$ (10) $$

where $\omega\in\Delta^{3}$ is a vector of jet weights.
With this operation, represented by Figure 2 (c), we have obtained four input-to-output paths, mimicking the exponential rewriting of the linear case; cf. Equation 5.
For instance, the zeroth order ($k=0$) path that passes through the second non-linearity only, skipping the first, is given by the function
$z\in\mathcal{Z}\to\omega_{3}U\,\gamma_{3}(w_{1}\gamma_{2}(\eta(z)))\in\mathcal
{Y}$.
This example demonstrates the key principles of our approach: recursive expansion of the computational graph using jets, and the use of convex combinations to isolate specific paths. However, for deeper networks with many blocks, manually expanding each layer becomes impractical. To address this, we generalize this process into an algorithmic framework, which we develop next.

Figure: Algorithm 1 jet_expand($q$, $l$, $\mathcal{C}$, $k$)

#### The jet-expand algorithm.

Algorithm 1 presents the key operation of the framework.
The algorithm applies Lemma 1 to a residual transformation or to the decoding non-linearity for a given (user-defined)
set of centers $\mathcal{C}$.
It yields a set of expanded polynomial terms $\xi$, which can be seen as a set-valued function $\xi:\mathcal{Z}\times\triangle^{N-1}\to\mathcal{E}$,
where $\mathcal{E}$ is an appropriate power set of functions,
and a non-linear remainder $\delta:\mathcal{Z}\times\triangle^{N-1}\to\mathbb{R}^{d}$.
The remainder encompasses both the residuals stemming from Equation 6 and Lemma 1.
As we showed above, centers can be the outputs of previous expansions, enabling the propagation of the expansion through the entire network and effectively ’unrolling’ the computation graph into distinct paths.
Importantly, once we apply the algorithm for $l=L$ we obtain a way to rewrite the computational graph of $q$ as a sum of expanded terms (input-to-output paths), which we call expansion, and a non-linear remainder.
Indeed, if $(\xi_{L},\delta_{L})=$jet_expand$(q,L,\mathcal{C},k)$ for some $\mathcal{C}$ and $k$, the following class of functional equivalences holds:

$$ $\textstyle q=\sum_{e\in\xi_{L}}U\,e(\cdot,w)+\delta_{L}(\cdot,w)\qquad\text{ for }w\in\triangle^{N-1}.$ (11) $$

The runtime of Algorithm 1 is negligible as it operates at the level of the computational graph.
Evaluating $\xi$ (and $\delta$) at any $z\in\mathcal{Z}$, instead, incurs a runtime complexity of $O(|\mathcal{C}|(F+kB))$ where $F$ and $B$ are the costs of a forward and a backward evaluation of $q$, respectively.
In practice runtime can be reduced by storing computation (Griewank & Walther, ; Bettencourt et al., ).
In next section we discuss how particular instantiations of our framework encompass previous studies and let us seamlessly define novel objects of interest such as $n$-gram statistics of LLMs.
Before that, we conclude the section with two remarks regarding remainders and jet weights.

###### Remark 2 (Non-vanishing remainders) .

In general, we cannot expect reminders to vanish (as $k$ grows). Indeed, even if the convergence radius of the Taylor series is infinite, the arguments of residuals introduced by applications of Lemma 1 do not vanish.
If $q$ is a linear residual network, however, $\delta=0$ for $k\geq 1$, showing that Algorithm 1 recovers (after reorganizing terms) the rewrite of Equation 5 for every choice of $w$. (^3^33Other special cases include expansions where each center set is a singleton and the convergence radius of the expanded non-linearities is infinite.)
Hence, in light of Equation 11, jet expansions should be seen as ways to rewrite computational graphs rather than approximations; in experiments we show however how $\delta$’s can be small and the cosine similarity between expansion and original network logits can be close to 1; see Figure 3 (bottom).

###### Remark 3 (Jet weights optimization) .

So far we glossed over the role of the jet weights $w$’s. In principle, these can be fixed, e.g. $w_{i}=1/N$.
However, jet weights can also be optimized to minimize the remainder at any given $z$, e.g. after projecting it into the logit space.
Interesting, this can be done cheaply as $\|U\delta_{L}(z,w)\|^{2}=\|\gamma_{L}(h_{L}(z))-\sum_{e\in\xi_{L}}§e(z,w)\|^{2
}_{U^{T}U}$, which amounts to the squared distance between the expansion and the original residual stream in the representation space $\mathbb{R}^{d}$ with the metric induced by the unembedding matrix.

###### Remark 2 (Non-vanishing remainders) .

###### Remark 3 (Jet weights optimization) .

## 4 Notable expansions and their implications

We introduce some particular expansions as application of the introduced jet_expand algorithm, setting the stage for the numerical case studies of the next section.

#### (Super)exponential expansion.

Algorithm 2 generalizes the exponential expansion we performed onto the two-blocks network in Section 3, using uniform jet weights.
One can interpret the algorithm as performing a “maximal” expansion (when remaining at the grain of the blocks) which yields $2^{L}$ input-to-output paths.
In fact, for $k\geq 1$, we can further isolate each degree of the expanded terms into separate input-to-output paths that highlight interactions among various blocks.
This further refinement, which we will focus on in future work, may suggests that residual networks may in fact behave as super-exponential ensembles of (shallower) functions.

#### Jet lenses and logit lens.

The logit lens (nostalgebraist, ; Geva et al., ; ; Merullo et al., ; Belrose et al., ) is an interpretability method that consists in applying the decoder to intermediate representations as follows:

$$ $\textstyle\mathrm{LogitLens}_{l}(z)=U\gamma(h_{l}(z))=\mathrm{J}^{0}\upsilon(h _{l}(z))(h_{L}(z)).$ $$

The logit lens, aimed at highglighting the iterative refinement of the prediction across blocks,
is related to early exiting (or early decoding) in the context of conditional computation (see e.g. Panda et al., ; Elbayad et al., ; Geva et al., ).
It is immediate to verify that $\mathrm{LogitLens}_{l}$
is equivalent to the expansion yielded by jet_expand$(q,L,\{h_{l}\},0)$.
This suggests two generalizations, which we dub iterative and joint jet lenses, respectively.
The iterative jet lens is a direct extension of the logit lenses with higher order jets: jet_expand$(q,L,\{h_{l}\},k)$. The joint jet lenses are expansions obtained through jet_expand$(q,L,\{\gamma_{l}\circ h_{l-1}\}_{l\in[L]},k)$ that are aimed at highlighting the residual contributions of each block non-linearity, rather than the iterative refinement of the residual stream.

#### Jet bi-grams and skip- n 𝑛 n italic_n -grams statistics.

We consider transformer-based large language models with alternating self-attentions and MLPs, which are particular instances of residual nets. (^4^44We disregard positional embeddings for simplicity and leave their study to future work.)
Our framework allows us to directly extract $n$-gram statistics from an existing LLM without any probing datasets.
Concretely, we can systematically evaluate relevant jet paths (for small $n$’s) on the entire input space, usually the vocabulary and its Cartesian products, independently from individual contexts.
For example, bi-grams statistics related to $\mathbb{P}_{q}(z_{2}|z_{1},\dots)$ can be computed by evaluating bi-gram paths, which we can obtain by expanding the LLM with Algorithm 2 and filtering out all paths that involve self-attention modules.
Specifically in our case studies (Section 5), we focus on encoding-decoding bi-gram path, obtainable via expanding the LLM with jet_expand$(q,L,\{\eta\},k=0)$, and the bi-gram paths involving up to one MLP module, which can also be obtained via applying Algorithm 1 twice.
We can obtain skip-$n$-gram statistics relating to $\mathbb{P}_{q}(z_{n}|z_{n-1},\dots,z_{n-2},\dots,z_{1},\dots)$, where dots indicate any number of interceding tokens, by evaluating jet paths with self-attentions (the fewer self-attentions, the lower the $n$) and isolated single query-key products.
Such jet $n$-gram statistics offer a *data-free* tool to sketch LLMs via casting them into (symbolic) $n$-gram databases.
Thus they allows us to perform symbolic model diffing between any two models that share a common vocabulary,
as opposed to take differences in the parameter space, harder to interpret and only possible for same-architecture models.

## 5 Interpreting LLMs with jet expansions

Our framework provides users with freedom in terms of choosing the computational paths they wish to focus on.
Jet expansions support studies across various levels, including model-level global analysis (jet $n$-grams), component-level analysis (jet paths), and example-level analysis (jet lens).
We experiment with several popular open-sourced large language models families: GPT-2 (Radford et al., ), GPT-Neo Black et al. (), Llama (Touvron et al., ; ; Rozière et al., ) and OLMo (Groeneveld et al., ), showcasing the generality of the algorithm.
Our main experiments run on $128$ CPU servers with $1$ TB memory, while jet lens experiment run on a single laptop.

### 5.1 Analyzing LLM inner working

LLMs are notorious for their lack of interpretability due to their inherent model complexity and size, made worse by the usual opaque training process and unknown training data. Understanding their inner working contributes to calibrating trust for users to use them appropriately. We showcase how jet expansion along user-selected computational paths (jet paths) can help us discover and locate learned associations akin to studies in mechanistic interpretability Templeton et al. ().

#### Jet lenses.

Figure: Figure 3: (Top) example of a joint jet lens on GPT-Neo $2.7$B with $k=1$, visualizing the seven blocks with highest average jet weights after optimization. Each table cell indicates the most likely token of the jet path related to each block non-linearity. Optimized jet weight are in brackets. We used a diverging blue-to-red color map tracking logit scores, centered around zero. The bottom table shows the model logits and the expansion logits, with cosine similarity in brackets; in this case, all top-$1$ tokens perfectly coincide. (Bottom) plots of average cosine similarities between original and jet logits of joint (left) and iterative (right) lenses.
Refer to caption: x3.png

We use jet lenses introduced in Section 4 to analyze LLM’s mechanism when processing individual examples.
Figure 3 (top) visualize a joint jet lens for GPT-Neo 2.7B (Black et al., ) (other examples can be found in Appendix C).
Here, a block contains one self-attention and one MLP module.
All table cells depict top-$1$ tokens for the corresponding path, following conventions from prior work (Belrose et al., ).
We observe that the joint jet lens captures the synergy among different blocks, as the model prediction is decomposed into several jet paths.
Our preliminary analysis supports recent work on super-position (Elhage et al., ) and neuron polysemy (Bricken et al., ), suggesting that interactions among components may have ensemble effects, which can broadly vary across model families.
In this sense, the jet lenses with $k>0$ may serve as tools to systematically discover such synergic behaviors.
We also find that higher-orders ($k>0$) help iterative lenses deliver more meaningful interpretations than the logit lens ($k=0$) for GPT-Neo-$2.7$B (see Figures 6, 7 and 8). This is potentially due to their capability to trace indirect impacts of early layers on the final logits, which were otherwise missing under logit lens.
Our findings are consistent with  nostalgebraist (); Cancedda () where naive implementations of logit lens are shown to fail on GPT-Neo model family.
Figure 3 (bottom) present mean cosine similarities of joint and iterative jet lenses for various GPT models and orders, averaged over $100$ example sentences.
The similarities are high and close to $1$ for various $k$, showing however different behavior across model families and sizes. This indicates jet expansions highly correlate with model outputs, potentially providing faithful interpretations.

#### Jet paths of individual components.

By examining the representative jet bi-grams that are captured by each MLP path, we find some MLPs that perform special linguistic functions.
For example, in OLMo-$7$B, the jet path which passes through the $3$rd MLP promotes the addition of the “-ing” suffixes to the current token.
Similar MLPs with certain linguistic functions are listed in Table 1. Note that the relationship between functions and components are not necessarily one-to-one mappings.
Particularly we find that the paths through multiple MLPs might work together to complete one linguistic function e.g.
MLP $6$ and MLP $18$ in Llama-$2$-$7$B can add “-ing” suffix. One MLP might also do multiple linguistic jobs e.g. MLP $1$ in OLMo 7B adding “-ly” and “-▁else” suffixes. This echos work on circuit discovery (Conmy et al., ; Ferrando & Voita, ) and superposition (Elhage et al., ), where the role of each component cannot be easily dissected and multiple components collaborate to fulfill a function.
Table 2 reports a role identification study on attention heads in the first self-attention of OLMo-$7$B using jet tri-grams.
Specifically, we find heads associated with math and programming, e.g. head $1$ on Math/Latex; heads promoting digits and dash composition into dates, e.g. head $25$; and heads constituting phrase templates, e.g. head $15$ managing a “for $x$ purposes”, where $x$ is a placeholder.
To verify the roles we revealed, we further perform preliminary intervention experiments where we ablate MLPs or attention heads and compute variations in model logits.
After the interventions, the logits drop consistently in all cases, suggesting our jet $n$-grams indeed can help identify certain roles for selected components.
Varying impact on logit differences is likely due to overdetermination (Mueller, ) and our partial selection of jet paths (e.g. for tri-grams we only selected encoding-attention-decoding paths, excluding any MLP).

**Table 1: MLPs in OLMo-$7$B and Llama-$2$-$7$B performing certain linguistic functions based on jet bi-grams extracted from the corresponding jet paths.**
|  | OLMo-$7$B | Llama-$2$-$7$B |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| MLP Index | $1$ | $3$ | $9$ | $17$ | $19$ | $6$ | $7$ | $18$ | $19$ |
| Role | -ly, -▁else | -ing | -’t | -▁than | -s | -ing | -es | -ing,-ity | -ly |
| $\Delta$ logit after intervention | $-4.19,-3.35$ | $-0.58$ | $-9.73$ | $-4.26$ | $-7.42$ | $-14.61$ | $-3.55$ | $-9.69,-11.93$ | $-9.14$ |

**Table 2: Several attention heads in the first residual block of OLMo-$7$B and their roles identified with jet tri-grams extracted from corresponding jet paths. We also include an example tri-gram captured by each head.**
| Head Index | $2$ | $16$ | $26$ | $30$ |
| --- | --- | --- | --- | --- |
| Role | Math/LaTeX | “for …purposes” | date composition | “into account/consideration …” |
| Example 3-gram | (▁Lemma, ▁let, ▁s) | (▁for, ▁use, ▁purposes) | (20, 23, ▁-) | (▁into, ▁account, ▁possible) |
| $\Delta$logit after intervention | $-0.1570$ | $-0.0019$ | $-0.0093$ | $-0.0001$ |

### 5.2 Analyzing pretraining dynamics

Pretraining an LLM is usually extremely resource intensive.
Therefore it is crucial to monitor the progress of a pretraining run to prevent wasting of time and compute.
In this section, we show how jet bi-grams can serve as an effective signaling tool to trace the pretraining dynamics, providing insights about the model’s maturity. Such signals are especially useful to understand what happens with the model when the pretraining loss shows marginal improvements and fails to reflect the changes inside the model.

#### Identifying the top bi-grams.

To assess the model’s progression, we extracted jet bi-grams from OLMo-7B model checkpoints across $555$K pretraining steps. Table 4 presents a summary of the top $10$ jet bi-grams at different stages of training. Due to space reason, we only show the top $10$ jet bi-grams every $100$K steps. Initially, the network exhibits nonsensical jet bi-grams, such as “ICUirling”.
As training advances, it gradually learns more meaningful combinations, like “at least”. This process of acquiring sensible bi-grams stabilizes around step $200$K, indicating that the model is reaching a level of maturity where the top $10$ bi-grams capture common meaning.

#### Analyzing bi-grams learning speed.

To evaluate the learning speed of these jet bi-grams, we consider the jet bi-grams at the final training step ($555$K) as the ground-truth bi-grams.
We then chart the hit ratios of these ground-truth bi-grams at each pretraining step, as illustrated in Figure 4(a). Interestingly, even though the pretraining loss (the blue curve) shows only minor improvements after the initial $50$K steps, the model’s acquisition of effective bi-grams continues to progress in a steady, consistent manner. This observation aligns with known phenomena in neural network training, such as double-descent and grokking, which highlight the model’s ability to improve generalization capabilities even when the loss appears to stagnate (Zhang et al., ; Power et al., ).
In addition, Figure 4(b) characterizes the total pseudo-joint probability mass of top $1$K bi-grams from empirical data (Liu et al., ).
We derive a pseudo-joint jet bi-gram probability using statistical uni-grams from (Liu et al., ).
We observe that the model gradually accumulates probability mass that aligns with the real corpus data distribution.

Figure: (a) Top $1$K jet bi-gram hit ratios w.r.t. the final step.
Refer to caption: x5.png

#### Learning schemes for different bi-grams.

To understand if there are any differences between the learning schemes of different bi-grams, we can trace the progression of the jet bi-gram scores for selected bi-grams. Figure 5 provides a visual comparison of how different bi-grams are promoted or suppressed during the pretraining process.
The different slopes and levels of the lines indicate varying rates of learning for the respective bi-grams.
We observe that, the model first acquires random bi-grams due to random parameter initialization. These random bi-grams, like “ICUirling” and “VENT thanks”, are quickly suppressed in the early steps and never regain high scores.
In contrast, one-to-many bi-grams like “at least” are first promoted to very high scores but then get suppressed perhaps due to the model seeing more of the scope of the token “at”. One-to-one bi-grams like “&amp” (HTML code) are gradually promoted and stabilize.
Many-to-many bi-grams like “make sure” takes the most time to learn and the scores are still increasing even at the end of pretraining.
Our findings suggest that the training process effectively promotes certain “good” bi-grams, but at different paces, where they might be suppressed later depending on their occurrences and linguistic nature. These insights could inform future training strategies, such as targeted training on more relevant bi-grams or adjusting the training data to improve the pretraining speed.

Figure: Figure 5: Visualization of OLMo-$7$B’s promotion and suppression dynamics of jet bi-grams scores.
Refer to caption: x7.png

### 5.3 Analyzing fine-tuning effect

Fine-tuning is an important phase where the raw pretrained LLMs are guided to perform particular tasks.
We would like to understand how the model inner knowledge changes during fine-tuning processes.
While parameter diffing can be a straightforward solution, jet n-grams provides an alternative approach, where the diffs are human readable and directly reflect the change of knowledge retained by the LLMs.
Such insights would allow us to better decide the mixture of data for fine-tuning, and the number of steps for fine-tuning, which are currently a mix of heuristics and trial-and-error.

#### Code fine-tuning promotes coding-relevant bi-grams.

We analyze the changes due to code fine-tuning via *diffing* jet bi-grams extracted from Llama-2-7B and its fine-tuned versions, Codellama-7B and Codellama-Python-7B. As highlighted in Table 5 with orange coloring, the jet bi-gram diff reveals coding-relevant keywords, such as “**kwargs”, “getters” and “Assertion”, suggesting jet bi-gram can be a tool for verifying if fine-tuning is effective in acquiring relevant knowledge.

**Table 3: Toxicity indexes for Llama-$2$-$7$B and Llama-$2$-$7$B-chat using different methods: ToxiGen, jet bi-grams, and RealToxicityPrompts challenge prompting. Higher numbers indicate higher toxicity scores on the corresponding benchmarks and higher toxic knowledge possession for jet bi-grams.**
|  | ToxiGen Score | Jet Bi-grams | RTP Challenging Prompts |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
|  | Hartvigsen et al. () | Mass of “toxic” bi-grams | No | Very mild | Medium | Hard |
| Llama-$2$-$7$B | $21.25$ | $0.03445$ | $38\%$ | $49\%$ | $64\%$ | $88\%$ |
| Llama-$2$-$7$B-chat | $0.0$ | $0.03377$ | $23\%$ | $35\%$ | $64\%$ | $84\%$ |

#### Does RLHF fine-tuning remove toxicity?

We compare the original pretrained model, Llama-2-7B, with its RLHF version, Llama-2-7B-Chat. RLHF alignment (Bai et al., ) is widely believed to detoxify LLMs, as indicated by the ToxiGen scores (Hartvigsen et al., ). However, it remains easy to prompt LLMs to bypass this alignment and produce toxic content.
In Table 3, we demonstrate this with dataset-based toxicity scores on a subset of challenging prompts in the RealToxicityPrompts (RTP) dataset (Gehman et al., ): the gap in toxicity potential between the two models narrows as we prepend to RTP prompts increasingly “explicit” (short) context.
Specifically, for hard context, Llama-2-7B-Chat shows an $84\%$ probability of producing toxic content, close to that of Llama-2-7B.
This suggests that the RLHF model is not completely detoxified but rather hides the toxicity knowledge from the “surface”, which however can be easily triggered by specific contexts.
To quantify the toxicity knowledge embedded in these models, we use jet bi-gram probability scores and calculate the cumulative conditional probability mass for a set of “toxic” bi-grams, which are combinations of tokens associated with toxic meanings from a predefined list of keywords.
Interestingly, we observe a small change in mass from $0.03445$ to $0.03377$ after RLHF.
Thus, although the ToxiGen score may suggest that the model has been effectively detoxified, the jet bi-gram mass reflects retention of toxic knowledge after RLHF, aligning with the scores obtained by introducing medium or hard explicit context and computing a toxicity score (via a second scorer model, (Hanu & Unitary team, )) on RealToxicityPrompts dataset (Gehman et al., ).
This showcases a potential application of jet bi-grams in constructing *data-free* indices that reveal embedded knowledge, offering complimentary views beyond traditional data-driven benchmark evaluations.

## 6 Related work

#### Interpreting transformers.

There has been much effort in interpreting the inner computations of transformer models. In particular, *mechanistic interpretability* Ferrando et al. (), focuses on reverse-engineering such computations by identifying, clustering and labelling model behavior (Shah et al., ; Meng et al., ; Bricken et al., ) in human understandable terms and attributing them with certain model components, e.g., MLPs Geva et al. (; ), or typical “circuits” (Conmy et al., ; Ferrando & Voita, ).
Authors discussed limitations of currents approaches to MI.
For example, Templeton et al. () found it generally hard to conclude neuron-level intepretabilities, compared with feature representations;
while Bolukbasi et al. (); Goldowsky-Dill et al. () points out that conclusions drawn are generally limited to the chosen data distribution.
As our approach focuses on manipulating functions, it does not require extra datasets that are used for probe fitting in methods such as Belrose et al. () nor sampling, as needed in (Conmy et al., ; Ferrando & Voita, ; Voita et al., ).
On a high level, allowing taking any portion of compute out of the original transformer, jet expansions abstract and generalize previous characterizations on the computational paths (Veit et al., ; Elhage et al., ), where non-linear components with significant roles, e.g. layernorm and MLPs, are either ignored or over-simplified for the ease of analysis.
Additionally, zero ablations (or knock out) (Olsson et al., ) and direct logits attributions (Wang et al., ) are linked to particular instantiations of zeroth order jet expansions.

#### n 𝑛 n italic_n -gram models.

The early applications of $n$-gram models in languages dates back to (Shannon, ), where $n$-grams modeled the statistics of English. The $n$-gram based approaches have been an important baseline in language processing, e.g., general language modelling (Goodman, ) with applications like machine translation (Brants et al., ). There have been regained interests on combining $n$-gram with neural network model-based approaches (e.g. Liu et al., ).
Several recent works have explored the relationships between LLMs and $n$-gram language models,
such as analyzing the representational capacity of transformers to simulate $n$-gram LMs (Svete & Cotterell, ) and measuring agreement between LLM predictions and $n$-gram rulesets (Nguyen, ).

#### Taylor expansion and jets

Taylor expansions are popular tools in analyzing learning behaviours (Jastrzebski et al., ), notably linearization ($k=1$). For example, Belrose et al. () applied Taylor expansion on the loss function to demonstrate the learning preference of neural network models. Xu et al. () introduced a second-order Taylor expansion over the data distribution to interpret optimal features.
The generalized jet notions was introduced in machine learning in the context automatic differentiation tools by Bettencourt et al. (), and is an experimental feature in Jax (Bradbury et al., ), but has been studied before (see e.g. Griewank & Walther, ).

## 7 Conclusion and discussion

We introduced jet expansion, a novel framework for expanding the computational graphs of neural networks.
The method, which we specialize in this paper to deep residual nets, can be used to disentangle contributions of user-selected computational paths from the overall graph.
Complementary to other dataset-dependent methods in MI, our method enables various dataset-free global interpretability studies, such as mapping computation to linguistic roles.
We have validated jet expansions in terms of cosine similarity against model outputs and through interventional experiments (Section 5.1).
We applied our data-free method to transformer LMs, showing how we can sketch the original model with input-output probability databases, extracting LM bi-and-tri-gram statistics.

#### Limitations.

Although rooted in Taylor series theory, expansions obtained via our frameworks do not (seek to) approximate the input function in any strict sense.
Rather, our framework is amed at facilitating interpretation of model behavior: we can use jet expansion to rewrite an input computational graph as a sum of “interpretable” polynomial terms and a (computable) remainder.
How large is a reminder and how expansions align with model outputs remains at the moment an empirical question, implying that the jet order and weight optimization routines should generally be considered as hyperparameters of the method.
Furthermore, expansions are not unique (but higher order expansions ”contain” lower order one).
We leave a deeper investigation of these aspects to future work.
From a runtime standpoint,
we note that even though graph manipulation is almost immediate, systematic evaluation of jet paths may be time consuming (especially for $k\gg 0$ and when optimizing jet weights).
If the input space is large, one may need to resort to sub-sampling or search heuristics.
Finally, we limited our study of $n$-gram expansions of LMs to bi-and-tri-grams, unearthing compelling behaviors. This leaves the study of longer-context expansions to future work.

#### Implications and future work.

Our work opens up several research directions.
From a theoretical standpoint, we will extend the expansion procedure to cover finer granularities, e.g. at neuron (subspace) levels; incorporate established attribution methods such as the Shapley value (Shapley et al., ), including recent extensions to deal with probabilistic models (Franceschi et al., ); develop concepts of (approximate) equivalence classes over models leveraging the jet spaces, which, in turn, may further ground the model diffing procedure sketched in our case studies.
Furthermore, we will take inspiration from the numerous tools in linear algebra to provide further depth into the analysis, deepening the link to linear residual structures and
establishing relations with Markov chains and hidden Markov models, recently employed e.g. by Zhang et al. () for constrained (structured) decoding.
We plan to investigate the implication of the super-exponential number of paths in the residual networks depth unearthed by Algorithm 2.
From an applications standpoint, besides studying jet $n$-grams for $n>3$, we envision several fruitful applications in safety and transparency, such as developing “search features” to systematically detect unwanted associations, or leaked private content.
Although our experiments are primarily observational, we speculate that jet_expand may also become an useful tool to guide interventions, supplementing other techniques like causal tracing (Meng et al., ) and path patching (Goldowsky-Dill et al., ).

## Appendix A Additional details on jets

A jet of a function represents an equivalence class. We thus can perform algebraic operations among functional equivalence classes using jet algebra stated below.

###### Proposition 1 (Jet algebra) .

Let $f,g\in C^{\infty}(\mathbb{R}^{d},\mathbb{R}^{d})$ and $k\in\mathbb{N}^{+}$. Then,

- (i)
$\mathrm{J}^{k}(af+bg)({\color[rgb]{1,0,0}x})=a\,\mathrm{J}^{k}(f)({\color[rgb]
{1,0,0}x})+b\,\mathrm{J}^{k}(g)({\color[rgb]{1,0,0}x})$, for $a,b\in\mathbb{R}$ (linearity);
- (ii)
$\mathrm{J}^{k}f({\color[rgb]{1,0,0}x})\circ g\in\mathrm{J}^{k}f({\color[rgb]{
1,0,0}x})$ and $\mathrm{J}^{k}f({\color[rgb]{1,0,0}x})\circ g(y)=\mathrm{J}^{k}f({\color[rgb]{
1,0,0}x})({\color[rgb]{0,0,1}g(y)})$ (jet after endomorphisms);
- (iii)
$g\circ\mathrm{J}^{k}f({\color[rgb]{1,0,0}x})=\{g\circ u\,:\,u\in\mathrm{J}^{k}
f(x)\}$ (endomorphism after jet);
- (iv)
$\mathrm{J}^{k}(f\circ g)({\color[rgb]{1,0,0}x})=\mathrm{J}^{k}f({\color[rgb]{
1,0,0}g(x)})\circ\mathrm{J}^{k}g({\color[rgb]{1,0,0}x})$ (composition of jets);

Properties (i)-(iii) follow directly from the definition; (iv) is a consequence of the chain rule and truncation.

###### Proposition 1 (Jet algebra) .

#### Proof of Lemma 1

Take $y\in\mathbb{R}^{d}$, $N\geq 1$, $x_{i}\in\mathbb{R}^{d}$ for $i\in[N]$, $w\in\triangle^{N-1}$ and an order $k\geq 0$.
Since $w$ belongs to the simplex $\triangle^{N-1}$, we have $\sum_{i=1}^{N}w_{i}=1$. Multiplying $f(y)$ on both hands, we obtain

$$ $f(y)=\sum_{i=1}^{N}w_{i}f(y)=\sum_{i=1}^{N}w_{i}\left[f(x_{i})+\sum_{s=1}^{k} \mathrm{D}^{s}f(x_{i})(y-x_{i})^{\otimes s}+O(\|y-x_{i}\|^{k+1})\right]$ $$

$$ $=\sum_{i=1}^{N}w_{i}\mathrm{J}^{k}f({\color[rgb]{1,0,0}x_{i}})({\color[rgb]{ 0,0,1}y})+O(w_{i}\|y-x_{i}\|^{k+1}),$ $$

by applying Equation 6 (Taylor expansion) and the definition of jet with each $x_{i}$ as the center.
At the same time, we can expand $f(y)$ with $\sum_{i=1}^{N}x_{i}$ as the center

$$ $f(y)=\mathrm{J}^{k}f({\color[rgb]{1,0,0}\sum_{i=1}^{N}x_{i}})({\color[rgb]{ 0,0,1}y})+O(\|y-\sum x_{i}\|^{k+1}).$ $$

Now let us take $y=\sum_{i=1}^{N}x_{i}$ and observe that $O(\|y-\sum x_{i}\|^{k+1})=0$ and
$O(w_{i}\|y-x_{i}\|^{k+1})=O(w_{i}\|x_{i}-\sum_{j}x_{j}\|^{k+1})$. Finally we observe that the class of functions in the last $O$ are dominated by the class of function in $O(r^{k+1})$ where $r=\max_{i}\{w_{i}\|x_{i}-\sum_{j}x_{j}\|\}$ is the maximum remainder.
This concludes the proof.

As a side note, jet weights would not need to form convex combinations, but rather linear combinations $\sum_{i}w_{i}=1$.
However, restricting to convex combinations has two major advantages:

- •
optimizing over a convex set guarantees the existence of maxima and minima (Weierstrass theorem) and uniqueness of minima if we are optimizing a strictly convex loss as in general is the case for expansions that only affect the decoder module.
- •
weights within the probability simplex have a clearer interpretation for interpretability purposes.

## Appendix B Additional Tables for Jet Bi-grams

See Table 4 and Table 5.

**Table 4: Bi-gram evolution across pretraining steps for OLMo 7B. Each column represents a distinct step, while each row corresponds to a different rank. The table entries are the bi-grams at each step for each rank. The number of tokens seen in association with the pretraining steps is also annotated. The model gradually picks up meaningful bi-grams after starting from senseless bi-grams (due to random initialization).**
| Rank | 0K [#steps] | 100K | 200K | 300K | 400K | 555K |
| --- | --- | --- | --- | --- | --- | --- |
| 0B [#tokens] | 442B | 885B | 1327B | 1769B | 2455B |  |
| 0 | immortal | ’s | at least | &amp | &amp | &amp |
| 1 | ICUirling | at least | ’s | at least | its own | its own |
| 2 | ords architect | its own | &amp | its own | their own | their own |
| 3 | yaml Adam | okerly | your own | your own | at least | his own |
| 4 | 231 next | VENT thanks | its own | their own | your own | make sure |
| 5 | clonal{CJK}UTF8gbsn条 | iums | iums | more than | his own | your own |
| 6 | Charg@{ | you’re | you’re | can’t | 2nd | 2nd |
| 7 | avoir careless | Everything v | 2nd | his own | more than | at least |
| 8 | HOLD worsening | erna already | you guys | 2nd | make sure | more than |
| 9 | Horse dismant | ’my | more than | make sure | can’t | iums |

**Table 5: The bi-grams before and after coding-finetuning. For space reason, we only show the bi-grams at every 50 ranks among the top 1000 bi-grams. We highlight the bi-grams that are relevant to coding, such as “**kwargs” a keyword in python programming. This demonstrate that our method has the capability to extract representative bi-grams that reflect fine-tuning quality.**
| Rank | LLAMA2-7B | CodeLLAMA-7B | CodeLLAMA-Python-7B |
| --- | --- | --- | --- |
| 0 | (▁more, ▁than) | (▁like, wise) | (▁like, wise) |
| 50 | (▁Now, here) | (▁just, ification) | (▁Like, wise) |
| 100 | (▁system, atically) | (▁in, ▁case) | (▁all, udes) |
| 150 | (▁all, erg) | (▁get, ters) | (▁no, isy) |
| 200 | (▁on, ions) | (któber, s) | (output, ted) |
| 300 | (▁other, world) | (▁all, ud) | (Object, ive) |
| 350 | (▁Just, ified) | (gebiet, s) | (▁as, cii) |
| 400 | (▁trust, ees) | (▁Protest, s) | (▁can, nab) |
| 450 | (▁at, he) | (▁deploy, ment) | (▁transport, ation) |
| 500 | (▁book, mark) | (Class, room) | (Tag, ging) |
| 550 | (▁from, {CJK}UTF8gbsn而) | (▁access, ory) | (▁personal, ized) |
| 600 | (▁WHEN, ever) | (▁In, variant) | (▁excess, ive) |
| 650 | (▁where, about) | (▁I, ▁am) | (▁Add, itional) |
| 700 | (ag, ged) | (add, itionally) | (▁**, kwargs) |
| 750 | (▁he, he) | (▁invalid, ate) | (name, plates) |
| 800 | (▁all, anto) | (div, ision) | (▁select, ive) |
| 850 | (▁Tom, orrow) | (▁process, ors) | (▁Assert, ions) |
| 900 | (▁for, ays) | (▁Program, me) | (blog, ger) |
| 950 | (▁Bach, elor) | (▁set, up) | (▁can, cellation) |

## Appendix C Additional plots of jet lenses

See plots below, referring to the main paper for details.
Note that for iterative lenses the last block coincides with the model logits for all $k$ by design.
We omit the iterative lens for GPT2-large for $k=2$ due to low cosine similarity.

Figure: Figure 6: Iterative jet lens ($k=0$), equivalent to logit lens(nostalgebraist, ), applied over GPT-Neo-$2.7$B with the input sentence “new simple neural architecture, the Transformer”.
Refer to caption: x8.png

Figure: Figure 7: Iterative jet lens ($k=1$), applied over GPT-Neo-$2.7$B with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x9.png

Figure: Figure 8: Iterative jet lens ($k=2$), applied over GPT-Neo-$2.7$B with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x10.png

Figure: Figure 9: Iterative jet lens ($k=0$), equivalent to logit lens(nostalgebraist, ), applied over GPT-2-large with the input sentence “new simple neural architecture, the Transformer”.
Refer to caption: x11.png

Figure: Figure 10: Iterative jet lens ($k=1$), applied over GPT-2-large with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x12.png

Figure: Figure 11: Joint jet lens with learnable weightings ($k=0$), applied over GPT2 with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x13.png

Figure: Figure 12: Joint jet lens with learnable weightings ($k=1$), applied over GPT2 with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x14.png

Figure: Figure 13: Joint jet lens with learnable weightings ($k=0$), applied over GPT-Neo-$2.7$B with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x15.png

Figure: Figure 14: Joint jet lens with learnable weightings ($k=1$), applied over GPT-Neo-$2.7$B with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x16.png

Figure: Figure 15: Joint jet lens with learnable weightings ($k=0$), applied over GPT-2-large with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x17.png

Figure: Figure 16: Joint jet lens with learnable weightings ($k=1$), applied over GPT-2-large with the input sentence “new simple neural architecture, the Transformer”
Refer to caption: x18.png

## Appendix D Runtime

We report in Figure 17 a plot of the runtime for evaluating expansions originating from the joint jet lenses of Section 5.1 as a ratio of the input model evaluation (forward pass), for both the uniform and the optimized jet weight setup, for different jet orders.

Figure: Figure 17: Empirical runtime of evaluations of jet expansions originating form the joint jet lenses as a ratio of the evaluation of the input model.
Refer to caption: x19.png

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 5
presentation: 4
questions: I have mostly raised them in the weakness section.
soundness: 3
strengths: Well-written and theoretically well-developed, with content that is thorough yet not overwhelming.
summary: The paper introduces a method for expanding residual networks, such as Transformers, using jets—operators that generalize truncated Taylor series. This approach aims to disentangle the contributions of individual computational paths to model predictions. The authors claim that their method subsumes the Logit Lens and demonstrate its ability to extract n-gram statistics from intermediate model layers, also enabling a data-free approach to detoxification.
weaknesses: I find the theoretical foundation to be solid, but my main concerns lie with the experimental approach.

The experiments may be overly empirical and lack statistical rigor. For instance, in Section 5.1, only a handful of jet paths corresponding to specific linguistic functions are selected to demonstrate intervention effects. A more systematic approach is needed to demonstrate that the jet lens is more effective than the logit lens.

While the paper primarily offers an analytical framework, it lacks actionable insights for model steering. For example, could it be demonstrated that the bi-gram statistics can be leveraged to guide more efficient pre-training or improve RLHF techniques for reducing toxicity?

---

confidence: 3
contribution: 3
initial_rating: 6
presentation: 2
questions: - Paragraph after eq (9): what is gamma_3? it is not defined or used in the figure. This seems important. Is it a hypothetical 3rd block? 
- Lemma 1: Unclear where w comes from. I have 3 hypotheses: (1) w is arbitrary and changes which member of the equivalence class you have (2) there is a specific value of w needed ("there exists a w...") (3) there's a typo and the LHS should be a weighted sum of x. This needs to be explicit.
- What is the point of tthe if l < L in Algorithm 1? Isn't this always true? In the else, how can there be a gamma_{L+1} if there are L layers? where does w come from? 

line 264: "For example, bi-grams statistics related to Pq (z2|z1, . . . ) can be computed
by evaluating bi-gram paths, which we can obtain by expanding the LLM with Algorithm 2 and
filtering out all paths that involve self-attention modules."

If you filter out all self-attention paths, aren't the bigrams z1, z2 independent? this needs to be true because self-attention is the only mechanism for a transformer to route information amongst tokens.

How are you optimizing the jet weights? This seems to be very important as you show the weights in Figure 2, but you only briefly mention that it is "done cheaply" without any details. Do you need specific datasets? do you use SGD? How do you actually compute the residual in a way that can be optimized?

How do you represent (computationally) and evaluate the jets? The paper presents them abstractly, which is fine, but in order to compute anything you need to be able to evaluate the k-th order jet for an MLP or self-attention layer.


Minor comments:

In eq (7), I found the notation `J^k f(x) = f(x) + ...` to be a bit confusing; suggest `(J^k f) x = y \mapsto ...`
soundness: 3
strengths: The method itself is very interesting; thinking of a network as a sum-of-paths is very natural and the jet formalism seems to capture it in a nice way.

The authors show that this generalizes  prior work such as the logit lens.

Since the top network architectures are residual, this is applicable to the most common model types.

Interpereting parts of the network is an important and relevant topic.
summary: The authors develop a method that expands a residual network into the sum of an exponential number of jets (roughly, taylor expansions of different components). Each term is a "path" information takes as it traverses the network. They apply this to interperability,
weaknesses: - The primary issue is confusing exposition and incomplete details. These make the contributions difficult to asses. I enumerated specifics in the "questions" section. 
- The exponential expansion factor means that to analyze a model like LLaMa 405b, one would have 2^118 terms which seems a bit unwieldy
- Presumably, you need ways of computing k-th order jets for network components (the authors don't seem to discuss this), which makes implementation difficult.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 2
questions: - "filtering out all paths that involve self-attention modules" — why is this necessary or reasonable?
- Figure 2
    - How is the top table related to the bottom figures?
    - Is it necessary to put all this information in a single figure?
    - Why should we measure the “cosine similarities between original and jet logits of joint (left) and iterative (right) lenses”? What do we learn from measuring it?
    - How do we see evidence for superposition or neuron polysemy in this figure?
    - Is a simpler method like LogitLens capable of identifying similar patterns?  Is there some simpler baseline you could compare your method to?
- Tables 1 and 2
    - "∆ logit after intervention" — what is the exact definition? unclear what this means.
    - What's the order of the expansion?
    - Is a simpler method like LogitLens capable of identifying similar patterns? Is there some simpler baseline you could compare your method to?
- "One-to-one bi-grams like" and “Many-to-many bi-grams” — unclear what does this mean.
- Figure 4
    - What’s the definition of a "hit ratio"?
    - What’s the definition of "total mass"?
    - How do I see double descent or grokking in this figure?
- What’s the definition of “diffing jet bi-grams”?
- "small change in mass" — what’s the definition of “mass”?
soundness: 4
strengths: - The mathematical exposition is clear.
- The authors acknowledge the limitation of their method in capturing the nonlinear model exactly.
- The applicability of the proposed method for evaluating models globally is interesting and promising. In particular, the model diffing experiments provide the potential of useful metrics for assessing the effectiveness of a specific fine-tuning method, the rate of model improvement and saturation, and the potential for certain emergent properties from n-gram statistics.
summary: The authors rewrite a model with skip connections as a composition of many Taylor series, evaluated at various points that are related to intermediate activations, promising data-independent global interpretability. The approach is demonstrated on LLMs and conceptually compared to related methods such as LogitLens.
weaknesses: - The first four sections contain clear mathematical expressions. The remaining sections do not use any of these notations which makes it very hard to digest what the figures are measuring in the context of the proposed method. I’d encourage the authors to improve the clarity of the figures and the captions. At the moment, they are very unclear.
- One way to address the first weakness would be to add a new section, between the theoretical section and the empirical section, which explains in the greatest detail possible what exactly is going to be measured empirically.
- The authors claim that their method provides global interpretability but it is unclear how their method is able to provide insights without evaluating the Jacobians at specific points.
- Is the proof of Lemma 1 a novel contribution or is it a well-known result?
- The proof of Lemma 1 (in the Appendix) is not clear.
- Before Equation 9, you state “x_{empty set} = eta”. The notation $x_set$ wasn’t previously defined and is therefore unclear.
- Could the authors expand on the algorithm bubble? At the moment, the steps are not very clear.
- It is unclear from the paper how the jet expansion relates to n-grams.
- The relation between LogitLens and the proposed method should be made more explicit.
- Superposition is mentioned multiple times throughout the paper. The relation with the jet expansion is not clear.

---

confidence: 2
contribution: 3
initial_rating: 6
presentation: 3
questions: In Figure 2, the truthfulness of jet logits decay when $k=2$. Could you comment about scaling with respect to $k$? Do you expect it to improve the quality of the expansions?

Can you explain how to obtain bi-gram and skip-n-gram expansions? Overall, I think these two paragraphs (L259 "Jet bi-grams and skip-n-grams statistics") could be a bit more detailed for comprehension of the reader.
soundness: 3
strengths: The proposed approach is principled, intuitive and unifies certain prior works. As shown by experiments, it can identify the linguistic functionality of various computational subunits in language models.
summary: This paper utilizes a convex combination of Taylor expansions to rewrite residual networks up to a nonlinear residual term. Crucially, these expansions are such that the contributions from different combinations of network subunits can be studied separately. This results in a data-independent interpretation tool for understanding black-box residual networks. The authors use this developed tool to study the functionality of subunits, pretraining dynamics, and finetuning in the context of language models.
weaknesses: Overall, the approximation quality of the jet expansions is not guaranteed, and hence faithfulness to the actual network and its behavior is unclear. This is acknowledged by the authors, and the approximation quality does not necessarily improve with scaling k (as seen from the experiments). Therefore, experimental explorations with jet expansions are only indicative without any confidence.

Meta-review: In this work, the authors introduce a framework for expanding residual networks into linear residual networks using Taylor-type expansions (jets). These jets encode path information through the computational graph which can then be interpreted to better understand higher-order behavior during inference. All reviewers expressed mixed opinions of the work, acknowledging the report is generally well-written (at the sentence level), and clearly shows a substantial amount of thought and development. The general idea is attractive, but the report falters with the details. Much of the "weaknesses" raised seem to stem from a general confusion around many of the developed concepts, including how the jets are computed, how they provide insights, what some of the terminology means, what the baselines are actually capable of and how they are subsumed, how the jets relate to n-grams, and what the jet weights are. There are many other missed details here, but given the novelty of the approach and its potential for a new form of mechanistic interpretability, a clear exposition should receive glowing reviews. 

I would recommend that the authors reconsider how the document is structured. Perhaps rather than focusing on the nature of the theoretical framework and broad discussion of its implications, I suggest considering the report from the angle of a practitioner and place practical motivations front and center: first, how does one interpret a network using current approaches (e.g. LogitLens); then, what is a general model for interpretability and how might it be used (linear residual networks), what is the ideal toolkit etc.; and finally, introduce the jets as a natural generalization. Provide examples of computational complexity. All implementation details, including the code segment provided to Reviewer NZ3B, are required for reproducibility, but these can go into further Appendices as needed. However, they should not be in remarks, which can be easily ignored when read.

This is just an example, but regardless, I believe the manuscript is not yet ready, and will require an additional review process once it is reformatted to better suit practitioners.

Decision: Reject