Overview
| Parameter | Value |
|---|---|
| Project name | TransformerLens Contributions |
| Organization | TransformerLensOrg |
| Contributor | Janmenjaya Panda |
| Mentor | Jonah Larson |
| Contribution period | July 2026 - present |
| Technologies | Python, PyTorch, TransformerLens, Hugging Face Transformers, Sphinx |
| Topics | Mechanistic interpretability, Jacobian Lens, J-space decomposition, gradient interpretation, subspace geometry, attribution patching, sparse probing, and model-bridge reliability |
| Statistics (as of 09/07/2026) |
10 authored pull requests: 7 merged and 3 open. 7 authored issues: 3 completed and 4 open. Merged authored work: 11,202 additions, 38 deletions, 49 commits, and 46 changed-file entries. Open authored work: 2,074 additions and 247 deletions across 3 pull requests. |
| Project details | This work turns recent mechanistic-interpretability ideas into tested TransformerLens APIs. It covers sparse Jacobian-space analysis and intervention, vocabulary-facing gradient interpretation, attention-head subspace comparison, first-order attribution, independent numerical parity, and cross-model compatibility. Each contribution pairs an explicit mathematical contract with focused tests, documentation, and reproducible examples. |
The line, file, and commit totals are GitHub-reported snapshot metrics. They include source, tests, documentation, and notebooks; changed-file counts are summed per pull request and are not counts of unique repository paths.
Detailed Overview
The contributions form a connected research and engineering program: define a mathematical object, expose it through a maintainable API, validate it against an independent numerical oracle, and document exactly what the result does and does not establish.
Jacobian Lens and J-space
The Jacobian Lens maps a vocabulary direction backward through the model's local Jacobian. For layer \(\ell\) and vocabulary token \(t\), the J-lens vector is
where \(W_U[:, t]\) is the token's unembedding direction. The J-space at that layer is the span of these vocabulary-derived vectors. Collecting them as dictionary columns gives \(B = [v_1, \ldots, v_{|V|}]\).
PR #1596 implemented sparse J-space decomposition. For an activation \(x\), it finds a small nonnegative coordinate vector by solving
and reports the anchored decomposition
The implementation includes nonnegative orthogonal matching pursuit, exact Lawson-Hanson nonnegative least squares on the selected support, gradient pursuit, cached layer dictionaries, typed result objects, and independent KKT checks for the NNLS solution.
Occupancy and fraction of variance
PR #1676 made the recovered space measurable. Occupancy compares the cumulative variance captured by greedily selected J-lens atoms with random unit-norm control dictionaries and reports the point of maximum separation. For selected support \(S\), fraction of variance uses orthogonal projection onto the selected span:
This deliberately measures the span rather than conflating it with the nonnegative reconstruction. PR #1738 added a reproducible GPT-2 notebook for sparse coordinates, selected-span variance, occupancy, ranking overlap, solver runtime, and causal removal against norm-matched random controls.
Anchored J-space interventions
PR #1741 implemented coordinate substitution and swapping while preserving the original residual and every unedited coordinate:
The edit uses the existing decomposition chart rather than recomputing
\(B^\dagger x\), so changing one coordinate cannot silently move all the
others. The interpolation parameter \(\alpha=0\) is an exact no-op, and
conditioning diagnostics expose near-parallel directions. PR #1749 extends
the same anchored edit into live run_with_hooks and generate calls; it
is open at the snapshot date.
Backward Lens
PR #1723 implemented a vocabulary-facing interpretation of GPT-2 MLP parameter gradients. It captures position-wise factors whose outer products must independently reconstruct the parameter gradients:
Residual-width factors are projected through the model's live final
normalization and unembedding. The API reports signed token directions,
target-token ranks, factor norms, numerical ranks, and absolute and relative
reconstruction errors without mutating model parameters or .grad fields.
Attention-head subspace geometry
PR #1721 implemented the Projection Kernel, a basis-invariant affinity between attention-head weight subspaces. For orthonormal bases \(Q_A\) and \(Q_B\),
where \(\theta_i\) are the principal angles. The implementation covers reduced-SVD basis extraction, rank metadata, random-subspace moments, OQ/OK/OV comparisons, grouped-query attention, masks, and bounded-memory tiled scoring.
Attribution patching
PR #1750 develops node-level attribution patching from one clean activation, one corrupt activation, and one corrupt-run gradient:
The sign convention is denoising: a positive score means moving a corrupt node toward its clean activation increases the metric. A deliberately linear model provides the exact correctness oracle. Edge Attribution Patching and integrated gradients remain explicitly reserved follow-ups rather than being presented as implemented in this open pull request.
Validation, probing, and model compatibility
PR #1735 added independent BERT Bridge-to-Hugging-Face parity for logits,
activation-cache points, and padded attention masks. issue #1728 specifies a
leakage-safe sparse-probing pipeline that splits before feature selection or
normalization and evaluates deterministic random-coordinate and shuffled-label
controls. PR #1752 addresses NeoX/Pythia unembedding compatibility across
embed_out and lm_head layouts.
Across the program, correctness is tested through independent KKT conditions, outer-product reconstruction, basis invariance, direct Hugging Face parity, and exact identities on deliberately linear models. Open-weight experiments, decodability results, and first-order approximations are documented with their claim boundaries.
Note
Pull-request and issue status is a verified snapshot as of 7 September 2026. See Project Work for the source-linked contribution table.