Upload config
Browse files- config.json +100 -0
- configuration_meralion2.py +76 -0
config.json
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"MERaLiON2ForConditionalGeneration"
|
4 |
+
],
|
5 |
+
"auto_map": {
|
6 |
+
"AutoConfig": "configuration_meralion2.MERaLiON2Config",
|
7 |
+
"AutoModelForSpeechSeq2Seq": "modeling_meralion2.MERaLiON2ForConditionalGeneration"
|
8 |
+
},
|
9 |
+
"head_dim": 256,
|
10 |
+
"hidden_size": 3584,
|
11 |
+
"intermediate_size": 14336,
|
12 |
+
"model_type": "meralion2",
|
13 |
+
"num_attention_heads": 16,
|
14 |
+
"num_hidden_layers": 42,
|
15 |
+
"num_key_value_heads": 8,
|
16 |
+
"sliding_window": 4096,
|
17 |
+
"speech_config": {
|
18 |
+
"_attn_implementation_autoset": true,
|
19 |
+
"_name_or_path": "openai/whisper-large-v3",
|
20 |
+
"activation_dropout": 0.0,
|
21 |
+
"activation_function": "gelu",
|
22 |
+
"apply_spec_augment": true,
|
23 |
+
"architectures": [
|
24 |
+
"WhisperForConditionalGeneration"
|
25 |
+
],
|
26 |
+
"attention_dropout": 0.0,
|
27 |
+
"begin_suppress_tokens": [
|
28 |
+
220,
|
29 |
+
50257
|
30 |
+
],
|
31 |
+
"bos_token_id": 50257,
|
32 |
+
"classifier_proj_size": 256,
|
33 |
+
"d_model": 1280,
|
34 |
+
"decoder_attention_heads": 20,
|
35 |
+
"decoder_ffn_dim": 5120,
|
36 |
+
"decoder_layerdrop": 0.0,
|
37 |
+
"decoder_layers": 32,
|
38 |
+
"decoder_start_token_id": 50258,
|
39 |
+
"dropout": 0.0,
|
40 |
+
"encoder_attention_heads": 20,
|
41 |
+
"encoder_ffn_dim": 5120,
|
42 |
+
"encoder_layerdrop": 0.0,
|
43 |
+
"encoder_layers": 32,
|
44 |
+
"eos_token_id": 50257,
|
45 |
+
"init_std": 0.02,
|
46 |
+
"mask_feature_length": 10,
|
47 |
+
"mask_feature_min_masks": 0,
|
48 |
+
"mask_feature_prob": 0.1,
|
49 |
+
"mask_time_length": 20,
|
50 |
+
"mask_time_min_masks": 2,
|
51 |
+
"mask_time_prob": 0.1,
|
52 |
+
"max_length": 448,
|
53 |
+
"max_source_positions": 1500,
|
54 |
+
"max_target_positions": 448,
|
55 |
+
"median_filter_width": 7,
|
56 |
+
"model_type": "whisper",
|
57 |
+
"num_hidden_layers": 32,
|
58 |
+
"num_mel_bins": 128,
|
59 |
+
"scale_embedding": false,
|
60 |
+
"torch_dtype": "bfloat16",
|
61 |
+
"use_cache": true,
|
62 |
+
"use_weighted_layer_sum": false,
|
63 |
+
"vocab_size": 51866
|
64 |
+
},
|
65 |
+
"speech_mlp_scale_factor": 15,
|
66 |
+
"speech_token_index": 255999,
|
67 |
+
"text_config": {
|
68 |
+
"_attn_implementation_autoset": true,
|
69 |
+
"_name_or_path": "google/gemma-2-9b-it",
|
70 |
+
"architectures": [
|
71 |
+
"Gemma2ForCausalLM"
|
72 |
+
],
|
73 |
+
"attention_bias": false,
|
74 |
+
"attention_dropout": 0.0,
|
75 |
+
"attn_logit_softcapping": 50.0,
|
76 |
+
"cache_implementation": "hybrid",
|
77 |
+
"final_logit_softcapping": 30.0,
|
78 |
+
"head_dim": 256,
|
79 |
+
"hidden_act": "gelu_pytorch_tanh",
|
80 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
81 |
+
"hidden_size": 3584,
|
82 |
+
"initializer_range": 0.02,
|
83 |
+
"intermediate_size": 14336,
|
84 |
+
"max_position_embeddings": 8192,
|
85 |
+
"model_type": "gemma2",
|
86 |
+
"num_attention_heads": 16,
|
87 |
+
"num_hidden_layers": 42,
|
88 |
+
"num_key_value_heads": 8,
|
89 |
+
"query_pre_attn_scalar": 256,
|
90 |
+
"rms_norm_eps": 1e-06,
|
91 |
+
"rope_theta": 10000.0,
|
92 |
+
"sliding_window": 4096,
|
93 |
+
"sliding_window_size": 4096,
|
94 |
+
"torch_dtype": "bfloat16",
|
95 |
+
"use_cache": true,
|
96 |
+
"vocab_size": 256000
|
97 |
+
},
|
98 |
+
"torch_dtype": "bfloat16",
|
99 |
+
"transformers_version": "4.50.1"
|
100 |
+
}
|
configuration_meralion2.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""MERaLiON2 model configuration"""
|
2 |
+
|
3 |
+
from transformers import Gemma2Config, WhisperConfig
|
4 |
+
from transformers.configuration_utils import PretrainedConfig
|
5 |
+
from transformers.utils import logging
|
6 |
+
|
7 |
+
|
8 |
+
logger = logging.get_logger(__name__)
|
9 |
+
|
10 |
+
|
11 |
+
class MERaLiON2Config(PretrainedConfig):
|
12 |
+
r"""
|
13 |
+
This is the configuration class to store the configuration of a [`MERaLiON2ForConditionalGeneration`]. It is used to instantiate an
|
14 |
+
MERaLiON2 model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
15 |
+
with the defaults will yield a similar configuration to that of the MERaLiON2.
|
16 |
+
|
17 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
18 |
+
documentation from [`PretrainedConfig`] for more information.
|
19 |
+
|
20 |
+
Args:
|
21 |
+
audio_config (`Union[AutoConfig, dict]`, *optional*, defaults to `CLIPVisionConfig`):
|
22 |
+
The config object or dictionary of the audio backbone.
|
23 |
+
text_config (`Union[AutoConfig, dict]`, *optional*, defaults to `LlamaConfig`):
|
24 |
+
The config object or dictionary of the text backbone.
|
25 |
+
audio_token_index (`int`, *optional*, defaults to 151646):
|
26 |
+
The image token index to encode the image prompt.
|
27 |
+
"""
|
28 |
+
|
29 |
+
model_type = "meralion2"
|
30 |
+
is_composition = False
|
31 |
+
|
32 |
+
def __init__(
|
33 |
+
self,
|
34 |
+
speech_config=None,
|
35 |
+
text_config=None,
|
36 |
+
speech_mlp_scale_factor=15,
|
37 |
+
speech_token_index=255999,
|
38 |
+
**kwargs,
|
39 |
+
):
|
40 |
+
|
41 |
+
if isinstance(speech_config, dict):
|
42 |
+
speech_config = WhisperConfig(**speech_config)
|
43 |
+
elif speech_config is None:
|
44 |
+
speech_config = WhisperConfig(
|
45 |
+
d_model=1280,
|
46 |
+
encoder_attention_heads=20,
|
47 |
+
encoder_ffn_dim=5120,
|
48 |
+
encoder_layerdrop=0.0,
|
49 |
+
encoder_layers=32,
|
50 |
+
num_mel_bins=128,
|
51 |
+
max_source_positions=1500,
|
52 |
+
scale_embedding=False,
|
53 |
+
activation_function="gelu",
|
54 |
+
)
|
55 |
+
|
56 |
+
self.speech_config = speech_config
|
57 |
+
|
58 |
+
if isinstance(text_config, dict):
|
59 |
+
text_config = Gemma2Config(**text_config)
|
60 |
+
elif text_config is None:
|
61 |
+
text_config = Gemma2Config()
|
62 |
+
|
63 |
+
self.text_config = text_config
|
64 |
+
|
65 |
+
self.speech_mlp_scale_factor = speech_mlp_scale_factor
|
66 |
+
self.speech_token_index = speech_token_index
|
67 |
+
|
68 |
+
self.sliding_window = self.text_config.sliding_window
|
69 |
+
self.hidden_size = self.text_config.hidden_size
|
70 |
+
self.num_attention_heads = self.text_config.num_attention_heads
|
71 |
+
self.num_hidden_layers = self.text_config.num_hidden_layers
|
72 |
+
self.num_key_value_heads = self.text_config.num_key_value_heads
|
73 |
+
self.head_dim = self.text_config.head_dim
|
74 |
+
self.intermediate_size = self.text_config.intermediate_size
|
75 |
+
|
76 |
+
super().__init__(**kwargs)
|