transformer_lens.components.rms_norm#

Hooked Transformer RMS Norm Component.

This module contains all the component RMSNorm.

class transformer_lens.components.rms_norm.RMSNorm(cfg: Union[Dict, HookedTransformerConfig], length: Optional[int] = None)#

Bases: Module

__init__(cfg: Union[Dict, HookedTransformerConfig], length: Optional[int] = None)#

RMSNorm - LayerNorm without the centering and bias (RMS = Root Mean Square)

length (Optional[int]): If the dimension of the RMSNorm. If not provided, assumed to be d_model

forward(x: Float[Tensor, 'batch pos length']) Float[Tensor, 'batch pos length']#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.