transformer_lens.conversion_utils.hook_conversion_utils module

Weight conversion utilities.

transformer_lens.conversion_utils.hook_conversion_utils.get_weight_conversion_field_set(weights: dict) str

Creates a formatted string showing how weights are mapped between frameworks.

Parameters:

weights

Dictionary containing weight mappings where: - keys are TransformerLens weight names - values can be:

  • tuple[str, “BaseTensorConversion”]

  • torch.Tensor

  • strings

Returns:

A formatted multi-line string showing each weight’s mapping details.

transformer_lens.conversion_utils.hook_conversion_utils.model_info(model_name)

Displays the weight conversion from HuggingFace to TransformerLens for a given model name.

Parameters:

model_name (str) – Name of the pretrained model to analyze (e.g., ‘gpt2’, ‘bert-base-uncased’, etc.)

transformer_lens.conversion_utils.hook_conversion_utils.model_info_cfg(cfg)

Displays the weight conversion from HuggingFace to TransformerLens for a given model configuration.

Parameters:

cfg – Model configuration object containing architecture information