create_bert_mlm#

composer.models.create_bert_mlm(use_pretrained=False, pretrained_model_name=None, model_config=None, tokenizer_name=None, gradient_checkpointing=False)[source]#

BERT model based on ๐Ÿค— Transformers.

For more information, see Transformers.

Args:

gradient_checkpointing (bool, optional): Use gradient checkpointing. Default: False. use_pretrained (bool, optional): Whether to initialize the model with the pretrained weights. Default: False. model_config (dict): The settings used to create a Hugging Face BertConfig. BertConfig is used to specify the architecture of a Hugging Face model. tokenizer_name (transformers.BertTokenizer, optional): Tokenizer name used to preprocess the dataset and validate the models inputs.

{
  "_name_or_path": "bert-base-uncased",
  "architectures": ["BertForMaskedLM"],
  "attention_probs_dropout_prob": 0.1,
  "classifier_dropout": null,
  "gradient_checkpointing": false,
  "hidden_act": "gelu",
  "hidden_dropout_prob": 0.1,
  "hidden_size": 768,
  "initializer_range": 0.02,
  "intermediate_size": 3072,
  "layer_norm_eps": 1e-12,
  "max_position_embeddings": 512,
  "model_type": "bert",
  "num_attention_heads": 12,
  "num_hidden_layers": 12,
  "pad_token_id": 0,
  "position_embedding_type": "absolute",
  "transformers_version": "4.16.0",
  "type_vocab_size": 2,
  "use_cache": true,
  "vocab_size": 30522
}

To create a BERT model for Masked Language Model pretraining:

from composer.models import create_bert_mlm
model = create_bert_mlm()