jacobian-lens  by anthropics

Interpretability tool for understanding language model activations

Created 6 days ago

New!

811 stars

Top 42.8% on SourcePulse

GitHubView on GitHub
Project Summary

<2-3 sentences summarising what the project addresses and solves, the target audience, and the benefit.> This repository provides the reference implementation for the Jacobian lens, a tool designed to interpret internal activations of large language models. It addresses the challenge of understanding what specific internal states "want" to say, targeting LLM interpretability researchers and engineers. The benefit lies in decoding these internal states into ranked vocabulary tokens, offering a direct window into the model's decision-making process.

How It Works

The Jacobian lens linearly transports residual-stream vectors from any layer to the final-layer basis using the average input-output Jacobian matrix (J_l = E[∂h_final / ∂h_l]) over a text corpus. The transported vector is then decoded via the model's unembedding layer, yielding ranked vocabulary tokens representing the activation's disposition. This offers a novel method to directly query and visualize the semantic content of internal model states.

Quick Start & Requirements

Installation: pip install -e .. Requires HuggingFace transformers models and typically a CUDA-enabled GPU. Fitting a lens involves providing model, prompts, and checkpoint paths; quality reportedly saturates quickly (~100 prompts). The walkthrough.ipynb notebook offers an end-to-end guide.

Highlighted Details

  • Features an interactive layer × position view visualizing lens outputs, showing top-1 words at specific activation points.
  • Demonstrates interpretability with examples like the ASCII-face, correctly identifying "nose" at mid-layers even when absent from the prompt.
  • Designed for compatibility with various HuggingFace decoder-only transformers.
  • Fitting requires minimal data; quality stabilizes rapidly with ~100 prompts.

Maintenance & Community

This project is explicitly marked as "Not maintained and not accepting contributions." No community channels are listed.

Licensing & Compatibility

Code and prompt sets are released under the permissive Apache License 2.0, generally allowing commercial use. The library adapts cleanly to other HuggingFace decoders. Note that model weights and datasets downloaded at runtime are subject to their respective licenses.

Limitations & Caveats

The project is "Not maintained and not accepting contributions," indicating a lack of ongoing development or support. It is a reference implementation and is not optimized for performance, with fitting times potentially dominated by the model's backward pass.

Health Check
Last Commit

6 days ago

Responsiveness

Inactive

Pull Requests (30d)
2
Issues (30d)
1
Star History
812 stars in the last 6 days

Explore Similar Projects

Starred by Anastasios Angelopoulos Anastasios Angelopoulos(Cofounder of LMArena), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
7 more.

transformer-debugger by openai

0.0%
4k
Tool for language model behavior investigation
Created 2 years ago
Updated 2 months ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Neel Nanda Neel Nanda(Research Scientist at Google DeepMind), and
1 more.

TransformerLens by TransformerLensOrg

0.6%
4k
Library for mechanistic interpretability research on GPT-style language models
Created 3 years ago
Updated 23 hours ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Didier Lopes Didier Lopes(Founder of OpenBB), and
3 more.

transformer-explainer by poloclub

0.5%
8k
Interactive visualization for Transformer model education
Created 2 years ago
Updated 1 month ago
Feedback? Help us improve.