feat(jacobian_lens): add artifact registry + short-name resolution in from_pretrained#1537
Merged
jlarson4 merged 3 commits intoJul 24, 2026
Conversation
… from_pretrained
Adds jacobian_lens_registry.json bundling 37 pre-fitted J-lens checkpoints
from neuronpedia/jacobian-lens, and updates JacobianLens.from_pretrained to
resolve short model names and HF model IDs automatically.
Before this change users had to remember the full Hub subpath:
JacobianLens.from_pretrained(
'neuronpedia/jacobian-lens',
filename='gemma-2-2b/jlens/Salesforce-wikitext/gemma-2-2b_jacobian_lens.pt',
)
After this change either of these works:
JacobianLens.from_pretrained('gemma-2-2b')
JacobianLens.from_pretrained('google/gemma-2-2b')
Resolution order:
1. Local file path (unchanged)
2. Local directory (unchanged)
3. Registry short name or HF model ID alias → resolves repo_id + filename
4. Explicit Hub repo + filename kwarg (unchanged, fully backward-compatible)
Registry coverage (37 models as of 2026-07-23):
- Gemma 2 (2b/9b/27b, base + instruct)
- Gemma 3 (270m/1b/4b/12b/27b, base + instruct)
- Gemma 4 (31b/e2b/e4b)
- GPT-2 Small, GPT-OSS 20B
- Llama 3.1 (8b base + instruct), Llama 3.3 (70b instruct)
- OLMo 3 (7b / 32b), Pythia 70M-deduped
- Qwen 2.5 (7b-it), Qwen 3 (1.7b/4b/8b/14b/32b), Qwen 3.5 (0.8b/2b/4b/9b/27b)
Tests: 9 new unit tests covering short-name lookup, HF-ID alias lookup,
unknown-model passthrough, filename override behaviour, and GPT-2's three
aliased entry points.
Closes TransformerLensOrg#1536.
Contributor
Author
|
Hey @jlarson4 — happy to have a review when you get a chance. Let me know if you want the registry to carry any additional metadata (n_prompts, dtype) or if the alias coverage needs adjusting for any of the models. |
Collaborator
|
This looks good to my eyes @mukund1985, I will let CI finish its thing and then merge |
Contributor
Author
|
@jlarson4 CI is all green — 22 checks passed, ready to merge whenever you are. |
38 tasks
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1536.
What
Adds
jacobian_lens_registry.jsonbundling 37 pre-fitted J-lens artifacts fromneuronpedia/jacobian-lens, and teachesJacobianLens.from_pretrainedto resolve short model names and Hugging Face model IDs automatically.Before (users had to know the full Hub subpath):
After (both of these work):
Resolution order
.ptfile — unchangedneuronpedia/jacobian-lens+ exact subpathfilenamekwarg — unchanged (fully backward-compatible)Registry coverage (37 models)
gpt2,openai-community/gpt2), GPT-OSS 20BThe registry JSON is generated from
neuronpedia/jacobian-lenssibling list and includes the exact filenames (including the naming irregularities in Gemma 3 base-ptsuffix and Gemma 4 uppercase size suffix).Tests
9 new unit tests in
TestRegistry:_resolve_registry_entryby short name and by HF model ID aliasNone(passthrough to explicit Hub path)from_pretrainedshort-name resolution end-to-endfrom_pretrainedHF alias → same artifact as short namefilenamekwarg when name resolvesgpt2-small/gpt2/openai-community/gpt2) all resolve to the same file