Proposal
Base on dev-4.x. Rewrite the executable >>> doctests that build a HookedTransformer so they construct a TransformerBridge instead, in the modules that keep running doctests after HookedTransformer is removed: transformer_lens/ActivationCache.py (4 HT-constructing doctests), transformer_lens/evals.py (2 HT-constructing doctests, only 1 executable at :326-329 — the other is already # doctest: +SKIP at :554-559), transformer_lens/utilities/exploratory_utils.py (1).
Motivation
HookedTransformer is being deprecated in favour of TransformerBridge. ActivationCache, evals, and exploratory_utils are staying, but their doctests still do HookedTransformer.from_pretrained(...). pytest runs these (pyproject.toml enables --doctest-modules over transformer_lens/), so they will hard-fail the moment HookedTransformer is removed. Migrating them now keeps the examples current and unblocks removal.
Pitch
- Replace
HookedTransformer.from_pretrained("gpt2"...) with TransformerBridge.boot_transformers("gpt2") (add .enable_compatibility_mode() where the example relies on HookedTransformer-exact hook names / numerics).
- Update expected doctest output to whatever the bridge prints, and any
# doctest: +SKIP markers that are no longer needed. Note every executable example also asserts the literal output line Loaded pretrained model ... into HookedTransformer, so each rewrite must update that expected-output line too.
- Keep each example's teaching intent identical; only the model construction changes.
Acceptance:
Mirror: existing bridge examples in docs/source/content/ and the boot_transformers / enable_compatibility_mode usage in tests/unit/model_bridge/.
Checklist
Proposal
Base on
dev-4.x. Rewrite the executable>>>doctests that build aHookedTransformerso they construct aTransformerBridgeinstead, in the modules that keep running doctests afterHookedTransformeris removed:transformer_lens/ActivationCache.py(4 HT-constructing doctests),transformer_lens/evals.py(2 HT-constructing doctests, only 1 executable at:326-329— the other is already# doctest: +SKIPat:554-559),transformer_lens/utilities/exploratory_utils.py(1).Motivation
HookedTransformeris being deprecated in favour ofTransformerBridge.ActivationCache,evals, andexploratory_utilsare staying, but their doctests still doHookedTransformer.from_pretrained(...).pytestruns these (pyproject.tomlenables--doctest-modulesovertransformer_lens/), so they will hard-fail the momentHookedTransformeris removed. Migrating them now keeps the examples current and unblocks removal.Pitch
HookedTransformer.from_pretrained("gpt2"...)withTransformerBridge.boot_transformers("gpt2")(add.enable_compatibility_mode()where the example relies on HookedTransformer-exact hook names / numerics).# doctest: +SKIPmarkers that are no longer needed. Note every executable example also asserts the literal output lineLoaded pretrained model ... into HookedTransformer, so each rewrite must update that expected-output line too.Acceptance:
ActivationCache.py,evals.py,utilities/exploratory_utils.pyconstructsHookedTransformermake docstring-test(orpytest --doctest-modules transformer_lens/) passesmake unit-testpassesuv run mypy .passesMirror: existing bridge examples in
docs/source/content/and theboot_transformers/enable_compatibility_modeusage intests/unit/model_bridge/.Checklist