Prompt48 commited on
Commit
d1e3090
·
verified ·
1 Parent(s): 5c17210

Upload edit\Qwen3-TTS-test\.venv\Lib\site-packages\transformers\models\helium\configuration_helium.py with huggingface_hub

Browse files
edit//Qwen3-TTS-test//.venv//Lib//site-packages//transformers//models//helium//configuration_helium.py ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The Kyutai and HuggingFace Inc. teams. All rights reserved.
3
+ #
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ from ...configuration_utils import PretrainedConfig
18
+
19
+
20
+ class HeliumConfig(PretrainedConfig):
21
+ r"""
22
+ This is the configuration class to store the configuration of a [`HeliumModel`]. It is used to instantiate an Helium
23
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
24
+ defaults will yield a similar configuration to that of the Helium 2b model.
25
+ e.g. [kyutai/helium-2b](https://huggingface.co/kyutai/helium-2b)
26
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
27
+ documentation from [`PretrainedConfig`] for more information.
28
+ Args:
29
+ vocab_size (`int`, *optional*, defaults to 48000):
30
+ Vocabulary size of the Helium model. Defines the number of different tokens that can be represented by the
31
+ `inputs_ids` passed when calling [`HeliumModel`]
32
+ hidden_size (`int`, *optional*, defaults to 2560):
33
+ Dimension of the hidden representations.
34
+ intermediate_size (`int`, *optional*, defaults to 7040):
35
+ Dimension of the MLP representations.
36
+ num_hidden_layers (`int`, *optional*, defaults to 24):
37
+ Number of hidden layers in the Transformer decoder.
38
+ num_attention_heads (`int`, *optional*, defaults to 20):
39
+ Number of attention heads for each attention layer in the Transformer decoder.
40
+ num_key_value_heads (`int`, *optional*, defaults to 20):
41
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
42
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
43
+ `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
44
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
45
+ by meanpooling all the original heads within that group. For more details, check out [this
46
+ paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
47
+ `num_attention_heads`.
48
+ head_dim (`int`, *optional*, defaults to 128):
49
+ The attention head dimension.
50
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
51
+ The legacy activation function. It is overwritten by the `hidden_activation`.
52
+ attention_dropout (`float`, *optional*, defaults to 0.0):
53
+ The dropout ratio for the attention probabilities.
54
+ max_position_embeddings (`int`, *optional*, defaults to 4096):
55
+ The maximum sequence length that this model might ever be used with.
56
+ initializer_range (`float`, *optional*, defaults to 0.02):
57
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
58
+ rms_norm_eps (`float`, *optional*, defaults to 1e-08):
59
+ The epsilon used by the rms normalization layers.
60
+ use_cache (`bool`, *optional*, defaults to `True`):
61
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
62
+ relevant if `config.is_decoder=True`.
63
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
64
+ Whether to tie weight embeddings
65
+ rope_theta (`float`, *optional*, defaults to 100000.0):
66
+ The base period of the RoPE embeddings.
67
+ pad_token_id (`int`, *optional*, defaults to 3):
68
+ Padding token id.
69
+ eos_token_id (`int` | `list`, *optional*, defaults to 2):
70
+ End of stream token id.
71
+ bos_token_id (`int`, *optional*, defaults to 1):
72
+ Beginning of stream token id.
73
+ attention_bias (`bool`, *optional*, defaults to `False`):
74
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
75
+ mlp_bias (`bool`, *optional*, defaults to `False`):
76
+ Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.
77
+ ```python
78
+ >>> from transformers import HeliumModel, HeliumConfig
79
+ >>> # Initializing a Helium 2b style configuration
80
+ >>> configuration = HeliumConfig()
81
+ >>> # Initializing a model from the Helium 2b style configuration
82
+ >>> model = HeliumModel(configuration)
83
+ >>> # Accessing the model configuration
84
+ >>> configuration = model.config
85
+ ```"""
86
+
87
+ model_type = "helium"
88
+ keys_to_ignore_at_inference = ["past_key_values"]
89
+ base_model_tp_plan = {
90
+ "layers.*.self_attn.q_proj": "colwise",
91
+ "layers.*.self_attn.k_proj": "colwise",
92
+ "layers.*.self_attn.v_proj": "colwise",
93
+ "layers.*.self_attn.o_proj": "rowwise",
94
+ "layers.*.mlp.gate_proj": "colwise",
95
+ "layers.*.mlp.up_proj": "colwise",
96
+ "layers.*.mlp.down_proj": "rowwise",
97
+ }
98
+ base_model_pp_plan = {
99
+ "embed_tokens": (["input_ids"], ["inputs_embeds"]),
100
+ "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
101
+ "norm": (["hidden_states"], ["hidden_states"]),
102
+ }
103
+
104
+ def __init__(
105
+ self,
106
+ vocab_size=48000,
107
+ hidden_size=2560,
108
+ intermediate_size=7040,
109
+ num_hidden_layers=24,
110
+ num_attention_heads=20,
111
+ num_key_value_heads=20,
112
+ head_dim=128,
113
+ hidden_act="silu",
114
+ attention_dropout=0.0,
115
+ max_position_embeddings=4096,
116
+ initializer_range=0.02,
117
+ rms_norm_eps=1e-8,
118
+ use_cache=True,
119
+ tie_word_embeddings=False,
120
+ rope_theta=100000.0,
121
+ pad_token_id=3,
122
+ eos_token_id=2,
123
+ bos_token_id=1,
124
+ attention_bias=False,
125
+ mlp_bias=False,
126
+ **kwargs,
127
+ ):
128
+ self.vocab_size = vocab_size
129
+ self.max_position_embeddings = max_position_embeddings
130
+ self.hidden_size = hidden_size
131
+ self.intermediate_size = intermediate_size
132
+ self.num_hidden_layers = num_hidden_layers
133
+ self.num_attention_heads = num_attention_heads
134
+ self.num_key_value_heads = num_key_value_heads
135
+ self.head_dim = head_dim
136
+ self.hidden_act = hidden_act
137
+ self.initializer_range = initializer_range
138
+ self.rms_norm_eps = rms_norm_eps
139
+ self.use_cache = use_cache
140
+ self.rope_theta = rope_theta
141
+ self.attention_bias = attention_bias
142
+ self.attention_dropout = attention_dropout
143
+ self.mlp_bias = mlp_bias
144
+
145
+ super().__init__(
146
+ pad_token_id=pad_token_id,
147
+ bos_token_id=bos_token_id,
148
+ eos_token_id=eos_token_id,
149
+ tie_word_embeddings=tie_word_embeddings,
150
+ **kwargs,
151
+ )
152
+
153
+
154
+ __all__ = ["HeliumConfig"]