Automatic Speech Recognition
Transformers
Safetensors
meralion2
meralion
meralion-2
custom_code
YingxuHe commited on
Commit
0ace617
·
verified ·
1 Parent(s): 04dce9a

Upload config

Browse files
Files changed (2) hide show
  1. config.json +4 -4
  2. configuration_meralion2.py +76 -0
config.json CHANGED
@@ -1,15 +1,15 @@
1
  {
2
  "architectures": [
3
- "MERaLiONForConditionalGeneration"
4
  ],
5
  "auto_map": {
6
- "AutoConfig": "configuration_meralion.MERaLiONConfig",
7
- "AutoModelForSpeechSeq2Seq": "modeling_meralion.MERaLiONForConditionalGeneration"
8
  },
9
  "head_dim": 256,
10
  "hidden_size": 3584,
11
  "intermediate_size": 14336,
12
- "model_type": "meralion",
13
  "num_attention_heads": 16,
14
  "num_hidden_layers": 42,
15
  "num_key_value_heads": 8,
 
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,
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)