muverqqw commited on
Commit
bc3697f
·
1 Parent(s): 598ebaa

Update configuration_alinlight.py

Browse files
Files changed (1) hide show
  1. configuration_alinlight.py +115 -63
configuration_alinlight.py CHANGED
@@ -1,63 +1,115 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright 2026 EngineerGL Research.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- from transformers import PretrainedConfig
17
-
18
- class AlinlightConfig(PretrainedConfig):
19
- model_type = "alinlight"
20
-
21
- def __init__(
22
- self,
23
- vocab_size=128000,
24
- hidden_size=2048,
25
- intermediate_size=5632,
26
- num_hidden_layers=22,
27
- num_attention_heads=32,
28
- num_key_value_heads=8,
29
- max_position_embeddings=4096,
30
- sliding_window=4096,
31
- attention_dropout=0.0,
32
- rms_norm_eps=1e-5,
33
- rope_theta=10000.0,
34
- rope_scaling=None,
35
- initializer_range=0.02,
36
- use_cache=True,
37
- pad_token_id=0,
38
- bos_token_id=1,
39
- eos_token_id=2,
40
- tie_word_embeddings=True,
41
- **kwargs,
42
- ):
43
- super().__init__(
44
- pad_token_id=pad_token_id,
45
- bos_token_id=bos_token_id,
46
- eos_token_id=eos_token_id,
47
- tie_word_embeddings=tie_word_embeddings,
48
- **kwargs
49
- )
50
- self.vocab_size = vocab_size
51
- self.hidden_size = hidden_size
52
- self.intermediate_size = intermediate_size
53
- self.num_hidden_layers = num_hidden_layers
54
- self.num_attention_heads = num_attention_heads
55
- self.num_key_value_heads = num_key_value_heads
56
- self.max_position_embeddings = max_position_embeddings
57
- self.sliding_window = sliding_window
58
- self.attention_dropout = attention_dropout
59
- self.rms_norm_eps = rms_norm_eps
60
- self.rope_theta = rope_theta
61
- self.rope_scaling = rope_scaling
62
- self.initializer_range = initializer_range
63
- self.use_cache = use_cache
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2026 EngineerGL Research.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from transformers import PretrainedConfig
17
+
18
+ class AlinlightConfig(PretrainedConfig):
19
+ """
20
+ Configuration class for Alinlight model.
21
+
22
+ Args:
23
+ vocab_size (int): Vocabulary size of the model.
24
+ hidden_size (int): Dimensionality of the encoder layers and the pooler layer.
25
+ intermediate_size (int): Dimensionality of the "intermediate" (i.e., feed-forward) layer.
26
+ num_hidden_layers (int): Number of hidden layers in the Transformer encoder.
27
+ num_attention_heads (int): Number of attention heads for each attention layer.
28
+ num_key_value_heads (int): Number of key/value heads for Grouped Query Attention.
29
+ max_position_embeddings (int): The maximum sequence length that this model might ever be used with.
30
+ rope_theta (float): The base period of the RoPE embeddings.
31
+ rope_scaling (dict, optional): Dictionary containing the scaling configuration for the RoPE embeddings.
32
+ sliding_window (int, optional): Sliding window size for local attention. None to disable.
33
+ attention_dropout (float): The dropout ratio for the attention probabilities.
34
+ use_qk_norm (bool): Whether to apply RMSNorm to Query and Key matrices.
35
+ attn_logit_softcapping (float, optional): If set, applies tanh soft-capping to attention logits (Gemma-2 style).
36
+ rms_norm_eps (float): The epsilon used by the rms normalization layers.
37
+ initializer_range (float): The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
38
+ resid_pdrop (float): The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
39
+ embed_pdrop (float): The dropout probability for the embedding layer.
40
+ embed_scale (bool): Whether to scale embeddings by sqrt(hidden_size).
41
+ final_logit_softcapping (float, optional): If set, applies tanh soft-capping to final LM head logits.
42
+ z_loss_weight (float): Coefficient for the Z-loss regularization term (stabilizes final logits).
43
+ """
44
+ model_type = "alinlight"
45
+
46
+ def __init__(
47
+ self,
48
+ # Architecture
49
+ vocab_size=128000,
50
+ hidden_size=2048,
51
+ intermediate_size=5632,
52
+ num_hidden_layers=22,
53
+ num_attention_heads=32,
54
+ num_key_value_heads=8,
55
+
56
+ # Positional Encoding
57
+ max_position_embeddings=4096,
58
+ rope_theta=10000.0,
59
+ rope_scaling=None,
60
+
61
+ # Attention
62
+ sliding_window=None,
63
+ attention_dropout=0.0,
64
+ use_qk_norm=True,
65
+ attn_logit_softcapping=50.0,
66
+
67
+ # Normalization & Regularization
68
+ rms_norm_eps=1e-6,
69
+ initializer_range=0.02,
70
+ resid_pdrop=0.0,
71
+ embed_pdrop=0.0,
72
+
73
+ # Stability Features
74
+ embed_scale=True,
75
+ final_logit_softcapping=30.0,
76
+ z_loss_weight=1e-4,
77
+
78
+ # System
79
+ use_cache=True,
80
+ pad_token_id=0,
81
+ bos_token_id=1,
82
+ eos_token_id=2,
83
+ tie_word_embeddings=True,
84
+
85
+ **kwargs,
86
+ ):
87
+ self.vocab_size = vocab_size
88
+ self.hidden_size = hidden_size
89
+ self.intermediate_size = intermediate_size
90
+ self.num_hidden_layers = num_hidden_layers
91
+ self.num_attention_heads = num_attention_heads
92
+ self.num_key_value_heads = num_key_value_heads
93
+ self.max_position_embeddings = max_position_embeddings
94
+ self.rope_theta = rope_theta
95
+ self.rope_scaling = rope_scaling
96
+ self.sliding_window = sliding_window
97
+ self.attention_dropout = attention_dropout
98
+ self.use_qk_norm = use_qk_norm
99
+ self.attn_logit_softcapping = attn_logit_softcapping
100
+ self.rms_norm_eps = rms_norm_eps
101
+ self.initializer_range = initializer_range
102
+ self.resid_pdrop = resid_pdrop
103
+ self.embed_pdrop = embed_pdrop
104
+ self.embed_scale = embed_scale
105
+ self.final_logit_softcapping = final_logit_softcapping
106
+ self.z_loss_weight = z_loss_weight
107
+ self.use_cache = use_cache
108
+
109
+ super().__init__(
110
+ pad_token_id=pad_token_id,
111
+ bos_token_id=bos_token_id,
112
+ eos_token_id=eos_token_id,
113
+ tie_word_embeddings=tie_word_embeddings,
114
+ **kwargs
115
+ )