MCPcopy Create free account
hub / github.com/SooLab/CGFormer / BertConfig

Class BertConfig

bert/configuration_bert.py:53–143  ·  view source on GitHub ↗

r""" This is the configuration class to store the configuration of a :class:`~transformers.BertModel`. It is used to instantiate an BERT model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a s

Source from the content-addressed store, hash-verified

51
52
53class BertConfig(PretrainedConfig):
54 r"""
55 This is the configuration class to store the configuration of a :class:`~transformers.BertModel`.
56 It is used to instantiate an BERT model according to the specified arguments, defining the model
57 architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of
58 the BERT `bert-base-uncased <https://huggingface.co/bert-base-uncased>`__ architecture.
59
60 Configuration objects inherit from :class:`~transformers.PretrainedConfig` and can be used
61 to control the model outputs. Read the documentation from :class:`~transformers.PretrainedConfig`
62 for more information.
63
64
65 Args:
66 vocab_size (:obj:`int`, optional, defaults to 30522):
67 Vocabulary size of the BERT model. Defines the different tokens that
68 can be represented by the `inputs_ids` passed to the forward method of :class:`~transformers.BertModel`.
69 hidden_size (:obj:`int`, optional, defaults to 768):
70 Dimensionality of the encoder layers and the pooler layer.
71 num_hidden_layers (:obj:`int`, optional, defaults to 12):
72 Number of hidden layers in the Transformer encoder.
73 num_attention_heads (:obj:`int`, optional, defaults to 12):
74 Number of attention heads for each attention layer in the Transformer encoder.
75 intermediate_size (:obj:`int`, optional, defaults to 3072):
76 Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
77 hidden_act (:obj:`str` or :obj:`function`, optional, defaults to "gelu"):
78 The non-linear activation function (function or string) in the encoder and pooler.
79 If string, "gelu", "relu", "swish" and "gelu_new" are supported.
80 hidden_dropout_prob (:obj:`float`, optional, defaults to 0.1):
81 The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.
82 attention_probs_dropout_prob (:obj:`float`, optional, defaults to 0.1):
83 The dropout ratio for the attention probabilities.
84 max_position_embeddings (:obj:`int`, optional, defaults to 512):
85 The maximum sequence length that this model might ever be used with.
86 Typically set this to something large just in case (e.g., 512 or 1024 or 2048).
87 type_vocab_size (:obj:`int`, optional, defaults to 2):
88 The vocabulary size of the `token_type_ids` passed into :class:`~transformers.BertModel`.
89 initializer_range (:obj:`float`, optional, defaults to 0.02):
90 The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
91 layer_norm_eps (:obj:`float`, optional, defaults to 1e-12):
92 The epsilon used by the layer normalization layers.
93 gradient_checkpointing (:obj:`bool`, optional, defaults to False):
94 If True, use gradient checkpointing to save memory at the expense of slower backward pass.
95
96 Example::
97
98 >>> from transformers import BertModel, BertConfig
99
100 >>> # Initializing a BERT bert-base-uncased style configuration
101 >>> configuration = BertConfig()
102
103 >>> # Initializing a model from the bert-base-uncased style configuration
104 >>> model = BertModel(configuration)
105
106 >>> # Accessing the model configuration
107 >>> configuration = model.config
108 """
109 model_type = "bert"
110

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected