megatron.model.biencoder_model.PretrainedBertModel#
- class megatron.model.biencoder_model.PretrainedBertModel(num_tokentypes=2, parallel_output=True, pre_process=True, post_process=True, model_type=None)#
Bases:
MegatronModule
BERT-based encoder for queries or contexts used for learned information retrieval.
- forward(input_ids, attention_mask, tokentype_ids=None)#
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.
- load_state_dict(state_dict, strict=True)#
Customized load.
- state_dict_for_save_checkpoint(prefix='', keep_vars=False)#
For easy load when model is combined with other heads, add an extra key.