transformer_lens.model_bridge.sources.inspect package

Submodules

Module contents

Inspect driver: turn an inspect_ai-served model into a TransformerLens bridge.

We ship our own HF-backed provider (provider.py) and a torch-free consumer (driver.py).

Maintainer note: this package is named inspect, shadowing the stdlib module. Only ever import the stdlib inspect via an absolute import from outside this package; never write a bare import inspect inside these modules.

transformer_lens.model_bridge.sources.inspect.boot_inspect(model_name: str, tokenizer: Any | None = None, dtype: dtype | None = None, provider: str = 'tl_bridge', **inspect_kwargs: Any) RemoteBridge

Boot a model via an inspect_ai provider and wrap it in a RemoteBridge.

The driver is provider-agnostic: provider defaults to our own HF-backed tl_bridge provider (residual/attn/mlp capture + full affine interventions + full-sequence logits); "vllm-lens" targets a running vllm-lens vLLM provider (residual-only, additive-steering-only) — wire-aligned with its documented format, but not yet verified against a live provider.

Fireable hooks (tl_bridge, TransformerBridge-native names): blocks.{i}.hook_in (resid_pre) / ln2.hook_in (resid_mid) / hook_out (resid_post) / attn.hook_out / mlp.hook_out, plus the head-split attention hooks where the structural probe finds them: attn.hook_q/k/v (pre-RoPE projection outputs; separate-projection archs only — fused qkv gates them), attn.hook_z (out-projection input), and attn.hook_pattern (post-softmax, capture-only, eager attention required). The provider runs a structural self-check per model and gates any boundary it can’t serve faithfully: resid_mid for parallel-residual or norm-variant blocks, attn_out/mlp_out when their submodule isn’t locatable (it warns when it gates one). embed, ln_final, and attn.hook_attn_scores are always non-fireable — use boot_transformers() for those.

For parity with boot_transformers the provider loads with the same dtype (fp32 by default) and eager attention. Full-sequence logits ride on return_logits=True (the default); pass return_logits=False to skip the (seq × d_vocab) payload for pure activation capture (run_with_cache keeps them since it returns logits).