megatron.model.bert_model.BertModel#
- class megatron.model.bert_model.BertModel(num_tokentypes: int = 2, add_binary_head=True, parallel_output=True, pre_process=True, post_process=True, model_type=None)#
Bases:
MegatronModule
Bert Language model.
- forward(bert_model_input, attention_mask, tokentype_ids=None, lm_labels=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.
- set_input_tensor(input_tensor)#
See megatron.model.transformer.set_input_tensor()
- state_dict_for_save_checkpoint(prefix='', keep_vars=False)#
For easy load when model is combined with other heads, add an extra key.