transformer_lens.components.bert_nsp_head#
Hooked Encoder Bert NSP Head Component.
This module contains all the component BertNSPHead
.
- class transformer_lens.components.bert_nsp_head.BertNSPHead(cfg: Union[Dict, HookedTransformerConfig])#
Bases:
Module
Transforms BERT embeddings into logits. The purpose of this module is to predict whether or not sentence B follows sentence A.
- forward(resid: Float[Tensor, 'batch d_model']) Float[Tensor, 'batch 2'] #
Define 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.