|
from transformers.configuration_utils import PretrainedConfig
|
|
from transformers.utils import logging
|
|
|
|
logger = logging.get_logger(__name__)
|
|
|
|
CYBERAI_PRETRAINED_CONFIG_ARCHIVE_MAP = {
|
|
"CyberCapstone/CyberAI": "https://huggingface.co/CyberCapstone/CyberAI/blob/main/config.json"
|
|
}
|
|
|
|
class CyberAIConfig(PretrainedConfig):
|
|
r"""
|
|
This is the configuration class to store the configuration of a [`CyberAIModel`]. It is used to instantiate a CyberAI
|
|
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
|
defaults will yield a similar configuration to that of the CyberCapstone/CyberAI architecture.
|
|
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
|
documentation from [`PretrainedConfig`] for more information.
|
|
|
|
Args:
|
|
vocab_size (`int`, *optional*, defaults to 65024):
|
|
Vocabulary size of the CyberAI model. Defines the number of different tokens that can be represented by the
|
|
`inputs_ids` passed when calling [`CyberAIModel`].
|
|
hidden_size (`int`, *optional*, defaults to 4096):
|
|
Dimension of the hidden representations.
|
|
num_hidden_layers (`int`, *optional*, defaults to 32):
|
|
Number of hidden layers in the Transformer decoder.
|
|
num_attention_heads (`int`, *optional*, defaults to 64):
|
|
Number of attention heads for each attention layer in the Transformer encoder.
|
|
layer_norm_epsilon (`float`, *optional*, defaults to 1e-05):
|
|
The epsilon used by the layer normalization layers.
|
|
initializer_range (`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 the model should return the last key/values attentions (not used by all models). Only relevant if
|
|
`config.is_decoder=True`.
|
|
hidden_dropout (`float`, *optional*, defaults to 0.1):
|
|
The dropout probability for MLP layers.
|
|
attention_dropout (`float`, *optional*, defaults to 0.1):
|
|
The dropout probability for attention layers.
|
|
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
|
The maximum sequence length that this model might ever be used with.
|
|
pad_token_id (`int`, *optional*, defaults to 0):
|
|
Padding token id.
|
|
bos_token_id (`int`, *optional*, defaults to 1):
|
|
Beginning of stream token id.
|
|
eos_token_id (`int`, *optional*, defaults to 2):
|
|
End of stream token id.
|
|
attention_bias (`bool`, defaults to `True`, *optional*):
|
|
Whether to use a bias in the query, key, value, and output projection layers during self-attention.
|
|
Example:
|
|
```python
|
|
>>> from transformers import CyberAIModel, CyberAIConfig
|
|
>>> # Initializing a CyberCapstone/CyberAI configuration
|
|
>>> configuration = CyberAIConfig()
|
|
>>> # Initializing a model from the configuration
|
|
>>> model = CyberAIModel(configuration)
|
|
>>> # Accessing the model configuration
|
|
>>> configuration = model.config
|
|
```"""
|
|
|
|
model_type = "cyberai"
|
|
keys_to_ignore_at_inference = ["past_key_values"]
|
|
|
|
def __init__(
|
|
self,
|
|
vocab_size=65024,
|
|
hidden_size=4096,
|
|
num_hidden_layers=32,
|
|
num_attention_heads=64,
|
|
layer_norm_epsilon=1e-5,
|
|
initializer_range=0.02,
|
|
use_cache=True,
|
|
hidden_dropout=0.1,
|
|
attention_dropout=0.1,
|
|
max_position_embeddings=2048,
|
|
pad_token_id=0,
|
|
bos_token_id=1,
|
|
eos_token_id=2,
|
|
attention_bias=True,
|
|
**kwargs,
|
|
):
|
|
self.vocab_size = vocab_size
|
|
self.hidden_size = hidden_size
|
|
self.num_hidden_layers = num_hidden_layers
|
|
self.num_attention_heads = num_attention_heads
|
|
self.layer_norm_epsilon = layer_norm_epsilon
|
|
self.initializer_range = initializer_range
|
|
self.use_cache = use_cache
|
|
self.hidden_dropout = hidden_dropout
|
|
self.attention_dropout = attention_dropout
|
|
self.max_position_embeddings = max_position_embeddings
|
|
self.pad_token_id = pad_token_id
|
|
self.bos_token_id = bos_token_id
|
|
self.eos_token_id = eos_token_id
|
|
self.attention_bias = attention_bias
|
|
|
|
super().__init__(
|
|
pad_token_id=pad_token_id,
|
|
bos_token_id=bos_token_id,
|
|
eos_token_id=eos_token_id,
|
|
**kwargs,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
config = CyberAIConfig()
|
|
print(config) |