easydel.modules.opt.opt_configuration#
- class easydel.modules.opt.opt_configuration.OPTConfig(vocab_size: int = 50272, hidden_size: int = 768, num_hidden_layers: int = 12, ffn_dim: int = 3072, max_position_embeddings: int = 2048, do_layer_norm_before: bool = True, _remove_final_layer_norm: bool = False, word_embed_proj_dim: int = None, dropout: float = 0.1, attention_dropout: float = 0.0, num_attention_heads: int = 12, activation_function: str = 'relu', layerdrop: float = 0.0, init_std: float = 0.02, use_cache: bool = True, pad_token_id: int = 1, bos_token_id: int = 2, eos_token_id: int = 2, enable_bias: bool = True, layer_norm_elementwise_affine: bool = True, gradient_checkpointing: EasyDeLGradientCheckPointers = EasyDeLGradientCheckPointers.NONE, **kwargs)[source]#
Bases:
EasyDeLBaseConfigConfiguration objects inherit from [EasyDeLBaseConfig] and can be used to control the model outputs. Read the documentation from [EasyDeLBaseConfig] for more information.
- Parameters
vocab_size (int, optional, defaults to 50272) โ Vocabulary size of the OPT model. Defines the number of different tokens that can be represented by the inputs_ids passed to the forward method.
hidden_size (int, optional, defaults to 768) โ Dimensionality of the encoder layers and the pooler layer.
num_hidden_layers (int, optional, defaults to 12) โ Number of hidden layers in the Transformer encoder.
ffn_dim (int, optional, defaults to 3072) โ Dimensionality of the โintermediateโ (i.e., feed-forward) layer in the Transformer encoder.
max_position_embeddings (int, optional, defaults to 2048) โ The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 2048).
do_layer_norm_before (bool, optional, defaults to True) โ Whether to perform layer normalization before the attention block.
_remove_final_layer_norm (bool, optional, defaults to False) โ Whether to remove the final layer norm.
word_embed_proj_dim (int, optional) โ The dimension of the word embedding projection. If not provided, it will default to hidden_size.
dropout (float, optional, defaults to 0.1) โ The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
attention_dropout (float, optional, defaults to 0.0) โ The dropout ratio for the attention probabilities.
num_attention_heads (int, optional, defaults to 12) โ Number of attention heads for each attention layer in the Transformer encoder.
activation_function (str or function, optional, defaults to โreluโ) โ The non-linear activation function (function or string) to use in the encoder and pooler. If string, โgeluโ, โreluโ, โswishโ and โgelu_newโ are supported.
layerdrop (float, optional, defaults to 0.0) โ The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556) for more details.
init_std (float, optional, defaults to 0.02) โ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
use_cache (bool, optional, defaults to True) โ Whether or not the model should return the last key/values attentions (not used by all models). Only relevant if config.is_decoder=True.
pad_token_id (int, optional, defaults to 1) โ The index of the padding token in the vocabulary.
bos_token_id (int, optional, defaults to 2) โ The id of the beginning-of-sequence token.
eos_token_id (int, optional, defaults to 2) โ The id of the end-of-sequence token.
enable_bias (bool, optional, defaults to True) โ Whether to use bias in the linear layers.
layer_norm_elementwise_affine (bool, optional, defaults to True) โ Whether to use elementwise affine in the layer normalization layers.
gradient_checkpointing (str, optional, defaults to โnothing_saveableโ) โ The gradient checkpointing configuration.
- attach_custom_arguments(vocab_size: int = 50272, hidden_size: int = 768, num_hidden_layers: int = 12, ffn_dim: int = 3072, max_position_embeddings: int = 2048, do_layer_norm_before: bool = True, _remove_final_layer_norm: bool = False, word_embed_proj_dim: int = None, dropout: float = 0.1, attention_dropout: float = 0.0, num_attention_heads: int = 12, activation_function: str = 'relu', layerdrop: float = 0.0, init_std: float = 0.02, use_cache: bool = True, pad_token_id: int = 1, bos_token_id: int = 2, eos_token_id: int = 2, enable_bias: bool = True, layer_norm_elementwise_affine: bool = True, gradient_checkpointing: EasyDeLGradientCheckPointers = EasyDeLGradientCheckPointers.NONE, **kwargs)[source]#
Attaches custom arguments to the configuration object.
This method allows dynamically adding or overriding configuration attributes. It iterates through the provided arguments and sets them as attributes of the configuration object if they donโt already exist.
- Parameters
vocab_size (int, optional) โ Vocabulary size. Defaults to 50272.
hidden_size (int, optional) โ Dimensionality of the encoder layers. Defaults to 768.
num_hidden_layers (int, optional) โ Number of hidden layers. Defaults to 12.
ffn_dim (int, optional) โ Dimensionality of the feed-forward layer. Defaults to 3072.
max_position_embeddings (int, optional) โ Maximum sequence length. Defaults to 2048.
do_layer_norm_before (bool, optional) โ Whether to apply layer norm before attention. Defaults to True.
_remove_final_layer_norm (bool, optional) โ Whether to remove the final layer norm. Defaults to False.
word_embed_proj_dim (int, optional) โ Dimension of the word embedding projection. Defaults to hidden_size.
dropout (float, optional) โ Dropout probability. Defaults to 0.1.
attention_dropout (float, optional) โ Attention dropout probability. Defaults to 0.0.
num_attention_heads (int, optional) โ Number of attention heads. Defaults to 12.
activation_function (str, optional) โ Activation function name. Defaults to โreluโ.
layerdrop (float, optional) โ LayerDrop probability. Defaults to 0.0.
init_std (float, optional) โ Initialization standard deviation. Defaults to 0.02.
use_cache (bool, optional) โ Whether to use key/value cache. Defaults to True.
pad_token_id (int, optional) โ Padding token ID. Defaults to 1.
bos_token_id (int, optional) โ Beginning-of-sequence token ID. Defaults to 2.
eos_token_id (int, optional) โ End-of-sequence token ID. Defaults to 2.
enable_bias (bool, optional) โ Whether to use bias in linear layers. Defaults to True.
layer_norm_elementwise_affine (bool, optional) โ Whether layer norm uses elementwise affine parameters. Defaults to True.
gradient_checkpointing (EasyDeLGradientCheckPointers, optional) โ Gradient checkpointing strategy. Defaults to EasyDeLGradientCheckPointers.NONE.
**kwargs โ Additional keyword arguments to attach.
- get_partition_rules(fully_sharded_data_parallel: bool = True)[source]#
Get the partition rules for the model.
- Parameters
fully_sharded_data_parallel (bool, optional, defaults to True) โ Whether to use fully sharded data parallelism.
- Returns
The partition rules.
- Return type
tp.Tuple[tp.Tuple[str, PartitionSpec]]
- keys_to_ignore_at_inference = ['past_key_values']#
- model_type: str = 'opt'#