transformer_lens.components.bert_pooler#
Hooked Encoder Bert Pooler Component.
This module contains all the component BertPooler
.
- class transformer_lens.components.bert_pooler.BertPooler(cfg: Union[Dict, HookedTransformerConfig])#
Bases:
Module
Transforms the [CLS] token representation into a fixed-size sequence embedding. The purpose of this module is to convert variable-length sequence inputs into a single vector representation suitable for downstream tasks. (e.g. Next Sentence Prediction)
- forward(resid: Float[Tensor, 'batch pos d_model']) Float[Tensor, 'batch d_model'] #
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.