An 𝔰𝔩_2 action on link homology of T(2,k) torus links
Felix Roz

We determine an \(\mathfrak{sl}_2\) module structure on the equivariant Khovanov-Rozanksy homology of \(T(2,k)\) torus link following the framework in <cit.>.

§ INTRODUCTION

In 1984, Vaughan Jones discovered the Jones polynomial, an invariant of oriented links which lands in \(\Z[q,q^{-1}]\) based on the representation theory of \(\mathcal{U}_q(\mathfrak{sl}_2)\).
One advantage of this invariant is that it admits a combinatorial definition called the Kauffman bracket which determines a Laurent polynomial based on skein relations.
Later, Khovanov <cit.> defined a categorification of the Jones polynomial: a bigraded homology theory whose Euler characteristic is the Jones polynomial.
Khovanov's original construction involved a simple combinatorial definition but had a sign ambiguity when dealing with functoriality with respect to link cobordisms.
Many approaches were taken to resolve the functoriality issue for example by Clark, Morrison, Walker <cit.> or more recently by Sano <cit.>.
We are especially interested in the approaches that employ foams <cit.> <cit.> <cit.>.
Further work by Khovanov and Rozansky <cit.> gave rise to a homology theory which categorifies the \(\mathcal{U}_q(\mathfrak{sl}_n)\) polynomial, but was defined using matrix factorization which made computations difficult compared to the original combinatorial one.
These issues were overcome by the work of Robert and Wagner <cit.> who developed an explicit foam evaluation formula which can be used to redefine Khovanov-Rozansky homology in a manner similar to Khovanov's original construction.

In order to understand the structure of the homology theory, Khovanov and Rozansky found the structure of an action by the positive half of a Witt algebra on HOMFLYPT homology <cit.>.
Following this work, Qi, Robert, Sussan, and Wagner found that the action of the Witt algebra can be extended to an action on the foams which are used in the combinatorial definition <cit.>.
When restricted to a copy of \(\mathfrak{sl}_2\) within the Witt algebra, it produces an action at the level of link homology <cit.>.
In this paper, we determine the explicit structure of the homology of \((2,k)\)-torus links as representations of \(\mathfrak{sl}_2\). Sections 2-4 review webs, foams, link homology and the action of \(\mathfrak{sl}_2\). Section 5 shows the computation of \(H^*(T_{2,k})\) in the \(\mathfrak{sl}_2\)-equivariant setting. Section 6 determines the structure of the representation.

§.§ Acknowledgments

I am thankful to Joshua Sussan for introducing me to categorification, link homology, and foams and for guiding me through the work behind this paper.

§ CONVENTIONS

Fix a field \(\mathbf{k}\). For any \(x \in \mathbf{k}\), \(\overline{x}  = 1- x\).
Define \(R_n = \mathbf{k}[X_1, \cdots, X_n]^{S_n} = \mathbf{k}[E_1, \cdots, E_n]\) where \(E_i\) is the \(i\)th elementary symmetric polynomial and \(deg(X_i) = 2\) so that \(deg(E_i) = 2i\).
Lastly, fix a non-negative integer \(N\) which will be the number of colors for links, webs, and foams.

We work in the relative homotopy category rather than the usual homotopy category.
A relative homotopy equivalence between chain complexes is a homotopy equivalence in the usual sense which has one direction equivariant with respect to \(\mathfrak{sl}_2\).
Full details are provided in <cit.>.

Foams and webs are always read from bottom to top.

§ WEBS AND FOAMS

A web is a finite, oriented, trivalent graph \(\Gamma = (V, E)\) embedded in the plane \(\R^2\), together with a thickness function \(\ell: E \to \N\) that satisfies the flow condition: no vertex may be a source or a sink, and the sum of the labels of the incoming edges must equal the sum of the labels of the outgoing edges.

With this definition, every vertex of a web must look like one of the following two types:

\[
\includegraphics[valign=c]{split.pdf}
\quad or \quad
\includegraphics[valign=c]{merge.pdf}
\]

The first is called a “split” and the second a “merge”. The edge with label \(a+b\) is called the “thick” edge, while the edges labeled \(a\) and \(b\) are the “thin” edges.

A foam in \(\R^2 \times [0,1]\) is a collection \(F\) of compact, oriented surfaces called facets, glued together along their boundaries.
Each facet \(f\) is given a label \(\ell(f) \in \{0, \dots, N\}\) called its thickness and a decoration \(P_f \in R_{\ell(f)}\).
Finally, we require that every point has a closed neighborhood homeomorphic to one of the following types:

* A disk,

* The cylinder over a merge or a split, denoted \(Y^{(a,b)}\):

\[\includegraphics[height=4cm]{Ybinding.pdf}\]

* The cone over the 1-skeleton of a tetrahedron, denoted \(T^{(a,b,c)}\):

\[\includegraphics[height=4cm]{tetra.pdf}\]

The set of points of the second type is a collection of curves called the bindings and the points of the third type are called the singular vertices.
For each foam \(F\) denote the set of facets \(F^2\), the set of bindings \(F^1\), and the set of singular vertices \(F^0\).
In the pictures above, the bindings are marked by black lines and the singular vertices are marked by red dots.

In the \(Y\) model, the thicknesses of the facets agree with the thicknesses of the edges in the merge or split.
This means the thicknesses of facets satisfies the flow condition as well, and we can refer to thick and thin facets around a binding.
The binding is oriented so that it agrees with the thin facets and is the opposite of the thick facet.

The boundary \(\partial F\) of \(F\) is the closure of the set of boundary points that are not contained in any bindings.
A foam with empty boundary is called a closed foam

To simplify diagrams,
the decoration \(\spadesuit_i\) denotes the power sum function of of every variable on the facet and
\(\hat{\spadesuit}_i\) denotes the power sum of every variable not on the facet.
For example, if \(N=3\) a \(\spadesuit_2\) on a facet with thickness \(2\) is an abbreviation for the polynomial \(x_1^2+x_2^2\).
The decoration \(\hat{\spadesuit}_1\) on the same facet denotes the polynomial \(x_3^1\).

Next we define the degree of a foam which adapts the Euler characteristic \(\chi\) to this setting.

For \(f \in F^2\), set

\[deg_N(f) = \ell(f)(N - \ell(f))\chi(f),\]

Let \(F^1_{\--}\) denote the collection of bindings diffeomorphic to intervals and \(F^1_{\circ}\) the bindings diffeomorphic to circles.
For \(s \in F^1_{\--}\) with a neighborhood diffeomorphic to \(Y^{(a,b)}\), set

\[deg_N(s) = ab + (a+b)(N-a-b),\]

For \(v \in F^0\) with a neighborhood diffeomorphic to \(T^{(a,b,c)}\), set

\[deg_N(v) = ab + bc +ac + (a+b+c)(N - a - b -c),\]

Finally for any decorated foam \(F\) with homogeneous decorations \(\{P_f\}_{f \in F^2}\) set

\[
deg_N(F) =
\sum_{f \in F^2} deg(P_f) -
\sum_{f \in F^2} deg_N(f) +
\sum_{s \in F^1_{\--}} deg_N(s) -
\sum_{v \in F^0} deg_N(v).
\]

Every foam in \(\R^2 \times [0,1]\) is isotopic to a composition of the following basic foams:

\[
\includegraphics[height=2cm,valign=c]{polynomial.pdf}
\]

\[
\includegraphics[height=2cm,valign=c]{assoc-left.pdf}
\quad\quad\quad\quad
\includegraphics[height=2cm,valign=c]{assoc-right.pdf}
\]

Digon cup and cap:

\[
\includegraphics[height=2cm,valign=c]{digon-cup.pdf}
\quad\quad\quad\quad
\includegraphics[height=2cm,valign=c]{digon-cap.pdf}
\]

Zip and Unzip:

\[
\includegraphics[height=2cm,valign=c]{zip.pdf}
\quad\quad\quad\quad
\includegraphics[height=2cm,valign=c]{basic-unzip.pdf}
\]

Cup and Cap:

\[
\includegraphics[height=2cm,valign=c]{basic-cup.pdf}
\quad\quad\quad\quad
\includegraphics[height=2cm,valign=c]{cap.pdf}
\]

\[
\includegraphics[height=2cm,valign=c]{saddle.pdf}
\]

§ ACTION OF \(\MATHFRAK{SL}_2\) ON FOAMS

Let \(\mathfrak{sl}_2\) be the Lie algebra over \(\mathbf{k}\) generated by symbols \(\mathbf{e}, \mathbf{h}, \mathbf{f}\) with the relations

\[
[\mathbf{h},\mathbf{e}] = 2\mathbf{e}, \quad [\mathbf{h}, \mathbf{f}]= -2 \mathbf{f}, \quad [\mathbf{e}, \mathbf{f}] = \mathbf{h}.
\]

In this section we describe the action of \(\mathfrak{sl}_2\) on foams that was defined in <cit.>.

All generators act as 0 on traces of isotopies. The action of the generators of \(\mathfrak{sl}_2\) is first defined on basic foam, then extended to all foams by the Leibniz rule

Let \(t_1\) and \(t_2\) be two fixed elements from \(R_N\).

\(\mathbf{e}\) acts as \(- \sum_i \frac{\partial}{\partial x_i}\) on polynomials and as 0 on all other basic foams.
\(\mathbf{h}\) acts on a polynomial \(P\) as \(-deg(P) \cdot P\).
\(\mathbf{f}\) acts on a polynomial \(P\) as \(- \sum_i x_i^2 \frac{\partial}{\partial x_i}(P)\).

Otherwise, \(\mathbf{h}\) and \(\mathbf{f}\) act as follows:

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{assoc-left.pdf}
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{assoc-right.pdf}
\]

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{digon-cup.pdf}
\includegraphics[height=2cm,valign=c]{digon-cup.pdf}
\]

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{digon-cap.pdf}
\includegraphics[height=2cm,valign=c]{digon-cap.pdf}
\]

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{basic-unzip.pdf}
\includegraphics[height=2cm,valign=c]{basic-unzip.pdf}
\]

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{zip.pdf}
\includegraphics[height=2cm,valign=c]{zip.pdf}
\]

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{basic-cup.pdf}
a(N - a)\;
\includegraphics[height=2cm,valign=c]{basic-cup.pdf}
\]

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{cap.pdf}
a(N - a)\;
\includegraphics[height=2cm,valign=c]{cap.pdf}
\]

\[
\mathbf{h} \cdot
\includegraphics[height=2cm,valign=c]{saddle.pdf}
-a(N - a)\;
\includegraphics[height=2cm,valign=c]{saddle.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{assoc-left.pdf}
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{assoc-right.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{digon-cup.pdf}
\includegraphics[height=2cm,valign=c]{digon-cup-back1.pdf}
\includegraphics[height=2cm,valign=c]{digon-cup-front1.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{digon-cap.pdf}
\includegraphics[height=2cm,valign=c]{digon-cap-back1.pdf}
\includegraphics[height=2cm,valign=c]{digon-cap-front1.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{basic-unzip.pdf}
\overline{t_1}\;
\includegraphics[height=2cm,valign=c]{unzip-back1.pdf}
\overline{t_2}\;
\includegraphics[height=2cm,valign=c]{unzip-front1.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{zip.pdf}
\includegraphics[height=2cm,valign=c]{zip-front1.pdf}+
\includegraphics[height=2cm,valign=c]{zip-back1.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{basic-cup.pdf}
\includegraphics[height=2cm,valign=c]{cup-hat1.pdf}
\includegraphics[height=2cm,valign=c]{cup-hat0.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{cap.pdf}
\includegraphics[height=2cm,valign=c]{cap-hat1.pdf}
\includegraphics[height=2cm,valign=c]{cap-hat0.pdf}
\]

\[
\mathbf{f} \cdot
\includegraphics[height=2cm,valign=c]{saddle.pdf}
\frac{1}{2}\;
\includegraphics[height=2cm,valign=c]{saddle-hat1.pdf}+
\frac{1}{2}\;
\includegraphics[height=2cm,valign=c]{saddle-hat0.pdf}
\]

§.§ Green Dots and Twists

In order to ensure that the braiding complexes which are defined in the next section are equivariant with respect to the \(\mathfrak{sl}_2\)-action, the action needs to be twisted.
These twists are recorded by allowing two types of green dots with \(k\)-valued multiplicities as new decorations on webs.
When a green dot is found in the source or target of a web, the action of \(\mathfrak{sl}_2\) is modified by adding an extra term. Note that the sign of the extra term differs depending on whether the green dot is in the source or target of the given foam.

The action of \(\mathbf{e}\) ignores all green dots and the action of \(\mathbf{h}\) and \(\mathbf{f}\) is defined below:

\[
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-green-top.pdf}
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-top.pdf}
- \lambda
\includegraphics[height=1.5cm,valign=c]{open-top-spade.pdf},
\quad\quad
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom-green.pdf}
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom.pdf}
+ \lambda
\includegraphics[height=1.5cm,valign=c]{open-bottom-spade.pdf}
\]

\[
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-green-top-filled.pdf}
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-top.pdf}
- \lambda
\includegraphics[height=1.5cm,valign=c]{open-top-spade-hat.pdf},
\quad\quad
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom-green-filled.pdf}
\mathbf{h} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom.pdf}
+ \lambda
\includegraphics[height=1.5cm,valign=c]{open-bottom-spade-hat.pdf}
\]

\[
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-green-top.pdf}
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-top.pdf}
+ \lambda
\includegraphics[height=1.5cm,valign=c]{open-top-spade-1.pdf},
\quad\quad
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom-green.pdf}
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom.pdf}
- \lambda
\includegraphics[height=1.5cm,valign=c]{open-bottom-spade-1.pdf}
\]

\[
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-green-top-filled.pdf}
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-top.pdf}
+ \lambda
\includegraphics[height=1.5cm,valign=c]{open-top-spade-hat-1.pdf},
\quad\quad
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom-green-filled.pdf}
\mathbf{f} \cdot \includegraphics[height=1.5cm,valign=c]{open-bottom.pdf}
- \lambda
\includegraphics[height=1.5cm,valign=c]{open-bottom-spade-hat-1.pdf}
\]

§ DEFINITION OF LINK HOMOLOGY

§.§ Foam evaluation

The webs and foams above can be naturally assembled into a category.
For a foam \(F\) embedded in \(\R^2 \times [0,1]\), \(F_t = F \cap (\R^2 \times \{t\})\) is a web.
Thus any foam can be regarded as a morphism from \(F_0\) to \(F_1\).
Note that this means foams should be read from bottom to top.

Let \(\mathbf{Foam}\) be the additive closure of the category where
objects are \(q\)-degree shifted webs,
morphisms are free \(R\)-linear combinations of foams, and
composition is given by stacking foams.

In [RW20], Robert and Wagner defined a \(\mathfrak{gl}_N\)-evaluation of a closed decorated foam \(F\) as an element \(\langle F \rangle \in R_N\).
The exact formula for the evaluation is not important for this paper, but it provides a way to produce a TQFT on \(\mathbf{Foam}\).

For any web \(\Gamma\), Robert-Wagner evaluation lets us define an \(R_N\)-bilinear form \(\langle \cdot ; \cdot \rangle_N\) on \(Hom_{\mathbf{Foam}}(\varnothing, \Gamma)\) by

\[\langle F ; G \rangle_N = \langle \overline{G} \circ F \rangle_N,\]

where \(\overline{G}: \Gamma \to \varnothing\) is the mirror image of a foam \(G: \varnothing \to \Gamma\).

For any web \(\Gamma\),
\(\mathcal{F}_N(\Gamma) = \mathcal{V}_N(\Gamma) / Ker\langle \cdot ; \cdot \rangle_N\) is called the state space of \(\Gamma\),
and by the universal construction it extends to a functor \(\mathcal{F}: \mathbf{Foam} \to R_N-\mathrm{mod}\).

From here on we restrict to the case when \(N=2\) and omit the subscript \(N\) when it is clear.
For example, \(R\) will always refer to \(R_2\).
In diagrams of webs and foams,
facets or edges of thickness 1 will be colored blue and facets or edges of thickness 2 will be colored red.
On blue facets, \(n\) dots will represent the polynomial \(x^n\) where \(x\) is the single variable allowed on that facet.

§.§ Braiding Complexes

Let \(A\) and \(B\) denote the right and left crossings respectively:

\[
A = \includegraphics[height=1.5cm, valign=c]{right-cross.pdf},
\quad\quad
B = \includegraphics[height=1.5cm, valign=c]{left-cross.pdf}
\]

Link homology is defined by assigning cohomological braiding complexes to the two crossing types:

\[
C(A) =
\uwave{\includegraphics[height=1cm,valign=c]{0-fork.pdf}}\quad
\xrightarrow{\quad\;\includegraphics[height=1cm,valign=c]{zip-bottom.pdf}\quad\;}\quad
q^{-1} \includegraphics[height=1cm,valign=c]{parallel.pdf}
\]

\[
C(B) =
q \includegraphics[height=1cm,valign=c]{parallel.pdf}\quad
\xrightarrow{\quad\;\includegraphics[height=1cm,valign=c]{unzip.pdf}\quad\;}\quad
\uwave{\includegraphics[height=1cm,valign=c]{1-fork.pdf}}
\]

In both cases the underlined term is in cohomological degree 0.

For an arbitrary link \(L\), we define \(C(L)\) to be the hypercube of resolutions constructed by taking the tensor product of braiding complexes corresponding to its component crossings.
The cohomology of the total complex of \(\mathcal{F}(C(L))\) is the cohomology \(H(L)\) of the link.

\(H(L)\) is an invariant of links and it carries an action of \(\mathfrak{sl}_2\).

See <cit.>.

§ COMPUTATION OF \(T(2,K)\) HOMOLOGY

Fix \(k \geq 2\) and consider the \((2,k)\)-torus link \(T_{2,k}\).

§.§ Local Relations

To streamline the computation,
we recall a few local relations on foams following <cit.>:

Dot Reduction by Symmetric Coefficients:

\[
\includegraphics[valign=c, height=0.5cm]{twodots.pdf}
\includegraphics[valign=c, height=0.5cm]{onedot.pdf}
\includegraphics[valign=c, height=0.5cm]{blue.pdf}
\]

Dot Migration:

\[
\includegraphics[valign=c, height=1cm]{migration-front.pdf}
\includegraphics[valign=c, height=1cm]{migration.pdf}
\includegraphics[valign=c, height=1cm]{migration-back.pdf}
\]

Neck Cutting:

\[
\includegraphics[valign=c, height=1cm]{neck.pdf}
\includegraphics[valign=c, height=1cm]{cutneck-top.pdf}
\includegraphics[valign=c, height=1cm]{cutneck-bottom.pdf}
\includegraphics[valign=c, height=1cm]{cutneck.pdf},
\quad\quad\quad
\includegraphics[valign=c, height=1cm]{red-neck.pdf} =
-\includegraphics[valign=c, height=1cm]{red-cutneck.pdf}
\]

\[
\includegraphics[valign=c,height=0.5cm]{blue-sphere.pdf} = 0
\quad
\includegraphics[valign=c,height=0.5cm]{blue-sphere-dot.pdf} = 1
\quad
\includegraphics[valign=c,height=0.5cm]{red-sphere.pdf} = -1
\]

\[
\includegraphics[valign=c,height=0.5cm]{red-neck-detach.pdf} =
\includegraphics[valign=c,height=0.5cm]{red-neck-detached.pdf},
\quad\quad\quad
\includegraphics[valign=c,height=0.5cm]{twosheet-detach.pdf} =
\includegraphics[valign=c,height=0.5cm]{twosheet-detached.pdf}
\]

§.§ Special Webs and Foams

A chain of \(k\) many \(A\)-crossings will be denoted \(A_k\)

The following are distinguished green-dotted webs

\begin{gather*}
H^n = \includegraphics[valign=c]{dotted-fork.pdf},\\
\Phi^n = \includegraphics[valign=c]{dotted-bubble.pdf},\\
I = \includegraphics[valign=c]{parallel.pdf}.
\end{gather*}

The following are distinguished foams between the above webs

\[\epsilon = \includegraphics[valign=c]{counit.pdf} \quad
\epsilon^{\bullet}_C = \includegraphics[valign=c]{counit-center-x.pdf} \quad
\epsilon^{\bullet}_R = \includegraphics[valign=c]{counit-right-x.pdf}\quad
\iota = \includegraphics[valign=c]{unit.pdf}\]

\[m_L = \includegraphics[valign=c]{left-m.pdf}\quad
m_R = \includegraphics[valign=c]{right-m.pdf}\]

\[
h = \includegraphics[valign=c]{H-id.pdf}\quad
h^{\bullet}_L = \includegraphics[valign=c]{left-x.pdf}\quad
h^{\bullet}_R = \includegraphics[valign=c]{right-x.pdf}\]

\[\phi^{\bullet}_R = \includegraphics[valign=c]{tube-center-x.pdf}\quad
\phi^{\bullet}_C = \includegraphics[valign=c]{tube-right-x.pdf}\]

\[z = \includegraphics[valign=c]{zip-bottom.pdf}\quad
u = \includegraphics[valign=c]{unzip.pdf}\]

§.§ Computation

We determine the homology of the \(T(2,k)\) link by first determining the complex of a link which contains a chain of half twists.
This is accomplished by induction, applying the following two lemmas which reduce the part of the complex corresponding to each crossing in the relative homotopy category.

The following diagram is \(\mathfrak{sl}_2\)-equivariant, commutative, and has exact columns:

\[\begin{tikzcd}[ampersand replacement=\&]
{qH^{1}} \&\& q^{-1}{H^{0}} \&\& q^{-2} I \\
\\
{\Phi^{0}} \&\& {q^{-1}H^{0}\oplus q^{-1}H^{0}} \&\& q^{-2}I \\
\\
q^{-1}{H^{0}} \&\& q^{-1}{H^{0}} \&\& \varnothing
\arrow["h", from=5-1, to=5-3]
\arrow[from=5-3, to=5-5]
\arrow["{\begin{bmatrix}h\\h\end{bmatrix}}", from=5-3, to=3-3]
\arrow["\iota"', from=5-1, to=3-1]
\arrow["\epsilon"', from=3-1, to=1-1]
\arrow["{\begin{bmatrix}m_R\\m_L\end{bmatrix}}", from=3-1, to=3-3]
\arrow["{\begin{bmatrix}h&-h\end{bmatrix}}"', from=3-3, to=1-3]
\arrow["{\begin{bmatrix}z&-z\end{bmatrix}}", from=3-3, to=3-5]
\arrow[from=5-5, to=3-5]
\arrow["{h^{\bullet}_R - h^{\bullet}_L}", from=1-1, to=1-3]
\arrow["z", from=1-3, to=1-5]
\arrow["id", from=3-5, to=1-5]
\end{tikzcd}\]

First, we will show equivariance.
The foams \(m_R, m_L\) and \(z\) are all included in braiding complexes and are thus known to be equivariant.
The foam \(h\) is simply the identity foam and is trivially equivariant.
Thus we will only show that \(\iota\), \(\epsilon\), and \(h_R^{\bullet} - h_L^{\bullet}\) are equivariant.
By the Leibniz rule for any
\(g \in \mathfrak{sl}_2\),
\(g \cdot F x = (g \cdot F) x + F (g \cdot x) = F (g \cdot x)\).
Thus a foam \(F\) is equivariant if and only if \(g \cdot F = 0\) for all \(g \in \mathfrak{sl}_2\).
The generator \(\mathbf{e}\) trivially kills these foams so we only check the generators \(\mathbf{h}\) and \(\mathbf{f}\).
In the diagrams below we omit green dots which are common to the source and target and put the result of the twisting in the second line.

\begin{align*}
\mathbf{h} \cdot \includegraphics[valign=c]{green-unit.pdf} =
(t_1 + t_2)&\includegraphics[valign=c]{unit.pdf} \\
- t_1&\includegraphics[valign=c]{unit.pdf} - t_2 \includegraphics[valign=c]{unit.pdf} = 0\\
\mathbf{f} \cdot
\includegraphics[valign=c]{green-unit.pdf} =
-t_1 &\includegraphics[valign=c]{back-unit.pdf}
-t_2 \includegraphics[valign=c]{front-unit.pdf} \\
+t_1 &\includegraphics[valign=c]{back-unit.pdf}
+t_2 \includegraphics[valign=c]{front-unit.pdf}
\end{align*}

\begin{align*}
\mathbf{h} \cdot \includegraphics[valign=c]{green-counit.pdf} =
(\overline{t_1} + \overline{t_2})&\includegraphics[valign=c]{counit.pdf} \\
+t_1&\includegraphics[valign=c]{counit.pdf} + t_1 \includegraphics[valign=c]{counit.pdf} - 1\includegraphics[valign=c]{counit.pdf} -1\includegraphics[valign=c]{counit.pdf} = 0\\
\mathbf{f} \cdot \includegraphics[valign=c]{green-counit.pdf} =
-\overline{t_1} \; &\includegraphics[valign=c]{counit-back-center-x.pdf}
-\overline{t_2} \; \includegraphics[valign=c]{counit-center-x.pdf} \\
-t_1 \; &\includegraphics[valign=c]{counit-back-center-x.pdf}
-t_2 \; \includegraphics[valign=c]{counit-center-x.pdf}
+\; \includegraphics[valign=c]{counit-back-right-x.pdf}
+\; \includegraphics[valign=c]{counit-right-x.pdf}\\
= - \; &\includegraphics[valign=c]{counit-back-center-x.pdf}
- \; \includegraphics[valign=c]{counit-center-x.pdf} \\
+\; &\includegraphics[valign=c]{counit-back-right-x.pdf}
+\; \includegraphics[valign=c]{counit-right-x.pdf}\\
= \; &\includegraphics[valign=c]{counit-center-x.pdf}
- E_1\; \includegraphics[valign=c]{counit.pdf}
- \; \includegraphics[valign=c]{counit-center-x.pdf} \\
-\; &\includegraphics[valign=c]{counit-right-x.pdf}
+ E_1\; \includegraphics[valign=c]{counit.pdf}
+\; \includegraphics[valign=c]{counit-right-x.pdf}\\
\end{align*}

\begin{align*}
\mathbf{h} \cdot
\left(
\includegraphics[valign=c]{green-right-x.pdf} -
\includegraphics[valign=c]{green-left-x.pdf}
\right)
= -2
\includegraphics[valign=c]{right-x.pdf} -
\includegraphics[valign=c]{left-x.pdf}
\right)\\
\includegraphics[valign=c]{right-x.pdf} -
\includegraphics[valign=c]{left-x.pdf}
\right)
\left(
\includegraphics[valign=c]{right-x.pdf} -
\includegraphics[valign=c]{left-x.pdf}
\right)\\
\mathbf{f} \cdot \left(
\includegraphics[valign=c]{right-x.pdf} -
\includegraphics[valign=c]{left-x.pdf}
\right) = \;
E_1\; &\includegraphics[valign=c]{right-x.pdf} -
E_1\; \includegraphics[valign=c]{left-x.pdf}\\
+\; \includegraphics[valign=c]{front-x.pdf}
E_1\; &\includegraphics[valign=c]{right-x.pdf}
- E_1\; \includegraphics[valign=c]{left-x.pdf}\\
+E_1\; &\includegraphics[valign=c]{left-x.pdf}
\end{align*}

It is easy to see that the bottom left and top right squares are commutative.
The commutativity of the top square follows from the neck cutting relation:

\[
\includegraphics[valign=c]{right-m.pdf} =
\includegraphics[valign=c]{counit-center-x.pdf}
-E_1 \includegraphics[valign=c]{counit.pdf}
\]

Lastly, we check exactness of the columns.
Since the undotted sphere is equal to \(0\), the kernel of \(\epsilon\) consists of the elements of the state space of \(\Phi^0\) which have no dots on the inner circle. This is exactly image of \(\iota\), so the left column is exact.
Since the \(h\) foams are identities for \(H\), the middle column is clearly exact.

The middle row is \(C(D_2)\) and the bottom row is acyclic.
Thus this lemma gives a simplification of \(C(D_2)\) in the relative homotopy category.

The following diagram is \(\mathfrak{sl_2}\)-equivariant, commutative, and has exact columns:

\[\begin{tikzcd}[ampersand replacement=\&]
q^k{H^{k}} \&\& q^{k-2} {H^{k-1}} \&\&\& q^{k-4} {H^{k-2}} \\
\\
\\
q^{k-1}{\Phi^{k-1}} \&\& q^{k-2} {H^{k-1}\oplus q^{k-2} H^{k-1}} \&\&\& q^{k-4} {H^{k-2}} \\
\\
\\
q^{k-2} {H^{k-1}} \&\& q^{k-2} {H^{k-1}} \&\&\& \varnothing
\arrow["h", from=7-1, to=7-3]
\arrow[from=7-3, to=7-6]
\arrow["{\begin{bmatrix}(-1)^kh\\h\end{bmatrix}}", from=7-3, to=4-3]
\arrow["\iota"', from=7-1, to=4-1]
\arrow["\epsilon"', from=4-1, to=1-1]
\arrow["{\begin{bmatrix}\epsilon\tilde{d}^{0}\\m_L\end{bmatrix}}", from=4-1, to=4-3]
\arrow["{\begin{bmatrix}h&(-1)^{k-1}h\end{bmatrix}}"', from=4-3, to=1-3]
\arrow["{\begin{bmatrix}d^{0}&(-1)^{k-1}d^{0}\end{bmatrix}}", from=4-3, to=4-6]
\arrow[from=7-6, to=4-6]
\arrow["{d^{-1}}", from=1-1, to=1-3]
\arrow["{d^{0}}", from=1-3, to=1-6]
\arrow["h", from=4-6, to=1-6]
\end{tikzcd}\]

The bottom left square commutes by the bubble and sphere relations and the top left square commutes by the neck cutting relation.
The rest is similar to the preceding lemma.

The complex \(C(A_k)\) associated to the diagram with a chain of \(k\) half twists is:

\[
0 \xrightarrow{} q^{k-1} \uwave{H^{k-1}} \xrightarrow{d^{0}} q^{k-3} {H^{k-2}} \xrightarrow{d^{1}} \cdots \xrightarrow{d^{k-3}} q^{-k+3} {H^{1}} \xrightarrow{d^{k-2}} q^{-k+1} {H^{0}} \xrightarrow{d^{k-1}} q^{-k} I \xrightarrow{} 0
\]

where \(d^{k-1} = z\), \(d^{k-j} = h^{\bullet}_R - h^{\bullet}_L\) when \(j\) is even and \(d^{k-j} = h^{\bullet}_R + h^{\bullet}_L + E_1 h\) when \(j\neq 1\) is odd.
The underlined term is in cohomological degree 0.

The proof follows by induction.
The base case \(k=2\) is given by <ref>.

Suppose that the complex \(C(A_k)\) is as above.
Then the complex \(C(A_{k+1})\) is:

\[\begin{tikzcd}[ampersand replacement=\&]
0 \& q^{k-2}{H^{k-1}} \& q^{k-4}{H^{k-2}} \& \cdots \& q^{-k}{H^{0}} \& q^{-k-1}I \& 0 \\
0 \& q^{k-1} {\Phi^{k-1}} \& q^{k-3} {\Phi^{k-2}} \& \cdots \& q^{-k+1} {\Phi^{0}} \& q^{-k} H^0 \& 0
\arrow["{-d^{k-1}}", from=1-5, to=1-6]
\arrow["{}", from=1-6, to=1-7]
\arrow["{-d^{1}}", from=1-3, to=1-4]
\arrow["{-d^{0}}", from=1-2, to=1-3]
\arrow[from=1-1, to=1-2]
\arrow["{-d^{k-2}}", from=1-4, to=1-5]
\arrow["{m_L}", from=2-2, to=1-2]
\arrow["{\tilde{d}^{0}}"', from=2-2, to=2-3]
\arrow[from=2-1, to=2-2]
\arrow["{\tilde{d}^{1}}"', from=2-3, to=2-4]
\arrow["{m_L}", from=2-3, to=1-3]
\arrow["{\tilde{d}^{k-2}}"', from=2-4, to=2-5]
\arrow["{}"', from=2-6, to=2-7]
\arrow["{\tilde{d}^{k-1}}"', from=2-5, to=2-6]
\arrow["{m_L}", from=2-5, to=1-5]
\arrow["{z}", from=2-6, to=1-6]
\end{tikzcd}\]

Where \(\tilde{d}^{k-1} = m_R\), \(\tilde{d}^{k-j} = \phi^{\bullet}_R - \phi^{\bullet}_L\) when \(j\) is even and \(\tilde{d}^{k-j} = \phi^{\bullet}_R + \phi^{\bullet}_L + E_1 \phi\), when \(j \neq 1\) is odd.
These are simply the connected sums of the \({d}^{k-j}\) foams with the \(h\) foam.

Note that by the induction hypothesis, the part of \(C(A_k)\) excluding the leftmost term is the complex \(q^{-1}C(A_{k-1})\).
Thus the portion of the diagram above excluding the leftmost column must be isomorphic to \(q^{-1} C(A_k)\).
Therefore the entire diagram is isomorphic to:

\[\begin{tikzcd}[ampersand replacement=\&]
0 \& q^{k-2} {H^{k-1}} \& \& q^{k-4} {H^{k-2}} \& \cdots \& q^{-k} {H^{0}} \& q^{-k-1} I \& 0 \\
0 \& q^{k-1} {\Phi^{k-1}} \& \& q^{k-2} {H^{k-1}}
\arrow[from=1-7, to=1-8]
\arrow["{d^{k-1}}", from=1-6, to=1-7]
\arrow["{d^{k-2}}", from=1-5, to=1-6]
\arrow["{d^{1}}", from=1-4, to=1-5]
\arrow["{(-1)^{k-1}d^{0}}", from=1-2, to=1-4]
\arrow[from=1-1, to=1-2]
\arrow["{m_L}", from=2-2, to=1-2]
\arrow["{\epsilon\tilde{d}^{0}}"', from=2-2, to=2-4]
\arrow[from=2-1, to=2-2]
\arrow["{d^{0}}", from=2-4, to=1-4]
\end{tikzcd}\]

The final square is the middle row of the diagram in <ref> so in the relative homotopy category, the diagram is isomorphic to:

\[
0 \xrightarrow{} q^{k} \uwave{H^{k}} \xrightarrow{d^{-1}} q^{k-2} {H^{k-1}} \xrightarrow{d^{0}} q^{k-4}H^{k-2} \xrightarrow{d^1}  \cdots \xrightarrow{d^{k-2}} q^{-k} {H^{0}} \xrightarrow{d^{k-1}} q^{-k-1} I \xrightarrow{} 0
\]

After reindexing, this is the desired complex for \(C(D_{k+1})\).

Now we consider the case when the chain \(D_k\) is a part of a \((2,k)\)-torus link.
The web \(I\) is replaced by a pair of oppositely oriented circles which we will denote \(O \otimes O\), and each \(H\) is replaced by the theta web:

\[\Theta = \includegraphics[valign=c]{theta.pdf}
\Theta^n = \includegraphics[valign=c]{theta-dotted.pdf}\]

The foam \(h\) is replaced with the theta foam, and the foams \(h^{\bullet}_L\) and \(h^{\bullet}_R\) are replaced by the same dotted theta foam:

\[\theta = \includegraphics[valign=c]{theta-foam.pdf} \quad
\theta^{\bullet} = \includegraphics[valign=c]{theta-foam-dot.pdf}\]

Finally, the zip foam \(z\) is replaced by a singular pair of pants:

\[p = \includegraphics[valign=c]{pants.pdf}\]

Now the differentials collapse so that \(d^{k-1} = p\), \(d^{k-j} = 0\) when \(j\) is even, and \(d^{k-j} = 2\theta^{\bullet} - E_1 \theta\) when \(j\neq 1\) is odd:

\[
0 \xrightarrow{} q^{k-1} {\Theta^{k-1}} \xrightarrow{d^0} \cdots \xrightarrow{0} q^{-k+5} {\Theta^2} \xrightarrow{2\theta^\bullet - E_1 \theta} q^{-k+3} {\Theta^{1}} \xrightarrow{0} q^{-k+1} {\Theta^0} \xrightarrow{p} q^{-k} {O \otimes O} \xrightarrow{} 0
\]

The state spaces for \(O\) and \(\Theta\) are generated by their dotted and undotted cup foams:

\[\theta_\iota = \includegraphics[valign=c]{theta-cup.pdf} \quad
\theta^{\bullet}_\iota = \includegraphics[valign=c]{theta-cup-dot.pdf}\quad
o_\iota = \includegraphics[valign=c]{cup.pdf}\quad
o^{\bullet}_\iota = \includegraphics[valign=c]{cup-dot.pdf}\]

To determine the action of \(d^{-1} = p\) on this basis for \(\Theta^0\) we first simplify the following foam:

\begin{align*}
\includegraphics[valign=c]{cupped-pants.pdf}&=
\includegraphics[valign=c]{cut-cupped-pants-dot-L.pdf} +
\includegraphics[valign=c]{cut-cupped-pants-dot-M.pdf}
- E_1 \includegraphics[valign=c]{cut-cupped-pants.pdf} \\ &=
\includegraphics[valign=c]{cut-cupped-pants-dot-L.pdf}
- \includegraphics[valign=c]{cut-cupped-pants-dot-R.pdf} \\ &=
\includegraphics[valign=c]{left-dot-cup.pdf}-
\includegraphics[valign=c]{right-dot-cup.pdf}
\end{align*}

This determines the following action on our basis:

\begin{align*}
\theta_\iota &\mapsto o_\iota^{\bullet} \otimes o_\iota - o_\iota \otimes o_\iota^{\bullet} \\
\theta_\iota^{\bullet} &\mapsto o_\iota^{\bullet} \otimes o_\iota^{\bullet} - E_1 o_\iota \otimes o^\bullet_\iota + E_2 o_\iota \otimes o_\iota
\end{align*}

The kernel is clearly trivial, and the cokernel is freely generated by \(o_\iota \otimes o_\iota\) and \(o_\iota^{\bullet} \otimes o_\iota\) which have unshifted \(q\)-degree \(-2\) and \(0\) respectively.
Thus \(H^k(T_{2,k}) = q^{-2-k}R \oplus q^{-k}R\)

For odd \(j\), \(d^{-j} = 2\theta^{\bullet} - E_1h\) acts on the basis for \(\theta^{j-1}\) by:

\begin{align*}
\theta_\iota &\mapsto 2\theta_\iota^{\bullet} - E_1\theta_\iota \\
\theta_\iota^{\bullet} &\mapsto E_1\theta_\iota^{\bullet} - 2E_2\theta_\iota
\end{align*}

If \(a\theta_\iota+b\theta^{\bullet}_\iota\) were in the kernel,
then \(2a = -E_1b\) and \(E_1a = -2E_2b\).
These relations imply \(E_1^2b = 4E_2b\).
Since \(E_1\) and \(E_2\) are independent, \(b=0\) and thus \(a=0\).
Thus the kernel is trivial so \(H^{k-j}(T_{2,k}) = 0\) for all odd \(j \neq 1\).

The cokernel of \(d^{k-j}\) is generated by \(\theta_\iota\) and \(\theta_\iota^{\bullet}\) with the relations
\(E_1\theta_\iota = 2\theta^{\bullet}_\iota\) and
\(2E_2 \theta_\iota = E_1 \theta^{\bullet}_\iota\).
Since we require \(2\) to be invertible in the base ring, this reduces to a single generator \(\theta_\iota\) with unshifted \(q\)-degree \(-1\) modulo the relation \((E_1^2 - 4E_2)\theta_\iota = 0\).
Recalling the \(q\)-shift applied to the term at this cohomology degree: \(H^{k-j+1}(T_{2,k}) = q^{-k+2j-2} k[E_1,E_2]/\langle E_1^2-4E_2 \rangle\).

As a graded \(k[E_1,E_2]\)-module

\begin{align*}
H^k(T_{2,k})     &\cong q^{-k-2} k[E_1,E_2] \oplus q^{-k} k[E_1,E_2] \\
H^{k-j}(T_{2,k}) &\cong 0 \text{ for all odd } j \neq 1 \\
H^{k-j}(T_{2,k}) &\cong q^{-k+2j-2} k[E_1,E_2]/\langle E_1^2 + 4E_2   \rangle \text{ for all even } 0 < j < k\\
H^{0}(T_{2,k})   &\cong q^{k-2} k[E_1,E_2] \oplus q^{k} k[E_1,E_2] \text{ if } k \text{ is even }
\end{align*}

§ ACTION OF \(\MATHFRAK{SL}_2\)

We let \(\mathfrak{sl}_2\) act on the ring \(R = k[E_1,E_2]\) of symmetric polynomials by:

\begin{align*}
\mathbf{e}\cdot E_1 &= -2
&\mathbf{e}\cdot E_2 &= -E_1\\
\mathbf{h}\cdot E_1 &= -2E_1
&\mathbf{h}\cdot E_2 &= -4E_2\\
\mathbf{f}\cdot E_1 &= E_1^2 - 2E_2
&\mathbf{f}\cdot E_2 &= E_1 E_2
\end{align*}

This action comes from the action of the Lie algebra \(\mathfrak{M}\) generated by symbols \((L_n)_{n \in \Z}\) subject to the relations \([L_n, L_m] = (n-m)L_{m+n}\) for all \(n,m \in \Z\).
\(\mathfrak{M}\) acts on a polynomial \(Q \in k[x_1, \cdots, x_N]\) by

\[L_n \cdot Q = - \sum_{i=1}^k x_i^{n+1} \frac{\partial Q}{\partial x_i}\]

The action of \(\mathfrak{sl}_2\) defined on the ring \(R\) above comes from the identifications

\begin{gather*}
E_1 = X_1 + X_2,\; E_2 = X_1X_2, \\
\mathbf{e} = L_{-1},\; \mathbf{h} = 2L_0,\; \mathbf{f} = - L_1
\end{gather*}

Now we can compute the action of \(\mathfrak{sl}_2\) on the generators of cohomology.
In what follows we will replace normalize the homology \(H^*(T_{2,k})\) by replacing it with \(q^kH^*(T_{2,k})\).
In the shifted case, \(\mathbf{h}\) always acts by multiplying by the negative degree of a vector.
This has the advantage that the graded dimensions of the homology as a vector space coincide with the dimensions of its weight space decomposition.

We analyze the \(\mathfrak{sl}_2\) structure one cohomological degree at a time.
Cohomology degree \(k\) is generated by \(o_\iota \otimes o_\iota\) and \(o_\iota^{\bullet} \otimes o_\iota\) which have \(q\)-degree \(-2\) and \(0\) respectively.
The generators of \(\mathfrak{sl}_2\) act as follows:

\begin{align*}
\mathbf{e}(o_\iota \otimes o_\iota) &= 0
&\mathbf{e}(o_\iota^{\bullet} \otimes o_\iota) &= - o_\iota \otimes o_\iota\\
\mathbf{h}(o_\iota \otimes o_\iota) &= 2 o_\iota \otimes o_\iota
&\mathbf{h}(o_\iota^{\bullet} \otimes o_\iota) &= 0\\
\mathbf{f}(o_\iota \otimes o_\iota) &= - E_1 o_\iota \otimes o_\iota
&\mathbf{f}(o_\iota^{\bullet} \otimes o_\iota) &= - E_2 o_\iota \otimes o_\iota
\end{align*}

Now we will determine the graded dimension of \(H^{k}(T_{2,k})\).
An arbitrary polynomial ring \(k[x]\) where \(deg(x) =n\), has graded dimension

\[
1 + q^n + q^{2n} + q^{3n} + \cdots = \frac{1}{1-q^n}
\]

Since \(gdim(E_1) = 2\) and \(gdim(E_2) = 4\),

\[
gdim(k[E_1, E_2]) = gdim(k[E_1]) \cdot gdim(k[E_2]) = \frac{1}{1-q^2} \cdot \frac{1}{1-q^4}
\]

\begin{align*}
gdim(q^{-2} k[E_1,E_2] \oplus k[E_1,E_2]) &= \frac{q^{-2}}{(1-q^2)(1-q^4)} + \frac{1}{(1-q^2)(1-q^4)} \\
&= q^{-2} \frac{1+q^2}{(1-q^2)(1-q^4)} \\
&= q^{-2}\frac{1}{(1-q^2)^2}\\
&= q^{-2} + 2q^0 + 3q^2 + 4q^4 + \cdots
\end{align*}

Now we can read off \(dim(A_\lambda) = - \lambda/2 + 2\) for all even weights \(\lambda \leq 2\).
For any weight \(\lambda\), the operator \(\mathbf{e}\) maps the weight space \(A_\lambda\) to \(A_{\lambda+2}\).
Since \(dim(A_\lambda) = dim(A_{\lambda+2}) + 1\),
\(\mathbf{e}\) has a non trivial kernel in each \(A_\lambda\) and thus a highest weight vector \(v_\lambda\) in every weight.
Let \(S_\lambda\) be the \(\mathfrak{sl}_2\)-submodule generated by \(v_\lambda\).
For weights \(\lambda \leq -2\), \(S_\lambda\) is the Verma module \(M(\lambda)\).

Recall that an irreducible \(\mathfrak{sl}_2\)-module with highest weight \(\lambda \geq 0\) can only be in extension with a module with highest weight \(-\lambda - 2\).
The highest weight of the entire module \(A\) is \(2\), thus for \(\lambda \leq 6\), none of the submodules isomorphic to \(M(-\lambda)\) can be in extension with any other submodule.
However, submodules of weights \(2\) and be in extension with those of weight \(-4\) and submodules of weight \(0\) can be in extension with those of weight \(-2\).
Therefore we need to examine these weights more carefully.

By manipulating \(q\)-degrees, we can produce the following bases which will be helpful when searching for vectors with a desired action under \(\mathfrak{sl}_2\).

\begin{align*}
A_2    &= \langle o_\iota \otimes o_\iota \rangle\\
A_0    &= \langle E_1 o_\iota \otimes o_\iota, o_\iota^\bullet \otimes o_\iota \rangle\\
A_{-2} &= \langle E_1^2 o_\iota \otimes o_\iota, E_1 o_\iota^\bullet \otimes o_\iota, E_2 o_\iota \otimes o_\iota \rangle \\
A_{-4} &= \langle E_1E_2 o_\iota \otimes o_\iota, E_1^3 o_\iota \otimes o_\iota, E_1^2 o^\bullet_\iota \otimes o_\iota, E_2 o^\bullet_\iota \otimes o_\iota\rangle
\end{align*}

To begin, we can find lowest weight vectors in each of the above weights:

\begin{align*}
v_2    &= o_\iota \otimes o_\iota\\
v_0    &= E_1 o_\iota \otimes o_\iota - 2 o_\iota^\bullet \otimes o_\iota\\
v_{-2} &= E_1^2 o_\iota \otimes o_\iota - 4 E_2 o_\iota \otimes o_\iota \\
v_{-4} &= E_1^3 o_\iota \otimes o_\iota - 4 E_1E_2 o_\iota \otimes o_\iota - 2 E_1^2 o_\iota^\bullet \otimes o_\iota + 8 E_2 o_\iota^\bullet \otimes o_\iota
\end{align*}

Simple computations show that \(S_2\) and \(S_0\) are isomorphic to the finite dimensional simple modules \(L(2)\) and \(L(0)\).

\begin{align*}
v_2 &= o_\iota \otimes o_\iota\\
\mathbf{f}v_2 &= -E_1 o_\iota \otimes o_\iota\\
\mathbf{f}^2v_2 &= 2E_2 o_\iota \otimes o_\iota \\
\mathbf{f}^3v_2 &= 0
\end{align*}

\begin{align*}
v_0    &= E_1 o_\iota \otimes o_\iota - 2 o_\iota^\bullet \otimes o_\iota\\
\mathbf{f}v_0 &= 0
\end{align*}

Therefore the only submodule with highest weight 0, and thus the only submodule that \(S_{-2}\) can only be in extension with, is \(S_0 \cong L(0)\).
Only the action of \(\mathbf{e}\) increases weights, but it kills the vectors in \(S_0\) which have weight \(-2 = 0-2\).
Thus \(S_{-2}\) cannot be in extension with any other submodule.
For the same reason, \(S_{-4}\) cannot be in extension with \(S_2 \cong L(2)\), the only submodule with highest weight \(2\).

However, in weight \(-2\), we also find the vector

\[w_{-2} = E_1^2 o_\iota \otimes o_\iota - 2E_1 o_\iota^\bullet \otimes o_\iota\]

with the property \(\mathbf{e}w_{-2} = v_0\).
Now we must determine the module structure generated by \(v_0\) and \(w_{-2}\).
If we quotient \(\mathcal{U}(\mathfrak{sl}_2)\langle v_0, w_{-2} \rangle\) by \(\langle v_0 \rangle \cong S_0 \cong L(0)\), then we are left with the Verma module \(M(-2)\)
giving us a short exact sequence

\[
0 \to L(0) \to \mathcal{U}(\mathfrak{sl}_2)\langle v_0, w_{-2} \rangle \to M(-2) \to 0
\]

which presents \(\mathcal{U}(\mathfrak{sl}_2)\langle v_0, w_{-2} \rangle\) as an extension of \(M(-2)\) by \(L(0)\).
There is a unique such non-trivial extension, \(M^*(0)\), so \(\mathcal{U}(\mathfrak{sl}_2)\langle v_0, w_{-2} \rangle\) must be isomorphic to it.

Similarly, we can find a weight \(-4\) vector \(w_{-4}\) such that \(\mathbf{e} w_{-4} = 3 \mathbf{f}^3 v_2\):

\[
w = E_1^3 o_\iota \otimes o_\iota - 4 E_1 E_2 o_\iota \otimes o_\iota - 4 E_1^2 o_\iota^\bullet \otimes o_\iota + 10 E_2 o_\iota^\bullet \otimes o_\iota
\]

Again we can analyze the structure of the submodule generated by \(v_{2}\) and \(w_{-4}\) by a short exact sequence:

\[
0 \to L(2) \to \mathcal{U}(\mathfrak{sl}_2)\langle v_2, w_{-4} \rangle \to M(-4) \to 0
\]

\(M^*(2)\) is the unique such extension between \(M(-4)\) and \(L(2)\).

As an \(\mathfrak{sl}_2\)-module:

\[
H^k(T_{2,k}) \cong M^*(2) \oplus M^*(0) \oplus \bigoplus_{r=2}^\infty M(-2r)
\]

Next, we analyze the structure of \(H^{k-j}(T_{2,k})\) for \(0 < j < k\) even.
The state space of \(\Theta^{j-1}\) has a single generator \(\theta_\iota\) which has \(q\)-degree \(2j-2\).
The action of \(\mathfrak{sl}_2\) is as follows:

\begin{align*}
\mathbf{e}(\theta_\iota ) &= 0 \\
\mathbf{h}(\theta_\iota ) &= -2(j-1) \theta_\iota \\
\mathbf{f}(\theta_\iota ) &= E_1(j-1) \theta_\iota
\end{align*}

Since \(j\) is at least \(2\), the height weight of these modules are at most \(-2\).
Thus as an \(\mathfrak{sl}_2\)-module

\[H^{k-j}(T_{2,k}) \cong  M(-2j+2)\]

Finally, if \(k\) is even, then \(H^0(T_{2,k})\) is the state space of \(q^{2k-1}\Theta^{k-1}\).
As a vector space it is generated by \(\theta_\iota\) and \(\theta_\iota^\bullet\) which have \(q\)-degrees \(2k-2\) and \(2k\) respectively.
The action is as follows:

\begin{align*}
\mathbf{e}(\theta_\iota ) &= 0 &
\mathbf{e}(\theta_\iota^\bullet ) &= -\theta_\iota \\
\mathbf{h}(\theta_\iota ) &= -2(k-1) \theta_\iota &
\mathbf{h}(\theta_\iota^\bullet ) &= -2k \theta_\iota^\bullet \\
\mathbf{f}(\theta_\iota ) &= E_1(k-1) \theta_\iota &
\mathbf{f}(\theta_\iota^\bullet ) &= E_1k \theta_\iota^\bullet - E_2 \theta_\iota
\end{align*}

Just as we determined \(gdim(H^k(T_{2,k})) = \frac{q^{-2}}{(1-q^2)^2}\),

\[
= q^{2k-2}\frac{1}{(1-q^2)^2}
= q^{2k-2} + 2q^{2k} + 3q^{2k+2} + 4q^{2k+4} + \cdots
\]

The relation between dimensions of weight spaces are the same as in cohomology degree 0, so we also have a highest weight vector in each weight space.
However, the highest weight is \(-2k+2\) which is negative as long as \(k\geq 2\).
Thus every highest weight vector generates a Verma module and there are no extensions between them.

Fix \(k \geq 2\) and consider the \((2,k)\)-torus link \(T_{2,k}\).
As an \(\mathfrak{sl}_2\)-module and forgetting the \(q\)-grading

\begin{align*}
H^k(T_{2,k})     &\cong M^*(2) \oplus M^*(0) \oplus \bigoplus_{r=1}^\infty M(-2r) \\
H^{k-j}(T_{2,k}) &\cong 0 \text{ for all odd } j \neq 1 \\
H^{k-j}(T_{2,k}) &\cong M(-2j+2) \text{ for all even } 0 < j < k\\
H^{0}(T_{2,k})   &\cong \bigoplus_{r=k-1}^\infty  M(-2r) \text{ if } k \text{ is even }
\end{align*}

When defining the \(\mathfrak{sl}_2\) action we needed to fix two parameters \(t_1\) and \(t_2\) from our base field.
The homology of all \((2,k)\)-torus links is independent of these parameters, but it is unclear if this is the case in general.

Missing 'biblatex' package
The bibliography requires the 'biblatex' package.

Mathematical Sciences Publishers

journaltitleAlgebraic & Geometric Topology
titleOn the functoriality of \(\mathfrak{sl}_2\) tangle homology

titleAn oriented model for Khovanov homology

titleAn sl(2) tangle homology and seamed cobordisms

Mathematical Sciences Publishers

journaltitleGeometry & Topology
titleFixing the functoriality of Khovanov homology

titleA categorification of the Jones polynomial

titleMatrix factorizations and link homology

journaltitleQuantum Topology
titlePositive half of the Witt algebra acts on triply graded link homology

titleSymmetries of $\mathfrak{gl}_N$-foams

titleSymmetries of equivariant Khovanov-Rozansky homology

journaltitleQuantum Topology
titleA closed formula for the evaluation of $\mathfrak{sl}_N$-foams

World Scientific Pub Co Pte Ltd

journaltitleJournal of Knot Theory and Its Ramifications
titleFixing the functoriality of Khovanov homology: A simple approach


#  pyvene: A Library for Understanding and Improving PyTorch Models
via Interventions

Zhengxuan Wu†, Atticus Geiger‡, Aryaman Arora†, Jing Huang†, Zheng Wang†,
Noah D. Goodman†, Christopher D. Manning†, Christopher Potts†
†Stanford University ‡Pr(Ai)2R Group
<EMAIL_ADDRESS>

###### Abstract

Interventions on model-internal states are fundamental operations in many
areas of AI, including model editing, steering, robustness, and
interpretability. To facilitate such research, we introduce pyvene, an open-
source Python library that supports customizable interventions on a range of
different PyTorch modules. pyvene supports complex intervention schemes with
an intuitive configuration format, and its interventions can be static or
include trainable parameters. We show how pyvene provides a unified and
extensible framework for performing interventions on neural models and sharing
the intervened upon models with others. We illustrate the power of the library
via interpretability analyses using causal abstraction and knowledge
localization. We publish our library through Python Package Index (PyPI) and
provide code, documentation, and tutorials at
https://github.com/stanfordnlp/pyvene.

pyvene: A Library for Understanding and Improving PyTorch Models
via Interventions

Zhengxuan Wu†, Atticus Geiger‡, Aryaman Arora†, Jing Huang†, Zheng Wang†, Noah
D. Goodman†, Christopher D. Manning†, Christopher Potts† †Stanford University
‡Pr(Ai)2R Group
<EMAIL_ADDRESS>

Figure 1: An inference-time intervention (Li et al., 2023a) on
TinyStories-33M. The model is prompted with “Once upon a time there was a”,
and is asked to complete the story. We add a static word embedding (for
“happy” or “sad”) into the MLP output at each decoding step for all layers
with a coefficient of 0.3. pyvene’s complete implementation is provided. The
original and intervened generations use greedy decoding.

##  1 Introduction

When we _intervene_ on a neural network, we make an in-place change to its
activations, putting the model in a counterfactual state. This fundamental
operation has emerged as a powerful tool for both understanding and improving
models; interventions of various kinds are key to recent efforts in model
robustness He et al. (2019), model editing Meng et al. (2022) and steering Li
et al. (2023a), causal abstraction Geiger et al. (2020, 2021, 2023); Wu et al.
(2023) or activation patching Chan et al. (2022); Wang et al. (2023), circuit
finding Conmy et al. (2023); Goldowsky-Dill et al. (2023), and knowledge
tracing Geva et al. (2023).

As intervention-based techniques have matured, the need has arisen to run ever
more complex interventions on ever larger models. Currently, there is no
unified and generic intervention-oriented library to support such research.
Existing libraries are often project-based (see implementations for Wang et
al. 2023; Geiger et al. 2023 as examples) that lack extensibility and are hard
to maintain and share, and current toolkits focus on single or non-nested
interventions (e.g., ablation neurons in a single forward pass) and are often
limited to interventions on Transformers (Vaswani et al., 2017) without
natively supporting other neural architectures. Some of these existing
libraries (Bau, 2022; Lloyd, 2023; Fiotto-Kaufman, 2023; Mossing et al., 2024)
can support complex interventions such as exchanging activations across
multiple forward passes yet they require sophisticated knowledge and heavy
implementations.

To address these limitations, we introduce pyvene, an open-source Python
library that supports customizable interventions on different neural
architectures implemented in PyTorch. Different from previous libraries Bau
(2022); Nanda and Bloom (2022); Lloyd (2023); Fiotto-Kaufman (2023); Mossing
et al. (2024), pyvene is intervention-oriented. It supports complex
interventions by manipulating or exchanging activations across multiple model
forward runs while allowing these interventions to be shared with a
serialization configuration file. Specifically, pyvene has a number of
advantages:

  1. 1.

Intervention as the primitive. The intervention is the basic primitive of
pyvene. Interventions are specified with a dict-based format, in contrast to
previous approaches where interventions are expressed as code and executed
during runtime Bau (2022); Lloyd (2023); Fiotto-Kaufman (2023); Mossing et al.
(2024). All pyvene intervention schemes and models are serializable objects
that can be shared through a public model hub such as HuggingFace.

  2. 2.

Complex intervention schemes. pyvene supports interventions at multiple
locations, involving arbitrary subsets of neurons, and interventions can be
performed in parallel or in sequence. For generative use of LMs, pyvene
supports interventions at decoding steps. Furthermore, activations can easily
be collected for probe training.

  3. 3.

Support for recurrent and non-recurrent models. Existing libraries offer only
limited support for recurrent models. pyvene supports simple feed-forward
networks, Transformers, and recurrent and convolutional neural models.

In this paper, we provide two detailed case studies using pyvene as well: (1)
we fully reproduce Meng et al. (2022)’s locating factual associations in
GPT2-XL (Figure 1 in the original paper) in about 20 lines of code, and (2) we
show intervention and probe training with pyvene to localize gender in
Pythia-6.9B. pyvene is published through the Python Package Index
(PyPI),111pip install pyvene and the project
site222https://github.com/stanfordnlp/pyvene hosts more than 20 tutorials that
cover interventions at different levels of complexity with various model
architectures from simple feed-foward models to multi-modal models.

##  2 System Design and Architecture

Two primary components of pyvene are the intervenable configuration, which
outlines which model components will be intervened upon, and the intervenable
model, which decorates the original torch model with hooks that allow
activations to be collected and overwritten.333Code snippets provided in the
paper can be run on Google Colab at
https://colab.research.google.com/github/stanfordnlp/pyvene/blob/main/pyvene_101.ipynb.
Here is a setup for performing a zero-out intervention (often called a zero
ablation; Li et al. 2023b) on the 10th, 11th, and 12th dimensions of the MLP
output for 3rd token embedding of layer 0 in GPT-2:

⬇

import torch

import pyvene as pv

# built-in helper to get a HuggingFace model

_, tokenizer, gpt2 = pv.create_gpt2()

# create with dict-based config

pv_config = pv.IntervenableConfig({

"layer": 0,

"component": "mlp_output",

"intervention_type": pv.VanillaIntervention})

# initialize model

pv_gpt2 = pv.IntervenableModel(

pv_config, model=gpt2)

# run an intervened forward pass

intervened_outputs = pv_gpt2(

# the base input

base=tokenizer(

"The capital of Spain is",

return_tensors="pt"),

# the location to intervene at (3rd token)

unit_locations={"base": 3},

# the individual dimensions targetted

subspaces=[10,11,12],

# the intervention values

source_representations=torch.zeros(

gpt2.config.n_embd)

)

# sharing

pv_gpt2.save("./tmp/", save_to_hf_hub=True)

The model takes a tensor input base and runs through the model’s computation
graph modifying activations in place to be other values source. In this code,
we specified source in the forward call. When source is a constant, it can
alternatively be specified in the IntervenableConfig. To target complete MLP
output representations, one simply leaves out the subspaces argument. The
final line of the code block shows how to serialize and share an intervened
model remotely through a model hub such as HuggingFace.

###  2.1 Interchange Interventions

Interchange interventions (Geiger et al., 2020; Vig et al., 2020; Wang et al.,
2023, also known as activation patching) fix activations to take on the values
they would be if a different input were provided. With minor changes to the
forward call, we can perform an interchange intervention on GPT-2:

⬇

# run an interchange intervention

intervened_outputs = pv_gpt2(

# the base input

base=tokenizer(

"The capital of Spain is",

return_tensors = "pt"),

# the source input

sources=tokenizer(

"The capital of Italy is",

return_tensors = "pt"),

# the location to intervene at (3rd token)

unit_locations={"sources->base": 3},

# the individual dimensions targeted

subspaces=[10,11,12]

)

This forward call produces outputs for base but with the activation values for
MLP output dimensions 10–12 of token 3 at layer 0 set to those that obtained
when the model processes the source. Such interventions are used in
interpretability research to test hypotheses about where and how information
is stored in model-internal representations.

###  2.2 Addition Interventions

In the above examples, we replace values in the base with other values
(VanillaIntervention). Another common kind of intervention involves updating
the base values in a systematic way:

⬇

noising_config = pv.IntervenableConfig({

"layer": 0,

"component": "block_input",

"intervention_type": pv.AdditionIntervention})

noising_gpt2 = pv.IntervenableModel(

config, model=gpt2)

intervened_outputs = noising_gpt2(

base=tokenizer(

"The Space Needle is in downtown",

return_tensors = "pt"),

# target the first four tokens for intervention

unit_locations={"base": [0, 1, 2, 3]},

source_representations = torch.rand(

gpt2.config.n_embd, requires_grad=False))

As in this example, we add noise to a representation as a basic robustness
check. The code above does this, targetting the first four input token
embeddings to a Transformer by using AdditionIntervention. This example serves
as the building block of causal tracing experiments as in Meng et al. 2022,
where we corrupt embedding inputs by adding noise to trace factual
associations. Building on top of this, we reproduce Meng et al.’s result in
Section 3. pyvene allows Autograd on the static representations, so this code
could be the basis for training models to be robust to this noising process.

###  2.3 Activation Collection Interventions

This is a pass-through intervention to collect activations for operations like
supervised probe training. Such interventions can be combined with other
interventions as well, to support things like causal structural probes Hewitt
and Manning (2019); Elazar et al. (2020); Lepori et al. (2023). In the
following example, we perform an interchange intervention at layer 8 and then
collect activations at layer 10 for the purposes of fitting a probe:

⬇

# set up a upstream intervention

probe_config = pv.IntervenableConfig({

"layer": 8,

"component": "block_output",

"intervention_type": pv.VanillaIntervention})

# add downstream collector

probe_config = probe_config.add_intervention({

"layer": 10,

"component": "block_output",

"intervention_type": pv.CollectIntervention})

probe_gpt2 = pv.IntervenableModel(

probe_config, model=gpt2)

# return the activations for 3rd token

collected_activations = probe_gpt2(

base=tokenizer(

"The capital of Spain is",

return_tensors="pt"),

unit_locations={"sources->base": 3})

###  2.4 Custom Interventions

pyvene provides a flexible way of adding new intervention types. The following
is a simple illustration in which we multiply the original representation by a
constant value:

⬇

# multiply base with a constant

class MultInt(pv.ConstantSourceIntervention):

def __init__(self, **kwargs):

super().__init__()

def forward(self, base, source=None,

subspaces=None):

return base * 0.3

pv.IntervenableModel({

"intervention_type": MultInt},

model=gpt2)

The above intervention becomes useful when studying interpretability-driven
models such as the Backpack LMs of Hewitt et al. (2023). The sense vectors
acquired during pretraining in Backpack LMs have been shown to have a
“multiplication effect”, and so proportionally decreasing sense vectors could
effectively steer the model’s generation.

###  2.5 Trainable Interventions

pyvene interventions can include trainable parameters.
RotatedSpaceIntervention implements Distributed Alignment Search (DAS; Geiger
et al. 2023), LowRankRotatedSpaceIntervention is a more efficient version of
that model, and BoundlessRotatedSpaceIntervention implements the Boundless DAS
variant of Wu et al. (2023). With these primitives, one can easily train DAS
explainers.

In the example below, we show a single gradient update for a DAS training
objective that localizes the capital associated with the country in a one-
dimensional linear subspace of activations from the Transformer block output
(i.e., main residual stream) at the 8th layer by training our intervention
module to match the gold counterfactual behavior:

⬇

das_config = pv.IntervenableConfig({

"layer": 8,

"component": "block_output",

"low_rank_dimension": 1,

"intervention_type":

pv.LowRankRotatedSpaceIntervention})

das_gpt2 = pv.IntervenableModel(

das_config, model=gpt2)

last_hidden_state = das_gpt2(

base=tokenizer(

"The capital of Spain is",

return_tensors="pt"),

sources=tokenizer(

"The capital of Italy is",

return_tensors="pt"),

unit_locations={"sources->base": 3}

)[-1].last_hidden_state[:,-1]

# gold counterfacutual label as " Rome"

label = tokenizer.encode(

" Rome", return_tensors="pt")

logits = torch.matmul(

last_hidden_state, gpt2.wte.weight.t())

m = torch.nn.CrossEntropyLoss()

loss = m(logits, label.view(-1))

loss.backward()

###  2.6 Training with Interventions

Interventions can be co-trained with the intervening model for techniques like
interchange intervention training (IIT), which induce specific causal
structures in neural networks Geiger et al. (2022):

⬇

pv_gpt2 = pv.IntervenableModel({

"layer": 8},

model=gpt2)

# enable gradients on the model

pv_gpt2.enable_model_gradients()

# run counterfactual forward as usual

In the example above, with the supervision signals from the training dataset,
we induce causal structures in the residual stream at 8th layer.

###  2.7 Multi-Source Parallel Interventions

In the parallel mode, interventions are applied to the computation graph of
the same base example at the same time. We can perform interchange
interventions by taking activations from multiple source examples and swapping
them into the base’s computation graph:

⬇

parallel_config = pv.IntervenableConfig([

{"layer": 3, "component": "block_output"},

{"layer": 3, "component": "block_output"}],

# intervene on base at the same time

mode="parallel")

parallel_gpt2 = pv.IntervenableModel(

parallel_config, model=gpt2)

base = tokenizer(

"The capital of Spain is",

return_tensors="pt")

sources = [

tokenizer("The language of Spain is",

return_tensors="pt"),

tokenizer("The capital of Italy is",

return_tensors="pt")]

intervened_outputs = parallel_gpt2(

base, sources,

{"sources->base": (

# each list has a dimensionality of

# [num_intervention, batch, num_unit]

[[[1]],[[3]]], [[[1]],[[3]]])}

)

In the example above, we interchange the activations from the residual streams
on top of the second token from the first example (“language”) as well as the
fourth token from the second example (“Italy”) into the corresponding
locations of the base’s computation graph. The motivating intuition is that
now the next token might be mapped to a semantic space that is a mixture of
two inputs in the source “The language of Italy”. (And, in fact, “Italian” is
among the top five returned logits.)

###  2.8 Multi-Source Serial Interventions

Interventions can also be sequentially applied, so that later interventions
are applied to an intervened model created by the previous ones:

⬇

serial_config = pv.IntervenableConfig([

{"layer": 3, "component": "block_output"},

{"layer": 10, "component": "block_output"}],

# intervene on base one after another

mode="serial")

serial_gpt2 = pv.IntervenableModel(

serial_config, model=gpt2)

intervened_outputs = serial_gpt2(

base, sources,

# src_0 intervenes on src_1 position 1

# src_1 intervenes on base position 4

{"source_0->source_1": 1,

"source_1->base" : 4}

)

In the example above, we first take activations at the residual stream of the
first token (“language”) at the 3rd layer from the first source example and
swap them into the same location during the forward run of the second source
example. We then take the activations of the 4th token (“is”) at layer 10 at
upstream of this intervened model and swap them into the same location during
the forward run of the base example. The motivating intuition is that the
first intervention will result in the model retrieving “The language of Italy”
and the second intervention will swap the retrieved answer into the output
stream of the base example. (Once again, “Italian” is among the top five
returned logits.)

###  2.9 Intervenable Model

The IntervenableModel class is the backend for decorating torch models with
intervenable configurations and running intervened forward calls. It
implements two types of hooks: Getter and Setter hooks to save and set
activations.

Figure 1 highlights pyvene’s support for LMs. Interventions can be applied to
any position in the input prompt or any selected decoding step.

The following involves a model with recurrent (GRU) cells where we intervene
on two unrolled recurrent computation graphs at a time step:

⬇

# built-in helper to get a GRU

_, _, gru = pv.create_gru_classifier(

pv.GRUConfig(h_dim=32))

# wrap it with config

pv_gru = pv.IntervenableModel({

"component": "cell_output",

# intervening on time

"unit": "t",

"intervention_type": pv.ZeroIntervention},

model=gru)

# run an intervened forward pass

rand_b = torch.rand(1,10, gru.config.h_dim)

rand_s = torch.rand(1,10, gru.config.h_dim)

intervened_outputs = pv_gru(

base = {"inputs_embeds": rand_b},

sources = [{"inputs_embeds": rand_s}],

# intervening time step

unit_locations={"sources->base": (6, 3)})

A hook is triggered every time the corresponding model component is called. As
a result, a vanilla hook-based approach, as in all previous libraries (Bau,
2022; Lloyd, 2023; Fiotto-Kaufman, 2023; Mossing et al., 2024), fails to
intervene on any recurrent or state-space model. To handle this limitation,
pyvene records a state variable for each hook, and only executes a hook at the
targeted time step.

Figure 2: We reproduce the results in Meng et al. (2022)’s Figure 1 of
locating early sites and late sites of factual associations in GPT2-XL _in
about 20 lines of pyvene code_. The causal impact on output probability is
mapped for the effect of each Transformer block output (left), MLP activations
(middle), and attention layer output (right) .

Figure 3: Results of interchange intervention accuracy (IIA) with the
trainable intervention (DAS) and accuracy with the trainable linear probe on
different model components when localizing gender information.

##  3 Case Study I: Locating Factual Associations in GPT2-XL

We replicate the main result in Meng et al. (2022)’s Locating Factual
Associations in GPT2-XL with pyvene. The task is to trace facts via
interventions on fact-related datasets. Following Meng et al.’s setup, we
first intervene on input embeddings by adding Gaussian noise. We then restore
individual states to identify the information that restores the results.
Specifically, we restore the Transformer block output, MLP activation, and
attention output for each token at each layer. For MLP activation and
attention output, we restore 10 sites centered around the intervening layer
(clipping on the edges). Our Figure 2 fully reproduces the main Figure 1 (p.
2) in Meng et al.’s paper. To replicate their experiments, we first define a
configuration for causal tracing:

⬇

def tracing_config(

l, c="mlp_activation", w=10, tl=48):

s = max(0, l - w // 2)

e = min(tl, l - (-w // 2))

config = IntervenableConfig(

[{"component": "block_input"}] +

[{"layer": l, "component": c}

for l in range(s, e)],

[pv.NoiseIntervention] +

[pv.VanillaIntervention]*(e-s))

return config

With this configuration, we corrupt the subject token and then restore
selected internal activations to their clean value. Our main experiment is
implemented with about 20 lines of code with pyvene:

⬇

trace_results = []

_, tokenizer, gpt = pv.create_gpt2("gpt2-xl")

base = tokenizer(

"The Space Needle is in downtown",

return_tensors="pt")

for s in ["block_output", "mlp_activation",

"attention_output"]:

for l in range(gpt.config.n_layer):

for p in range(7):

w = 1 if s == "block_output" else 10

t_config, n_r = tracing_config(l, s, w)

t_gpt = pv.IntervenableModel(t_config, gpt)

_, outs = t_gpt(base, [None] + [base]*n_r,

{"sources->base": ([None] + [[[p]]]*n_r,

[[[0, 1, 2, 3]]] + [[[p]]]*n_r)})

dist = pv.embed_to_distrib(gpt,

outs.last_hidden_state, logits=False)

trace_results.append(

{"stream": s, "layer": l, "pos": p,

"prob": dist[0][-1][7312]})

##  4 Case Study II: Intervention and Probe Training with Pythia-6.9B

We showcase intervention and probe training with pyvene using a simple
gendered pronoun prediction task in which we try to localize gender in hidden
representations. For trainable intervention, we use a one-dimensional
Distributed Alignment Search (DAS; Geiger et al., 2023), that is, we seek to
learn a 1D subspace representing gender. To localize gender, we feed prompts
constructed from a template of the form “[John/Sarah] walked because [he/she]”
(a fixed length of 4) where the name is sampled from a vocabulary of 47
typically male and 10 typically female names followed by the associated
gendered pronoun as the output token. We use pythia-6.9B (Biderman et al.,
2023) in this experiment, which achieves 100% accuracy on the task. We then
train our interventions and probes at the Transformer block output at each
layer and token position. For intervention training, we construct pairs of
examples and train the intervention to match the desired counterfactual output
(i.e., if we swap activations from an example with a male name into another
example with a female name, the desired counterfactual output should be “he”).
For linear probe training, we use activation collection intervention to
retrieve activations to predict the pronoun gender with a linear layer.

As shown in Figure 3, a trainable intervention finds sparser gender
representations across layers and positions, whereas a linear probe achieves
100% classification accuracy for almost all components. This shows that a
probe may achieve high performance even on representations that are not
causally relevant for the task.

##  5 Limitations and Future Work

We are currently focused on two main areas:

  1. 1.

Expanding the default intervention types and model types. Although pyvene is
extensible to other types, having more built-in types helps us to onboard new
users easily.

  2. 2.

pyvene is designed to support complex intervention schemes, but this comes at
the cost of computational efficiency. As language models get larger, we would
like to investigate how to scale intervention efficiency with multi-node and
multi-GPU training.

##  6 Conclusion

We introduce pyvene, an open-source Python library that supports intervention-
based research on neural models. pyvene supports customizable interventions
with complex intervention schemes as well as different families of model
architectures, and intervened models are shareable with others through online
model hubs such as HuggingFace. Our hope is that pyvene can be a powerful tool
for discovering new ways in which interventions can help us explain and
improve models.

## References

  * Bau (2022) David Bau. 2022.  BauKit.  https://github.com/davidbau/baukit.
  * Biderman et al. (2023) Stella Biderman, Hailey Schoelkopf, Quentin Gregory Anthony, Herbie Bradley, Kyle O’Brien, Eric Hallahan, Mohammad Aflah Khan, Shivanshu Purohit, USVSN Sai Prashanth, Edward Raff, Aviya Skowron, Lintang Sutawika, and Oskar Van Der Wal. 2023.  Pythia: A suite for analyzing large language models across training and scaling.  In _International Conference on Machine Learning (ICML)_.
  * Chan et al. (2022) Lawrence Chan, Adrià Garriga-Alonso, Nicholas Goldowsky-Dill, Ryan Greenblatt, Jenny Nitishinskaya, Ansh Radhakrishnan, Buck Shlegeris, and Nate Thomas. 2022.  Causal scrubbing: a method for rigorously testing interpretability hypotheses.  Alignment Forum Blog post.
  * Conmy et al. (2023) Arthur Conmy, Augustine N Mavor-Parker, Aengus Lynch, Stefan Heimersheim, and Adrià Garriga-Alonso. 2023.  Towards automated circuit discovery for mechanistic interpretability.  In _Advances in Neural Information Processing Systems (NeurIPS)_.
  * Elazar et al. (2020) Yanai Elazar, Shauli Ravfogel, Alon Jacovi, and Yoav Goldberg. 2020.  Amnesic probing: Behavioral explanation with amnesic counterfactuals.  In _Transactions of the Association of Computational Linguistics (TACL)_.
  * Fiotto-Kaufman (2023) Jaden Fiotto-Kaufman. 2023.  nnsight.  https://github.com/JadenFiotto-Kaufman/nnsight.
  * Geiger et al. (2021) Atticus Geiger, Hanson Lu, Thomas Icard, and Christopher Potts. 2021.  Causal abstractions of neural networks.  In _Advances in Neural Information Processing Systems (NeurIPS)_.
  * Geiger et al. (2020) Atticus Geiger, Kyle Richardson, and Christopher Potts. 2020.  Neural natural language inference models partially embed theories of lexical entailment and negation.  In _Proceedings of the Third BlackboxNLP Workshop on Analyzing and Interpreting Neural Networks for NLP_ , Online.
  * Geiger et al. (2022) Atticus Geiger, Zhengxuan Wu, Hanson Lu, Josh Rozner, Elisa Kreiss, Thomas Icard, Noah Goodman, and Christopher Potts. 2022.  Inducing causal structure for interpretable neural networks.  In _International Conference on Machine Learning (ICML)_.
  * Geiger et al. (2023) Atticus Geiger, Zhengxuan Wu, Christopher Potts, Thomas Icard, and Noah D. Goodman. 2023.  Finding alignments between interpretable causal variables and distributed neural representations.  In _Causal Learning and Reasoning (CLeaR)_.
  * Geva et al. (2023) Mor Geva, Jasmijn Bastings, Katja Filippova, and Amir Globerson. 2023.  Dissecting recall of factual associations in auto-regressive language models.  In _Empirical Methods in Natural Language Processing (EMNLP)_ , Singapore.
  * Goldowsky-Dill et al. (2023) Nicholas Goldowsky-Dill, Chris MacLeod, Lucas Sato, and Aryaman Arora. 2023.  Localizing model behavior with path patching.  _arXiv:2304.05969_.
  * He et al. (2019) Zhezhi He, Adnan Siraj Rakin, and Deliang Fan. 2019.  Parametric noise injection: Trainable randomness to improve deep neural network robustness against adversarial attack.  In _IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)_.
  * Hewitt and Manning (2019) John Hewitt and Christopher D Manning. 2019.  A structural probe for finding syntax in word representations.  In _North American Chapter of the Association for Computational Linguistics (NAACL)_.
  * Hewitt et al. (2023) John Hewitt, John Thickstun, Christopher Manning, and Percy Liang. 2023.  Backpack language models.  In _Association for Computational Linguistics (ACL)_.
  * Lepori et al. (2023) Michael A Lepori, Thomas Serre, and Ellie Pavlick. 2023.  Uncovering intermediate variables in transformers using circuit probing.  _arXiv:2311.04354_.
  * Li et al. (2023a) Kenneth Li, Oam Patel, Fernanda Viégas, Hanspeter Pfister, and Martin Wattenberg. 2023a.  Inference-time intervention: Eliciting truthful answers from a language model.  In _Advances in Neural Information Processing Systems (NeurIPS)_.
  * Li et al. (2023b) Maximilian Li, Xander Davies, and Max Nadeau. 2023b.  Circuit breaking: Removing model behaviors with targeted ablation.  _arXiv:2309.05973_.
  * Lloyd (2023) Evan Lloyd. 2023.  graphpatch.  https://github.com/evan-lloyd/graphpatch.
  * Meng et al. (2022) Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov. 2022.  Locating and editing factual associations in GPT.  In _Advances in Neural Information Processing Systems (NeurIPS)_.
  * Mossing et al. (2024) Dan Mossing, Steven Bills, Henk Tillman, Tom Dupré la Tour, Nick Cammarata, Leo Gao, Joshua Achiam, Catherine Yeh, Jan Leike, Jeff Wu, and William Saunders. 2024.  Transformer debugger.  https://github.com/openai/transformer-debugger.
  * Nanda and Bloom (2022) Neel Nanda and Joseph Bloom. 2022.  Transformerlens.  https://github.com/neelnanda-io/TransformerLens.
  * Vaswani et al. (2017) Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017.  Attention is all you need.  In _Advances in Neural Information Processing Systems (NeurIPS)_.
  * Vig et al. (2020) Jesse Vig, Sebastian Gehrmann, Yonatan Belinkov, Sharon Qian, Daniel Nevo, Yaron Singer, and Stuart Shieber. 2020.  Investigating gender bias in language models using causal mediation analysis.  In _Advances in Neural Information Processing Systems (NeurIPS)_.
  * Wang et al. (2023) Kevin Wang, Alexandre Variengien, Arthur Conmy, Buck Shlegeris, and Jacob Steinhardt. 2023.  Interpretability in the wild: A circuit for indirect object identification in GPT-2 small.  In _International Conference on Learning Representations (ICLR)_.
  * Wu et al. (2023) Zhengxuan Wu, Atticus Geiger, Thomas Icard, Christopher Potts, and Noah Goodman. 2023.  Interpretability at scale: Identifying causal mechanisms in Alpaca.  In _Advances in Neural Information Processing Systems (NeurIPS)_.