transformer_lens.model_bridge.get_params_util module

Utility function for getting model parameters in TransformerLens format.

transformer_lens.model_bridge.get_params_util.get_bridge_params(bridge) Dict[str, Tensor]

Model parameters in SVDInterpreter format.

Reads the bridge components’ TL-layout weight properties (W_Q, W_in, …), which already account for layout conversion and weight processing. For missing weights, returns zero tensors of appropriate shape instead of raising exceptions. Skips attn keys for non-attention layers. LayerNorm params (blocks.{i}.ln1.w etc.) are included when the modules still carry them (i.e. before folding) so consumers can detect fold state.

Returns:

Dictionary of parameter tensors with TransformerLens naming convention

Return type:

dict

Raises:

ValueError – If configuration is inconsistent (e.g., cfg.n_layers != len(blocks))