transformer_lens.model_bridge.sources.inspect.driver module

InspectDriver — torch-free consumer of an inspect_ai provider’s output.

Talks to a provider through the inspect_ai ModelOutput envelope. Everything provider-specific — the request schema, which hooks are served, full vs last-token logits, intervention translation — lives in a profiles Profile; the driver just drives it. Stays numpy-only (to_torch runs at the bridge boundary), so this file imports zero torch symbols (enforced by a unit test). inspect_ai is imported lazily.

class transformer_lens.model_bridge.sources.inspect.driver.InspectDriver(model: Any, adapter: Any, tokenizer: Any, profile: Any = None)

Bases: DriverBase

Driver wrapping an inspect_ai model; capture + interventions via a Profile.

close() None

No-op default. Override when the driver owns releasable resources.

forward(input_ids: TensorLike | None = None, *, capture: tuple[str, ...] = (), intervene: Mapping[str, Callable[[TensorLike], TensorLike] | Mapping[str, Any]] | None = None, max_new_tokens: int = 1, return_logits: bool = True, **kwargs: Any) ForwardResult