ysn-rfd commited on
Commit
037c9d3
·
verified ·
1 Parent(s): ef15a39

Delete configuration_yasin.py

Browse files
Files changed (1) hide show
  1. configuration_yasin.py +0 -191
configuration_yasin.py DELETED
@@ -1,191 +0,0 @@
1
- """YASIN model configuration"""
2
-
3
- from transformers.configuration_utils import PretrainedConfig
4
- from transformers.modeling_rope_utils import rope_config_validation
5
-
6
-
7
- class YasinConfig(PretrainedConfig):
8
- r"""
9
- This is the configuration class to store the configuration of a [`YasinModel`]. It is used to instantiate a YASIN
10
- model according to the specified arguments, defining the model architecture.
11
-
12
- Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
13
- documentation from [`PretrainedConfig`] for more information.
14
-
15
- Args:
16
- vocab_size (`int`, *optional*, defaults to 32000):
17
- Vocabulary size of the YASIN model. Defines the number of different tokens that can be represented by the
18
- `inputs_ids` passed when calling [`YasinModel`]
19
- hidden_size (`int`, *optional*, defaults to 4096):
20
- Dimension of the hidden representations.
21
- intermediate_size (`int`, *optional*, defaults to 11008):
22
- Dimension of the MLP representations.
23
- num_hidden_layers (`int`, *optional*, defaults to 32):
24
- Number of hidden layers in the Transformer decoder.
25
- num_attention_heads (`int`, *optional*, defaults to 32):
26
- Number of attention heads for each attention layer in the Transformer decoder.
27
- num_key_value_heads (`int`, *optional*):
28
- This is the number of key_value heads that should be used to implement Grouped Query Attention. If
29
- `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
30
- `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
31
- converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
32
- by meanpooling all the original heads within that group. For more details, check out [this
33
- paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
34
- `num_attention_heads`.
35
- hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
36
- The non-linear activation function (function or string) in the decoder.
37
- max_position_embeddings (`int`, *optional*, defaults to 2048):
38
- The maximum sequence length that this model might ever be used with.
39
- initializer_range (`float`, *optional*, defaults to 0.02):
40
- The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
41
- rms_norm_eps (`float`, *optional*, defaults to 1e-06):
42
- The epsilon used by the rms normalization layers.
43
- use_cache (`bool`, *optional*, defaults to `True`):
44
- Whether or not the model should return the last key/values attentions (not used by all models). Only
45
- relevant if `config.is_decoder=True`.
46
- pad_token_id (`int`, *optional*):
47
- Padding token id.
48
- bos_token_id (`int`, *optional*, defaults to 1):
49
- Beginning of stream token id.
50
- eos_token_id (`int`, *optional*, defaults to 2):
51
- End of stream token id.
52
- pretraining_tp (`int`, *optional*, defaults to 1):
53
- Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
54
- document](https://huggingface.co/docs/transformers/main/perf_train_gpu_many#tensor-parallelism) to
55
- understand more about it. This value is necessary to ensure exact reproducibility of the pretraining
56
- results. Please refer to [this issue](https://github.com/pytorch/pytorch/issues/76232).
57
- tie_word_embeddings (`bool`, *optional*, defaults to `False`):
58
- Whether to tie weight embeddings
59
- rope_theta (`float`, *optional*, defaults to 10000.0):
60
- The base period of the RoPE embeddings.
61
- rope_scaling (`Dict`, *optional*):
62
- Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
63
- and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
64
- accordingly.
65
- Expected contents:
66
- `rope_type` (`str`):
67
- The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
68
- 'llama3'], with 'default' being the original RoPE implementation.
69
- `factor` (`float`, *optional*):
70
- Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
71
- most scaling types, a `factor` of x will enable the model to handle sequences of length x *
72
- original maximum pre-trained length.
73
- `original_max_position_embeddings` (`int`, *optional*):
74
- Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
75
- pretraining.
76
- `attention_factor` (`float`, *optional*):
77
- Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
78
- computation. If unspecified, it defaults to value recommended by the implementation, using the
79
- `factor` field to infer the suggested value.
80
- `beta_fast` (`float`, *optional*):
81
- Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
82
- ramp function. If unspecified, it defaults to 32.
83
- `beta_slow` (`float`, *optional*):
84
- Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
85
- ramp function. If unspecified, it defaults to 1.
86
- `short_factor` (`list[float]`, *optional*):
87
- Only used with 'longrope'. The scaling factor to be applied to short contexts (<
88
- `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
89
- size divided by the number of attention heads divided by 2
90
- `long_factor` (`list[float]`, *optional*):
91
- Only used with 'longrope'. The scaling factor to be applied to long contexts (<
92
- `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
93
- size divided by the number of attention heads divided by 2
94
- `low_freq_factor` (`float`, *optional*):
95
- Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
96
- `high_freq_factor` (`float`, *optional*):
97
- Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
98
- attention_bias (`bool`, *optional*, defaults to `False`):
99
- Whether to use a bias in the query, key, value and output projection layers during self-attention.
100
- attention_dropout (`float`, *optional*, defaults to 0.0):
101
- The dropout ratio for the attention probabilities.
102
- mlp_bias (`bool`, *optional*, defaults to `False`):
103
- Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.
104
- head_dim (`int`, *optional*):
105
- The attention head dimension. If None, it will default to hidden_size // num_attention_heads
106
-
107
- """
108
-
109
- model_type = "yasin"
110
- keys_to_ignore_at_inference = ["past_key_values"]
111
- # Default tensor parallel plan for base model `YasinModel`
112
- base_model_tp_plan = {
113
- "layers.*.self_attn.q_proj": "colwise",
114
- "layers.*.self_attn.k_proj": "colwise",
115
- "layers.*.self_attn.v_proj": "colwise",
116
- "layers.*.self_attn.o_proj": "rowwise",
117
- "layers.*.mlp.gate_proj": "colwise",
118
- "layers.*.mlp.up_proj": "colwise",
119
- "layers.*.mlp.down_proj": "rowwise",
120
- }
121
- base_model_pp_plan = {
122
- "embed_tokens": (["input_ids"], ["inputs_embeds"]),
123
- "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
124
- "norm": (["hidden_states"], ["hidden_states"]),
125
- }
126
-
127
- def __init__(
128
- self,
129
- vocab_size=32000,
130
- hidden_size=4096,
131
- intermediate_size=11008,
132
- num_hidden_layers=32,
133
- num_attention_heads=32,
134
- num_key_value_heads=None,
135
- hidden_act="silu",
136
- max_position_embeddings=2048,
137
- initializer_range=0.02,
138
- rms_norm_eps=1e-6,
139
- use_cache=True,
140
- pad_token_id=None,
141
- bos_token_id=1,
142
- eos_token_id=2,
143
- pretraining_tp=1,
144
- tie_word_embeddings=False,
145
- rope_theta=10000.0,
146
- rope_scaling=None,
147
- attention_bias=False,
148
- attention_dropout=0.0,
149
- mlp_bias=False,
150
- head_dim=None,
151
- **kwargs,
152
- ):
153
- self.vocab_size = vocab_size
154
- self.max_position_embeddings = max_position_embeddings
155
- self.hidden_size = hidden_size
156
- self.intermediate_size = intermediate_size
157
- self.num_hidden_layers = num_hidden_layers
158
- self.num_attention_heads = num_attention_heads
159
-
160
- # for backward compatibility
161
- if num_key_value_heads is None:
162
- num_key_value_heads = num_attention_heads
163
-
164
- self.num_key_value_heads = num_key_value_heads
165
- self.hidden_act = hidden_act
166
- self.initializer_range = initializer_range
167
- self.rms_norm_eps = rms_norm_eps
168
- self.pretraining_tp = pretraining_tp
169
- self.use_cache = use_cache
170
- self.rope_theta = rope_theta
171
- self.rope_scaling = rope_scaling
172
- self.attention_bias = attention_bias
173
- self.attention_dropout = attention_dropout
174
- self.mlp_bias = mlp_bias
175
- self.head_dim = head_dim if head_dim is not None else self.hidden_size // self.num_attention_heads
176
- # Validate the correctness of rotary position embeddings parameters
177
- # BC: if there is a 'type' field, copy it it to 'rope_type'.
178
- if self.rope_scaling is not None and "type" in self.rope_scaling:
179
- self.rope_scaling["rope_type"] = self.rope_scaling["type"]
180
- rope_config_validation(self)
181
-
182
- super().__init__(
183
- pad_token_id=pad_token_id,
184
- bos_token_id=bos_token_id,
185
- eos_token_id=eos_token_id,
186
- tie_word_embeddings=tie_word_embeddings,
187
- **kwargs,
188
- )
189
-
190
-
191
- __all__ = ["YasinConfig"]