Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/oracle-parity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Oracle Parity

# Runs the @pytest.mark.slow oracle parity suite for JacobianLens.
# Not part of the standard PR gate — requires ~4 GB VRAM and network access.
# Triggered manually or automatically when the test file or this workflow changes.
on:
workflow_dispatch:
push:
branches:
- main
- dev*
paths:
- "tests/integration/test_jacobian_lens_oracle_parity.py"
- ".github/workflows/oracle-parity.yml"

permissions:
contents: read

jobs:
oracle-parity-checks:
name: Oracle Parity Checks
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"
activate-environment: true
enable-cache: true

- name: Install dependencies
run: |
uv lock --check
uv sync

- name: Install oracle (pinned ORACLE_COMMIT from test file)
run: |
ORACLE_COMMIT=$(python -c "
import re, pathlib
src = pathlib.Path('tests/integration/test_jacobian_lens_oracle_parity.py').read_text()
print(re.search(r'ORACLE_COMMIT = \"([^\"]+)\"', src).group(1))
")
uv pip install "git+https://github.com/anthropics/jacobian-lens.git@${ORACLE_COMMIT}"

- name: Authenticate HuggingFace
if: env.HF_TOKEN != ''
run: uv run python -c "import os; from huggingface_hub import login; login(token=os.environ['HF_TOKEN'])"
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}

- name: Oracle Parity Test
run: uv run pytest tests/integration/test_jacobian_lens_oracle_parity.py -v -m slow
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interpretability](https://distill.pub/2020/circuits/zoom-in/) of GPT-2 Style lan
goal of mechanistic interpretability is to take a trained model and reverse engineer the algorithms
the model learned during training from its weights.

TransformerLens lets you load in 9,000+ open source language models across 50+ architecture families,
TransformerLens lets you load in 15,000+ open source language models across 140+ architecture families,
and exposes the internal activations of the model to you. You can cache any internal activation in the
model, and add in functions to edit, remove or replace these activations as the model runs.

Expand Down Expand Up @@ -52,7 +52,7 @@ logits, activations = bridge.run_with_cache("Hello World")

> Gated models (Llama, Mistral, Gemma, ...) require `HF_TOKEN` in your environment. See [Environment Variables](https://TransformerLensOrg.github.io/TransformerLens/content/getting_started.html#environment-variables) for the full list.

`TransformerBridge` is the recommended 3.0 path and supports 9,000+ models across 50+ architecture families (see [`supported_models.json`](transformer_lens/tools/model_registry/data/supported_models.json) for the full inventory). By default it preserves raw HuggingFace weights – logits and activations match HF, *not* legacy `HookedTransformer` (which folds LayerNorm and centers weights by default). Call `bridge.enable_compatibility_mode()` after booting for HookedTransformer-equivalent numerics. The legacy `HookedTransformer.from_pretrained` API is still available but deprecated — see the [Migrating to TransformerLens 3](https://TransformerLensOrg.github.io/TransformerLens/content/migrating_to_v3.html) guide.
`TransformerBridge` is the recommended path and supports 15,000+ models across 140+ architecture families (see [`supported_models.json`](transformer_lens/tools/model_registry/data/supported_models.json) for the full inventory). By default it preserves raw HuggingFace weights – logits and activations match HF, *not* legacy `HookedTransformer` (which folds LayerNorm and centers weights by default). Call `bridge.enable_compatibility_mode()` after booting for HookedTransformer-equivalent numerics. The legacy `HookedTransformer.from_pretrained` API is still available but deprecated — see the [Migrating to TransformerLens 3](https://TransformerLensOrg.github.io/TransformerLens/content/migrating_to_v3.html) guide.

## Key Tutorials

Expand Down
13 changes: 12 additions & 1 deletion demos/Grokking_Demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,18 @@
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"DeprecationWarning:\n",
"\n",
"HookedTransformer is deprecated and will be removed in 4.0. Use TransformerBridge.boot_transformers(...) instead, then call enable_compatibility_mode() for HookedTransformer-equivalent numerics.\n",
"\n"
]
}
],
"source": [
"model = HookedTransformer(cfg)"
]
Expand Down
1,722 changes: 1,468 additions & 254 deletions demos/Jacobian_Lens_Demo.ipynb

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion demos/No_Position_Experiment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,18 @@
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"DeprecationWarning:\n",
"\n",
"HookedTransformer is deprecated and will be removed in 4.0. Use TransformerBridge.boot_transformers(...) instead, then call enable_compatibility_mode() for HookedTransformer-equivalent numerics.\n",
"\n"
]
}
],
"source": [
"cfg = HookedTransformerConfig(\n",
" n_layers=2,\n",
Expand Down
13 changes: 12 additions & 1 deletion demos/Othello_GPT.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,18 @@
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"DeprecationWarning:\n",
"\n",
"HookedTransformer is deprecated and will be removed in 4.0. Use TransformerBridge.boot_transformers(...) instead, then call enable_compatibility_mode() for HookedTransformer-equivalent numerics.\n",
"\n"
]
}
],
"source": [
"import transformer_lens.utilities as utils\n",
"\n",
Expand Down
4 changes: 4 additions & 0 deletions demos/doc_sanitize.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ replace: \1
[regex6d]
regex: (0\.[1-9]\d{2})\d+
replace: \1

[regex7]
regex: [^\n]*DeprecationWarning:(?=\n\nHookedTransformer is deprecated and will be removed in 4\.0\. Use TransformerBridge\.boot_transformers\(\.\.\.\) instead, then call enable_compatibility_mode\(\) for HookedTransformer-equivalent numerics\.)
replace: DeprecationWarning:
Loading
Loading