transformer_lens.model_bridge.exceptions module

Exceptions for TransformerBridge.

This module contains custom exceptions used by the TransformerBridge.

exception transformer_lens.model_bridge.exceptions.StopAtLayerException(layer_output: Tensor)

Bases: Exception

Exception raised when execution should stop at a specific layer.

This exception is used to implement stop_at_layer functionality by having blocks check if they should stop and raise this exception, which is then caught in the main forward pass.

__init__(layer_output: Tensor)

Initialize with the output tensor from the layer where we stopped.

Parameters:

layer_output – The output tensor from the last layer that executed