Commit
·
e37f4c9
1
Parent(s):
cc0f9c4
Upload config
Browse files- config.json +53 -0
- configuration_gia2.py +130 -0
config.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_new",
|
| 3 |
+
"attention_dropout": 0.0,
|
| 4 |
+
"attention_layers": [
|
| 5 |
+
"global",
|
| 6 |
+
"local",
|
| 7 |
+
"global",
|
| 8 |
+
"local",
|
| 9 |
+
"global",
|
| 10 |
+
"local",
|
| 11 |
+
"global",
|
| 12 |
+
"local",
|
| 13 |
+
"global",
|
| 14 |
+
"local",
|
| 15 |
+
"global",
|
| 16 |
+
"local"
|
| 17 |
+
],
|
| 18 |
+
"attention_types": [
|
| 19 |
+
[
|
| 20 |
+
[
|
| 21 |
+
"global",
|
| 22 |
+
"local"
|
| 23 |
+
],
|
| 24 |
+
6
|
| 25 |
+
]
|
| 26 |
+
],
|
| 27 |
+
"auto_map": {
|
| 28 |
+
"AutoConfig": "configuration_gia2.Gia2Config"
|
| 29 |
+
},
|
| 30 |
+
"bos_token_id": 50256,
|
| 31 |
+
"classifier_dropout": 0.1,
|
| 32 |
+
"embed_dropout": 0.0,
|
| 33 |
+
"eos_token_id": 50256,
|
| 34 |
+
"hidden_size": 768,
|
| 35 |
+
"image_size": 224,
|
| 36 |
+
"initializer_range": 0.02,
|
| 37 |
+
"intermediate_size": null,
|
| 38 |
+
"layer_norm_epsilon": 1e-05,
|
| 39 |
+
"max_continuous_size": 377,
|
| 40 |
+
"max_discrete_value": 18,
|
| 41 |
+
"max_position_embeddings": 2048,
|
| 42 |
+
"model_type": "gia2",
|
| 43 |
+
"num_channels": 3,
|
| 44 |
+
"num_heads": 12,
|
| 45 |
+
"num_layers": 12,
|
| 46 |
+
"patch_size": 16,
|
| 47 |
+
"resid_dropout": 0.0,
|
| 48 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 49 |
+
"transformers_version": "4.29.1",
|
| 50 |
+
"use_cache": true,
|
| 51 |
+
"vocab_size": 50257,
|
| 52 |
+
"window_size": 256
|
| 53 |
+
}
|
configuration_gia2.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import GPTNeoConfig
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class Gia2Config(GPTNeoConfig):
|
| 5 |
+
r"""
|
| 6 |
+
This is the configuration class to store the configuration of a [`Gia2Model`]. It is used to instantiate a Gia2
|
| 7 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with
|
| 8 |
+
the defaults will yield a similar configuration to that of the ... (TODO)
|
| 9 |
+
|
| 10 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 11 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Args:
|
| 15 |
+
vocab_size (`int`, *optional*, defaults to 50257):
|
| 16 |
+
Vocabulary size of the GPT Neo model. Defines the number of different tokens that can be represented by the
|
| 17 |
+
`inputs_ids` passed when calling [`GPTNeoModel`]. Vocabulary size of the model. Defines the different
|
| 18 |
+
tokens that can be represented by the *inputs_ids* passed to the forward method of [`GPTNeoModel`].
|
| 19 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
| 20 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
| 21 |
+
just in case (e.g., 512 or 1024 or 2048).
|
| 22 |
+
hidden_size (`int`, *optional*, defaults to 2048):
|
| 23 |
+
Dimensionality of the encoder layers and the pooler layer.
|
| 24 |
+
num_layers (`int`, *optional*, defaults to 24):
|
| 25 |
+
Number of hidden layers in the Transformer encoder.
|
| 26 |
+
attention_types (`List`, *optional*, defaults to `[[["global", "local"], 12]]`):
|
| 27 |
+
The type of attention for each layer in a `List` of the following format `[[["attention_type"],
|
| 28 |
+
num_layerss]]` e.g. for a 24 layer model `[[["global"], 24]]` or `[[["global", "local"], 12]]` Choose the
|
| 29 |
+
value of `attention_type` from `["global", "local"]`
|
| 30 |
+
num_heads (`int`, *optional*, defaults to 16):
|
| 31 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 32 |
+
intermediate_size (`int`, *optional*, defaults to 8192):
|
| 33 |
+
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
|
| 34 |
+
window_size (`int`, *optional*, defaults to 256):
|
| 35 |
+
The size of the sliding window for local attention.
|
| 36 |
+
activation_function (`str` or `function`, *optional*, defaults to `"gelu_new"`):
|
| 37 |
+
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
|
| 38 |
+
`"relu"`, `"selu"` and `"gelu_new"` are supported.
|
| 39 |
+
resid_dropout (`float`, *optional*, defaults to 0.0):
|
| 40 |
+
Residual dropout used in the attention pattern.
|
| 41 |
+
embed_dropout (`float`, *optional*, defaults to 0.0):
|
| 42 |
+
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.
|
| 43 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 44 |
+
The dropout ratio for the attention probabilities.
|
| 45 |
+
classifier_dropout (`float`, *optional*, defaults to 0.1):
|
| 46 |
+
Argument used when doing token classification, used in the model [`GPTNeoForTokenClassification`]. The
|
| 47 |
+
dropout ratio for the hidden layer.
|
| 48 |
+
layer_norm_epsilon (`float`, *optional*, defaults to 1e-5):
|
| 49 |
+
The epsilon used by the layer normalization layers.
|
| 50 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 51 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 52 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 53 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 54 |
+
relevant if `config.is_decoder=True`.
|
| 55 |
+
bos_token_id (`int`, *optional*, defaults to 50256):
|
| 56 |
+
The id of the beginning of sentence token in the vocabulary.
|
| 57 |
+
eos_token_id (`int`, *optional*, defaults to 50256):
|
| 58 |
+
The id of the end of sentence token in the vocabulary.
|
| 59 |
+
max_continuous_size (`int`, *optional*, default to 376):
|
| 60 |
+
The maximum size of the continuous values.
|
| 61 |
+
max_discrete_value (`int`, *optional*, default to 18):
|
| 62 |
+
The maximum value of the discrete values.
|
| 63 |
+
image_size (`int`, *optional*, defaults to 224):
|
| 64 |
+
The size (resolution) of each image.
|
| 65 |
+
patch_size (`int`, *optional*, defaults to 16):
|
| 66 |
+
The size (resolution) of each patch.
|
| 67 |
+
tokenizer_class (`str`, *optional*, defaults to `"GPT2Tokenizer"`):
|
| 68 |
+
The name of the tokenizer class to use.
|
| 69 |
+
"""
|
| 70 |
+
|
| 71 |
+
model_type = "gia2"
|
| 72 |
+
|
| 73 |
+
def __init__(
|
| 74 |
+
self,
|
| 75 |
+
vocab_size=50257,
|
| 76 |
+
max_position_embeddings=2048,
|
| 77 |
+
hidden_size=2048,
|
| 78 |
+
num_layers=24,
|
| 79 |
+
attention_types=[[["global", "local"], 12]],
|
| 80 |
+
num_heads=16,
|
| 81 |
+
intermediate_size=None,
|
| 82 |
+
window_size=256,
|
| 83 |
+
activation_function="gelu_new",
|
| 84 |
+
resid_dropout=0.0,
|
| 85 |
+
embed_dropout=0.0,
|
| 86 |
+
attention_dropout=0.0,
|
| 87 |
+
classifier_dropout=0.1,
|
| 88 |
+
layer_norm_epsilon=1e-5,
|
| 89 |
+
initializer_range=0.02,
|
| 90 |
+
use_cache=True,
|
| 91 |
+
bos_token_id=50256,
|
| 92 |
+
eos_token_id=50256,
|
| 93 |
+
max_continuous_size=377,
|
| 94 |
+
max_discrete_value=18,
|
| 95 |
+
image_size=224,
|
| 96 |
+
num_channels=3,
|
| 97 |
+
patch_size=16,
|
| 98 |
+
tokenizer_class="GPT2Tokenizer",
|
| 99 |
+
**kwargs,
|
| 100 |
+
):
|
| 101 |
+
super().__init__(
|
| 102 |
+
vocab_size,
|
| 103 |
+
max_position_embeddings,
|
| 104 |
+
hidden_size,
|
| 105 |
+
num_layers,
|
| 106 |
+
attention_types,
|
| 107 |
+
num_heads,
|
| 108 |
+
intermediate_size,
|
| 109 |
+
window_size,
|
| 110 |
+
activation_function,
|
| 111 |
+
resid_dropout,
|
| 112 |
+
embed_dropout,
|
| 113 |
+
attention_dropout,
|
| 114 |
+
classifier_dropout,
|
| 115 |
+
layer_norm_epsilon,
|
| 116 |
+
initializer_range,
|
| 117 |
+
use_cache,
|
| 118 |
+
bos_token_id,
|
| 119 |
+
eos_token_id,
|
| 120 |
+
tokenizer_class=tokenizer_class,
|
| 121 |
+
**kwargs,
|
| 122 |
+
)
|
| 123 |
+
self.max_continuous_size = max_continuous_size
|
| 124 |
+
self.max_discrete_value = max_discrete_value
|
| 125 |
+
self.image_size = image_size
|
| 126 |
+
self.num_channels = num_channels
|
| 127 |
+
self.patch_size = patch_size
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
Gia2Config.register_for_auto_class()
|