Instructions to use OliBomby/CM3P with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OliBomby/CM3P with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="OliBomby/CM3P", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OliBomby/CM3P", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update configuration_cm3p.py
Browse files- configuration_cm3p.py +325 -323
configuration_cm3p.py
CHANGED
|
@@ -1,323 +1,325 @@
|
|
| 1 |
-
"""CM3P model configuration"""
|
| 2 |
-
from transformers import AutoConfig
|
| 3 |
-
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
-
from transformers.utils import logging
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
logger = logging.get_logger(__name__)
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
class CM3PMetadataConfig(PretrainedConfig):
|
| 11 |
-
model_type = "CM3PMetadata"
|
| 12 |
-
base_config_key = "metadata_config"
|
| 13 |
-
|
| 14 |
-
def __init__(
|
| 15 |
-
self,
|
| 16 |
-
cls_embed=False,
|
| 17 |
-
|
| 18 |
-
projection_dim=512,
|
| 19 |
-
initializer_factor=1.0,
|
| 20 |
-
|
| 21 |
-
vocab_size=1000,
|
| 22 |
-
hidden_size=256,
|
| 23 |
-
intermediate_size=512,
|
| 24 |
-
num_hidden_layers=6,
|
| 25 |
-
num_attention_heads=4,
|
| 26 |
-
hidden_activation="gelu",
|
| 27 |
-
max_position_embeddings=128,
|
| 28 |
-
initializer_range=0.02,
|
| 29 |
-
initializer_cutoff_factor=2.0,
|
| 30 |
-
norm_eps=1e-5,
|
| 31 |
-
norm_bias=False,
|
| 32 |
-
pad_token_id=0,
|
| 33 |
-
bos_token_id=1,
|
| 34 |
-
eos_token_id=2,
|
| 35 |
-
global_rope_theta=10000.0,
|
| 36 |
-
attention_bias=False,
|
| 37 |
-
attention_dropout=0.0,
|
| 38 |
-
global_attn_every_n_layers=1,
|
| 39 |
-
local_attention=128,
|
| 40 |
-
local_rope_theta=10000.0,
|
| 41 |
-
embedding_dropout=0.0,
|
| 42 |
-
mlp_bias=False,
|
| 43 |
-
mlp_dropout=0.0,
|
| 44 |
-
decoder_bias=True,
|
| 45 |
-
deterministic_flash_attn=False,
|
| 46 |
-
reference_compile=None,
|
| 47 |
-
**kwargs,
|
| 48 |
-
):
|
| 49 |
-
super().__init__(
|
| 50 |
-
pad_token_id=pad_token_id,
|
| 51 |
-
bos_token_id=bos_token_id,
|
| 52 |
-
eos_token_id=eos_token_id,
|
| 53 |
-
**kwargs,
|
| 54 |
-
)
|
| 55 |
-
|
| 56 |
-
self.cls_embed = cls_embed
|
| 57 |
-
|
| 58 |
-
self.projection_dim = projection_dim
|
| 59 |
-
self.initializer_range = initializer_range
|
| 60 |
-
self.initializer_factor = initializer_factor
|
| 61 |
-
self.attention_dropout = attention_dropout
|
| 62 |
-
|
| 63 |
-
self.vocab_size = vocab_size
|
| 64 |
-
self.max_position_embeddings = max_position_embeddings
|
| 65 |
-
self.hidden_size = hidden_size
|
| 66 |
-
self.intermediate_size = intermediate_size
|
| 67 |
-
self.num_hidden_layers = num_hidden_layers
|
| 68 |
-
self.num_attention_heads = num_attention_heads
|
| 69 |
-
self.initializer_range = initializer_range
|
| 70 |
-
self.initializer_cutoff_factor = initializer_cutoff_factor
|
| 71 |
-
self.norm_eps = norm_eps
|
| 72 |
-
self.norm_bias = norm_bias
|
| 73 |
-
self.global_rope_theta = global_rope_theta
|
| 74 |
-
self.attention_bias = attention_bias
|
| 75 |
-
self.attention_dropout = attention_dropout
|
| 76 |
-
self.hidden_activation = hidden_activation
|
| 77 |
-
self.global_attn_every_n_layers = global_attn_every_n_layers
|
| 78 |
-
self.local_attention = local_attention
|
| 79 |
-
self.local_rope_theta = local_rope_theta
|
| 80 |
-
self.embedding_dropout = embedding_dropout
|
| 81 |
-
self.mlp_bias = mlp_bias
|
| 82 |
-
self.mlp_dropout = mlp_dropout
|
| 83 |
-
self.decoder_bias = decoder_bias
|
| 84 |
-
self.deterministic_flash_attn = deterministic_flash_attn
|
| 85 |
-
self.reference_compile = reference_compile
|
| 86 |
-
|
| 87 |
-
def to_dict(self):
|
| 88 |
-
output = super().to_dict()
|
| 89 |
-
output.pop("reference_compile", None)
|
| 90 |
-
return output
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
class CM3PAudioConfig(PretrainedConfig):
|
| 94 |
-
model_type = "CM3PAudio"
|
| 95 |
-
base_config_key = "audio_config"
|
| 96 |
-
|
| 97 |
-
def __init__(
|
| 98 |
-
self,
|
| 99 |
-
hidden_size=512,
|
| 100 |
-
intermediate_size=1024,
|
| 101 |
-
num_hidden_layers=6,
|
| 102 |
-
num_attention_heads=8,
|
| 103 |
-
hidden_activation="gelu",
|
| 104 |
-
max_position_embeddings=4096,
|
| 105 |
-
initializer_range=0.02,
|
| 106 |
-
initializer_cutoff_factor=2.0,
|
| 107 |
-
norm_eps=1e-5,
|
| 108 |
-
norm_bias=False,
|
| 109 |
-
global_rope_theta=160000.0,
|
| 110 |
-
attention_bias=False,
|
| 111 |
-
attention_dropout=0.0,
|
| 112 |
-
global_attn_every_n_layers=3,
|
| 113 |
-
local_attention=128,
|
| 114 |
-
local_rope_theta=10000.0,
|
| 115 |
-
embedding_dropout=0.0,
|
| 116 |
-
mlp_bias=False,
|
| 117 |
-
mlp_dropout=0.0,
|
| 118 |
-
decoder_bias=True,
|
| 119 |
-
deterministic_flash_attn=False,
|
| 120 |
-
reference_compile=None,
|
| 121 |
-
|
| 122 |
-
projector_intermediate_size=2048, # 4 * hidden_size for a 4x reduction in tokens
|
| 123 |
-
projector_dim=768,
|
| 124 |
-
projector_hidden_act="gelu",
|
| 125 |
-
|
| 126 |
-
sample_rate: int = 16000,
|
| 127 |
-
n_ftt: int = 2048,
|
| 128 |
-
n_mels: int = 80,
|
| 129 |
-
hop_length: int = 128,
|
| 130 |
-
f_min: int = 0,
|
| 131 |
-
f_max: int = 8000,
|
| 132 |
-
pad_mode: str = "constant",
|
| 133 |
-
**kwargs,
|
| 134 |
-
):
|
| 135 |
-
super().__init__(**kwargs)
|
| 136 |
-
self.vocab_size = 1
|
| 137 |
-
self.max_position_embeddings = max_position_embeddings
|
| 138 |
-
self.hidden_size = hidden_size
|
| 139 |
-
self.intermediate_size = intermediate_size
|
| 140 |
-
self.num_hidden_layers = num_hidden_layers
|
| 141 |
-
self.num_attention_heads = num_attention_heads
|
| 142 |
-
self.initializer_range = initializer_range
|
| 143 |
-
self.initializer_cutoff_factor = initializer_cutoff_factor
|
| 144 |
-
self.norm_eps = norm_eps
|
| 145 |
-
self.norm_bias = norm_bias
|
| 146 |
-
self.global_rope_theta = global_rope_theta
|
| 147 |
-
self.attention_bias = attention_bias
|
| 148 |
-
self.attention_dropout = attention_dropout
|
| 149 |
-
self.hidden_activation = hidden_activation
|
| 150 |
-
self.global_attn_every_n_layers = global_attn_every_n_layers
|
| 151 |
-
self.local_attention = local_attention
|
| 152 |
-
self.local_rope_theta = local_rope_theta
|
| 153 |
-
self.embedding_dropout = embedding_dropout
|
| 154 |
-
self.mlp_bias = mlp_bias
|
| 155 |
-
self.mlp_dropout = mlp_dropout
|
| 156 |
-
self.decoder_bias = decoder_bias
|
| 157 |
-
self.deterministic_flash_attn = deterministic_flash_attn
|
| 158 |
-
self.reference_compile = reference_compile
|
| 159 |
-
|
| 160 |
-
self.projector_intermediate_size = projector_intermediate_size
|
| 161 |
-
self.projector_dim = projector_dim
|
| 162 |
-
self.projector_hidden_act = projector_hidden_act
|
| 163 |
-
|
| 164 |
-
self.sample_rate = sample_rate
|
| 165 |
-
self.n_ftt = n_ftt
|
| 166 |
-
self.n_mels = n_mels
|
| 167 |
-
self.hop_length = hop_length
|
| 168 |
-
self.f_min = f_min
|
| 169 |
-
self.f_max = f_max
|
| 170 |
-
self.pad_mode = pad_mode
|
| 171 |
-
|
| 172 |
-
def to_dict(self):
|
| 173 |
-
output = super().to_dict()
|
| 174 |
-
output.pop("reference_compile", None)
|
| 175 |
-
return output
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
class CM3PBeatmapConfig(PretrainedConfig):
|
| 179 |
-
model_type = "CM3PBeatmap"
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
self.
|
| 240 |
-
self.
|
| 241 |
-
self.
|
| 242 |
-
self.
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
self.
|
| 246 |
-
self.
|
| 247 |
-
self.
|
| 248 |
-
self.
|
| 249 |
-
self.
|
| 250 |
-
self.
|
| 251 |
-
self.
|
| 252 |
-
self.
|
| 253 |
-
self.
|
| 254 |
-
self.
|
| 255 |
-
self.
|
| 256 |
-
self.
|
| 257 |
-
self.
|
| 258 |
-
self.
|
| 259 |
-
self.
|
| 260 |
-
self.
|
| 261 |
-
self.
|
| 262 |
-
self.
|
| 263 |
-
self.
|
| 264 |
-
self.
|
| 265 |
-
self.
|
| 266 |
-
self.
|
| 267 |
-
self.
|
| 268 |
-
self.
|
| 269 |
-
self.
|
| 270 |
-
self.
|
| 271 |
-
self.
|
| 272 |
-
self.
|
| 273 |
-
self.
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
output.
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
self.
|
| 311 |
-
|
| 312 |
-
self.
|
| 313 |
-
self.
|
| 314 |
-
self.
|
| 315 |
-
self.
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
AutoConfig.register("
|
| 321 |
-
AutoConfig.register("
|
| 322 |
-
|
| 323 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
"""CM3P model configuration"""
|
| 2 |
+
from transformers import AutoConfig
|
| 3 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
+
from transformers.utils import logging
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
logger = logging.get_logger(__name__)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class CM3PMetadataConfig(PretrainedConfig):
|
| 11 |
+
model_type = "CM3PMetadata"
|
| 12 |
+
base_config_key = "metadata_config"
|
| 13 |
+
|
| 14 |
+
def __init__(
|
| 15 |
+
self,
|
| 16 |
+
cls_embed=False,
|
| 17 |
+
|
| 18 |
+
projection_dim=512,
|
| 19 |
+
initializer_factor=1.0,
|
| 20 |
+
|
| 21 |
+
vocab_size=1000,
|
| 22 |
+
hidden_size=256,
|
| 23 |
+
intermediate_size=512,
|
| 24 |
+
num_hidden_layers=6,
|
| 25 |
+
num_attention_heads=4,
|
| 26 |
+
hidden_activation="gelu",
|
| 27 |
+
max_position_embeddings=128,
|
| 28 |
+
initializer_range=0.02,
|
| 29 |
+
initializer_cutoff_factor=2.0,
|
| 30 |
+
norm_eps=1e-5,
|
| 31 |
+
norm_bias=False,
|
| 32 |
+
pad_token_id=0,
|
| 33 |
+
bos_token_id=1,
|
| 34 |
+
eos_token_id=2,
|
| 35 |
+
global_rope_theta=10000.0,
|
| 36 |
+
attention_bias=False,
|
| 37 |
+
attention_dropout=0.0,
|
| 38 |
+
global_attn_every_n_layers=1,
|
| 39 |
+
local_attention=128,
|
| 40 |
+
local_rope_theta=10000.0,
|
| 41 |
+
embedding_dropout=0.0,
|
| 42 |
+
mlp_bias=False,
|
| 43 |
+
mlp_dropout=0.0,
|
| 44 |
+
decoder_bias=True,
|
| 45 |
+
deterministic_flash_attn=False,
|
| 46 |
+
reference_compile=None,
|
| 47 |
+
**kwargs,
|
| 48 |
+
):
|
| 49 |
+
super().__init__(
|
| 50 |
+
pad_token_id=pad_token_id,
|
| 51 |
+
bos_token_id=bos_token_id,
|
| 52 |
+
eos_token_id=eos_token_id,
|
| 53 |
+
**kwargs,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
self.cls_embed = cls_embed
|
| 57 |
+
|
| 58 |
+
self.projection_dim = projection_dim
|
| 59 |
+
self.initializer_range = initializer_range
|
| 60 |
+
self.initializer_factor = initializer_factor
|
| 61 |
+
self.attention_dropout = attention_dropout
|
| 62 |
+
|
| 63 |
+
self.vocab_size = vocab_size
|
| 64 |
+
self.max_position_embeddings = max_position_embeddings
|
| 65 |
+
self.hidden_size = hidden_size
|
| 66 |
+
self.intermediate_size = intermediate_size
|
| 67 |
+
self.num_hidden_layers = num_hidden_layers
|
| 68 |
+
self.num_attention_heads = num_attention_heads
|
| 69 |
+
self.initializer_range = initializer_range
|
| 70 |
+
self.initializer_cutoff_factor = initializer_cutoff_factor
|
| 71 |
+
self.norm_eps = norm_eps
|
| 72 |
+
self.norm_bias = norm_bias
|
| 73 |
+
self.global_rope_theta = global_rope_theta
|
| 74 |
+
self.attention_bias = attention_bias
|
| 75 |
+
self.attention_dropout = attention_dropout
|
| 76 |
+
self.hidden_activation = hidden_activation
|
| 77 |
+
self.global_attn_every_n_layers = global_attn_every_n_layers
|
| 78 |
+
self.local_attention = local_attention
|
| 79 |
+
self.local_rope_theta = local_rope_theta
|
| 80 |
+
self.embedding_dropout = embedding_dropout
|
| 81 |
+
self.mlp_bias = mlp_bias
|
| 82 |
+
self.mlp_dropout = mlp_dropout
|
| 83 |
+
self.decoder_bias = decoder_bias
|
| 84 |
+
self.deterministic_flash_attn = deterministic_flash_attn
|
| 85 |
+
self.reference_compile = reference_compile
|
| 86 |
+
|
| 87 |
+
def to_dict(self):
|
| 88 |
+
output = super().to_dict()
|
| 89 |
+
output.pop("reference_compile", None)
|
| 90 |
+
return output
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class CM3PAudioConfig(PretrainedConfig):
|
| 94 |
+
model_type = "CM3PAudio"
|
| 95 |
+
base_config_key = "audio_config"
|
| 96 |
+
|
| 97 |
+
def __init__(
|
| 98 |
+
self,
|
| 99 |
+
hidden_size=512,
|
| 100 |
+
intermediate_size=1024,
|
| 101 |
+
num_hidden_layers=6,
|
| 102 |
+
num_attention_heads=8,
|
| 103 |
+
hidden_activation="gelu",
|
| 104 |
+
max_position_embeddings=4096,
|
| 105 |
+
initializer_range=0.02,
|
| 106 |
+
initializer_cutoff_factor=2.0,
|
| 107 |
+
norm_eps=1e-5,
|
| 108 |
+
norm_bias=False,
|
| 109 |
+
global_rope_theta=160000.0,
|
| 110 |
+
attention_bias=False,
|
| 111 |
+
attention_dropout=0.0,
|
| 112 |
+
global_attn_every_n_layers=3,
|
| 113 |
+
local_attention=128,
|
| 114 |
+
local_rope_theta=10000.0,
|
| 115 |
+
embedding_dropout=0.0,
|
| 116 |
+
mlp_bias=False,
|
| 117 |
+
mlp_dropout=0.0,
|
| 118 |
+
decoder_bias=True,
|
| 119 |
+
deterministic_flash_attn=False,
|
| 120 |
+
reference_compile=None,
|
| 121 |
+
|
| 122 |
+
projector_intermediate_size=2048, # 4 * hidden_size for a 4x reduction in tokens
|
| 123 |
+
projector_dim=768,
|
| 124 |
+
projector_hidden_act="gelu",
|
| 125 |
+
|
| 126 |
+
sample_rate: int = 16000,
|
| 127 |
+
n_ftt: int = 2048,
|
| 128 |
+
n_mels: int = 80,
|
| 129 |
+
hop_length: int = 128,
|
| 130 |
+
f_min: int = 0,
|
| 131 |
+
f_max: int = 8000,
|
| 132 |
+
pad_mode: str = "constant",
|
| 133 |
+
**kwargs,
|
| 134 |
+
):
|
| 135 |
+
super().__init__(**kwargs)
|
| 136 |
+
self.vocab_size = 1
|
| 137 |
+
self.max_position_embeddings = max_position_embeddings
|
| 138 |
+
self.hidden_size = hidden_size
|
| 139 |
+
self.intermediate_size = intermediate_size
|
| 140 |
+
self.num_hidden_layers = num_hidden_layers
|
| 141 |
+
self.num_attention_heads = num_attention_heads
|
| 142 |
+
self.initializer_range = initializer_range
|
| 143 |
+
self.initializer_cutoff_factor = initializer_cutoff_factor
|
| 144 |
+
self.norm_eps = norm_eps
|
| 145 |
+
self.norm_bias = norm_bias
|
| 146 |
+
self.global_rope_theta = global_rope_theta
|
| 147 |
+
self.attention_bias = attention_bias
|
| 148 |
+
self.attention_dropout = attention_dropout
|
| 149 |
+
self.hidden_activation = hidden_activation
|
| 150 |
+
self.global_attn_every_n_layers = global_attn_every_n_layers
|
| 151 |
+
self.local_attention = local_attention
|
| 152 |
+
self.local_rope_theta = local_rope_theta
|
| 153 |
+
self.embedding_dropout = embedding_dropout
|
| 154 |
+
self.mlp_bias = mlp_bias
|
| 155 |
+
self.mlp_dropout = mlp_dropout
|
| 156 |
+
self.decoder_bias = decoder_bias
|
| 157 |
+
self.deterministic_flash_attn = deterministic_flash_attn
|
| 158 |
+
self.reference_compile = reference_compile
|
| 159 |
+
|
| 160 |
+
self.projector_intermediate_size = projector_intermediate_size
|
| 161 |
+
self.projector_dim = projector_dim
|
| 162 |
+
self.projector_hidden_act = projector_hidden_act
|
| 163 |
+
|
| 164 |
+
self.sample_rate = sample_rate
|
| 165 |
+
self.n_ftt = n_ftt
|
| 166 |
+
self.n_mels = n_mels
|
| 167 |
+
self.hop_length = hop_length
|
| 168 |
+
self.f_min = f_min
|
| 169 |
+
self.f_max = f_max
|
| 170 |
+
self.pad_mode = pad_mode
|
| 171 |
+
|
| 172 |
+
def to_dict(self):
|
| 173 |
+
output = super().to_dict()
|
| 174 |
+
output.pop("reference_compile", None)
|
| 175 |
+
return output
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
class CM3PBeatmapConfig(PretrainedConfig):
|
| 179 |
+
model_type = "CM3PBeatmap"
|
| 180 |
+
is_composition = True
|
| 181 |
+
base_config_key = "beatmap_config"
|
| 182 |
+
sub_configs = {"audio_config": CM3PAudioConfig}
|
| 183 |
+
|
| 184 |
+
def __init__(
|
| 185 |
+
self,
|
| 186 |
+
audio_config: dict = None,
|
| 187 |
+
audio_sos_token_id=3164,
|
| 188 |
+
audio_eos_token_id=3165,
|
| 189 |
+
audio_token_id=3166,
|
| 190 |
+
cls_embed=False,
|
| 191 |
+
|
| 192 |
+
projection_dim=512,
|
| 193 |
+
initializer_factor=1.0,
|
| 194 |
+
|
| 195 |
+
vocab_size=3167,
|
| 196 |
+
hidden_size=768,
|
| 197 |
+
intermediate_size=1152,
|
| 198 |
+
num_hidden_layers=22,
|
| 199 |
+
num_attention_heads=12,
|
| 200 |
+
hidden_activation="gelu",
|
| 201 |
+
max_position_embeddings=8192,
|
| 202 |
+
initializer_range=0.02,
|
| 203 |
+
initializer_cutoff_factor=2.0,
|
| 204 |
+
norm_eps=1e-5,
|
| 205 |
+
norm_bias=False,
|
| 206 |
+
pad_token_id=0,
|
| 207 |
+
bos_token_id=1,
|
| 208 |
+
eos_token_id=2,
|
| 209 |
+
global_rope_theta=160000.0,
|
| 210 |
+
attention_bias=False,
|
| 211 |
+
attention_dropout=0.0,
|
| 212 |
+
global_attn_every_n_layers=3,
|
| 213 |
+
local_attention=128,
|
| 214 |
+
local_rope_theta=10000.0,
|
| 215 |
+
embedding_dropout=0.0,
|
| 216 |
+
mlp_bias=False,
|
| 217 |
+
mlp_dropout=0.0,
|
| 218 |
+
decoder_bias=True,
|
| 219 |
+
classifier_bias=False,
|
| 220 |
+
classifier_activation="gelu",
|
| 221 |
+
deterministic_flash_attn=False,
|
| 222 |
+
sparse_prediction=False,
|
| 223 |
+
sparse_pred_ignore_index=-100,
|
| 224 |
+
reference_compile=None,
|
| 225 |
+
repad_logits_with_grad=False,
|
| 226 |
+
**kwargs,
|
| 227 |
+
):
|
| 228 |
+
super().__init__(
|
| 229 |
+
pad_token_id=pad_token_id,
|
| 230 |
+
bos_token_id=bos_token_id,
|
| 231 |
+
eos_token_id=eos_token_id,
|
| 232 |
+
**kwargs,
|
| 233 |
+
)
|
| 234 |
+
|
| 235 |
+
if audio_config is None:
|
| 236 |
+
audio_config = {}
|
| 237 |
+
logger.info("`audio_config` is `None`. Initializing the `CM3PAudioConfig` with default values.")
|
| 238 |
+
|
| 239 |
+
self.audio_config = CM3PAudioConfig(**audio_config)
|
| 240 |
+
self.audio_sos_token_id = audio_sos_token_id
|
| 241 |
+
self.audio_eos_token_id = audio_eos_token_id
|
| 242 |
+
self.audio_token_id = audio_token_id
|
| 243 |
+
self.cls_embed = cls_embed
|
| 244 |
+
|
| 245 |
+
self.projection_dim = projection_dim
|
| 246 |
+
self.initializer_factor = initializer_factor
|
| 247 |
+
self.vocab_size = vocab_size
|
| 248 |
+
self.max_position_embeddings = max_position_embeddings
|
| 249 |
+
self.hidden_size = hidden_size
|
| 250 |
+
self.intermediate_size = intermediate_size
|
| 251 |
+
self.num_hidden_layers = num_hidden_layers
|
| 252 |
+
self.num_attention_heads = num_attention_heads
|
| 253 |
+
self.initializer_range = initializer_range
|
| 254 |
+
self.initializer_cutoff_factor = initializer_cutoff_factor
|
| 255 |
+
self.norm_eps = norm_eps
|
| 256 |
+
self.norm_bias = norm_bias
|
| 257 |
+
self.global_rope_theta = global_rope_theta
|
| 258 |
+
self.attention_bias = attention_bias
|
| 259 |
+
self.attention_dropout = attention_dropout
|
| 260 |
+
self.hidden_activation = hidden_activation
|
| 261 |
+
self.global_attn_every_n_layers = global_attn_every_n_layers
|
| 262 |
+
self.local_attention = local_attention
|
| 263 |
+
self.local_rope_theta = local_rope_theta
|
| 264 |
+
self.embedding_dropout = embedding_dropout
|
| 265 |
+
self.mlp_bias = mlp_bias
|
| 266 |
+
self.mlp_dropout = mlp_dropout
|
| 267 |
+
self.decoder_bias = decoder_bias
|
| 268 |
+
self.classifier_bias = classifier_bias
|
| 269 |
+
self.classifier_activation = classifier_activation
|
| 270 |
+
self.deterministic_flash_attn = deterministic_flash_attn
|
| 271 |
+
self.sparse_prediction = sparse_prediction
|
| 272 |
+
self.sparse_pred_ignore_index = sparse_pred_ignore_index
|
| 273 |
+
self.reference_compile = reference_compile
|
| 274 |
+
self.repad_logits_with_grad = repad_logits_with_grad
|
| 275 |
+
|
| 276 |
+
def to_dict(self):
|
| 277 |
+
output = super().to_dict()
|
| 278 |
+
output.pop("reference_compile", None)
|
| 279 |
+
return output
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
class CM3PConfig(PretrainedConfig):
|
| 283 |
+
model_type = "CM3P"
|
| 284 |
+
is_composition = True
|
| 285 |
+
sub_configs = {"metadata_config": CM3PMetadataConfig, "beatmap_config": CM3PBeatmapConfig}
|
| 286 |
+
|
| 287 |
+
def __init__(
|
| 288 |
+
self,
|
| 289 |
+
metadata_config=None,
|
| 290 |
+
beatmap_config=None,
|
| 291 |
+
projection_dim=512,
|
| 292 |
+
logit_scale_init_value=2.6592,
|
| 293 |
+
initializer_factor=1.0,
|
| 294 |
+
initializer_range=0.02,
|
| 295 |
+
loss_type=None,
|
| 296 |
+
has_decoder_head=False,
|
| 297 |
+
**kwargs
|
| 298 |
+
):
|
| 299 |
+
super().__init__(**kwargs)
|
| 300 |
+
|
| 301 |
+
if metadata_config is None:
|
| 302 |
+
metadata_config = {}
|
| 303 |
+
logger.debug("`metadata_config` is `None`. Initializing the `CM3PMetadataConfig` with default values.")
|
| 304 |
+
|
| 305 |
+
if beatmap_config is None:
|
| 306 |
+
beatmap_config = {}
|
| 307 |
+
logger.debug("`beatmap_config` is `None`. initializing the `CM3PBeatmapConfig` with default values.")
|
| 308 |
+
|
| 309 |
+
self.metadata_config = CM3PMetadataConfig(**metadata_config)
|
| 310 |
+
self.beatmap_config = CM3PBeatmapConfig(**beatmap_config)
|
| 311 |
+
|
| 312 |
+
self.projection_dim = projection_dim
|
| 313 |
+
self.logit_scale_init_value = logit_scale_init_value
|
| 314 |
+
self.initializer_factor = initializer_factor
|
| 315 |
+
self.initializer_range = initializer_range
|
| 316 |
+
self.loss_type = loss_type
|
| 317 |
+
self.has_decoder_head = has_decoder_head
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
AutoConfig.register("CM3PMetadata", CM3PMetadataConfig)
|
| 321 |
+
AutoConfig.register("CM3PAudio", CM3PAudioConfig)
|
| 322 |
+
AutoConfig.register("CM3PBeatmap", CM3PBeatmapConfig)
|
| 323 |
+
AutoConfig.register("CM3P", CM3PConfig)
|
| 324 |
+
|
| 325 |
+
__all__ = ["CM3PConfig", "CM3PMetadataConfig", "CM3PAudioConfig", "CM3PBeatmapConfig"]
|