potsawee commited on
Commit
679b242
·
verified ·
1 Parent(s): 097dc8c

Upload Typhoon2Audio2AudioForConditionalGeneration

Browse files
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
config.json ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Typhoon2Audio2AudioForConditionalGeneration"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_typhoon2audio.Typhoon2AudioConfig",
9
+ "AutoModel": "modeling_typhoon2audio.Typhoon2Audio2AudioForConditionalGeneration"
10
+ },
11
+ "beats": {
12
+ "model_type": ""
13
+ },
14
+ "ctc_decoder_config": "(4,4096,32,11008)",
15
+ "ctc_loss_weight": 1.0,
16
+ "ctc_upsample_factor": 25,
17
+ "head_dim": 128,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 4096,
20
+ "intermediate_size": 14336,
21
+ "llama_base_model": "scb10x/typhoon-2-llama31-8b-instruct-beta-v1",
22
+ "max_position_embeddings": 131072,
23
+ "mlp_bias": false,
24
+ "model_type": "typhoon2audio",
25
+ "num_attention_heads": 32,
26
+ "num_hidden_layers": 32,
27
+ "num_key_value_heads": 8,
28
+ "pretraining_tp": 1,
29
+ "rms_norm_eps": 1e-05,
30
+ "rope_scaling": {
31
+ "factor": 8.0,
32
+ "high_freq_factor": 4.0,
33
+ "low_freq_factor": 1.0,
34
+ "original_max_position_embeddings": 8192,
35
+ "rope_type": "llama3"
36
+ },
37
+ "rope_theta": 500000.0,
38
+ "second_per_frame": 0.333333,
39
+ "second_stride": 0.333333,
40
+ "speech_decoder_ignore_index": -100,
41
+ "speech_qformer_layer": 2,
42
+ "speech_qformer_token_num": 1,
43
+ "torch_dtype": "float16",
44
+ "transformers_version": "4.45.0",
45
+ "unit_vocab_size": 1000,
46
+ "vocab_size": 128256,
47
+ "vocoder_config": {
48
+ "code_hop_size": 320,
49
+ "dur_prediction_weight": 1.0,
50
+ "dur_predictor_params": {
51
+ "encoder_embed_dim": 512,
52
+ "var_pred_dropout": 0.5,
53
+ "var_pred_hidden_dim": 512,
54
+ "var_pred_kernel_size": 3
55
+ },
56
+ "embedding_dim": 512,
57
+ "hop_size": 256,
58
+ "model_in_dim": 512,
59
+ "n_fft": 1024,
60
+ "num_embeddings": 1000,
61
+ "num_freq": 1025,
62
+ "num_mels": 80,
63
+ "resblock": 1,
64
+ "resblock_dilation_sizes": [
65
+ [
66
+ 1,
67
+ 3,
68
+ 5
69
+ ],
70
+ [
71
+ 1,
72
+ 3,
73
+ 5
74
+ ],
75
+ [
76
+ 1,
77
+ 3,
78
+ 5
79
+ ]
80
+ ],
81
+ "resblock_kernel_sizes": [
82
+ 3,
83
+ 7,
84
+ 11
85
+ ],
86
+ "sampling_rate": 16000,
87
+ "segment_size": 8960,
88
+ "upsample_initial_channel": 512,
89
+ "upsample_kernel_sizes": [
90
+ 11,
91
+ 8,
92
+ 8,
93
+ 4,
94
+ 4
95
+ ],
96
+ "upsample_rates": [
97
+ 5,
98
+ 4,
99
+ 4,
100
+ 2,
101
+ 2
102
+ ],
103
+ "win_size": 1024
104
+ },
105
+ "vocoder_path": {
106
+ "filename": "checkpoint.pt",
107
+ "repo_id": "scb10x/unit-vocoder-gcp-th-v1-00206600"
108
+ },
109
+ "whisper": {
110
+ "apply_spec_augment": true,
111
+ "begin_suppress_tokens": [
112
+ 220,
113
+ 50257
114
+ ],
115
+ "bos_token_id": 50257,
116
+ "d_model": 1280,
117
+ "decoder_attention_heads": 20,
118
+ "decoder_ffn_dim": 5120,
119
+ "decoder_layers": 32,
120
+ "decoder_start_token_id": 50258,
121
+ "encoder_attention_heads": 20,
122
+ "encoder_ffn_dim": 5120,
123
+ "encoder_layers": 32,
124
+ "eos_token_id": 50257,
125
+ "mask_feature_length": 64,
126
+ "mask_feature_prob": 0.1,
127
+ "mask_time_prob": 0.1,
128
+ "max_length": 448,
129
+ "model_type": "whisper",
130
+ "num_hidden_layers": 32,
131
+ "num_mel_bins": 128,
132
+ "vocab_size": 51866
133
+ },
134
+ "whisper_extractor_feature_size": 128
135
+ }
configuration_typhoon2audio.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PretrainedConfig, WhisperConfig
2
+
3
+ class BEATsConfig(PretrainedConfig):
4
+ def __init__(self, cfg=None):
5
+ # update the default values to BEATs_iter3_plus_AS2M_finetuned_on_AS2M_cpt2.pt
6
+ self.input_patch_size: int = 16 # path size of patch embedding
7
+ self.embed_dim: int = 512 # patch embedding dimension
8
+ self.conv_bias: bool = False # include bias in conv encoder
9
+
10
+ self.encoder_layers: int = 12 # num encoder layers in the transformer
11
+ self.encoder_embed_dim: int = 768 # encoder embedding dimension
12
+ self.encoder_ffn_embed_dim: int = 3072 # encoder embedding dimension for FFN
13
+ self.encoder_attention_heads: int = 12 # num encoder attention heads
14
+ self.activation_fn: str = "gelu" # activation function to use
15
+
16
+ self.layer_wise_gradient_decay_ratio: float = 0.6 # ratio for layer-wise gradient decay
17
+ self.layer_norm_first: bool = False # apply layernorm first in the transformer
18
+ self.deep_norm: bool = True # apply deep_norm first in the transformer
19
+
20
+ # dropouts
21
+ self.dropout: float = 0.0 # dropout probability for the transformer
22
+ self.attention_dropout: float = 0.0 # dropout probability for attention weights
23
+ self.activation_dropout: float = 0.0 # dropout probability after activation in FFN
24
+ self.encoder_layerdrop: float = 0.05 # probability of dropping a tarnsformer layer
25
+ self.dropout_input: float = 0.0 # dropout to apply to the input (after feat extr)
26
+
27
+ # positional embeddings
28
+ self.conv_pos: int = 128 # number of filters for convolutional positional embeddings
29
+ self.conv_pos_groups: int = 16 # number of groups for convolutional positional embedding
30
+
31
+ # relative position embedding
32
+ self.relative_position_embedding: bool = True # apply relative position embedding
33
+ self.num_buckets: int = 320 # number of buckets for relative position embedding
34
+ self.max_distance: int = 800 # maximum distance for relative position embedding
35
+ self.gru_rel_pos: bool = True # apply gated relative position embedding
36
+
37
+ # label predictor
38
+ self.finetuned_model: bool = True # whether the model is a fine-tuned model.
39
+ self.predictor_dropout: float = 0.0 # dropout probability for the predictor
40
+ self.predictor_class: int = 527 # target class number for the predictor
41
+
42
+ if cfg is not None:
43
+ self.update(cfg)
44
+
45
+ def update(self, cfg: dict):
46
+ self.__dict__.update(cfg)
47
+
48
+
49
+ class Typhoon2AudioConfig(PretrainedConfig):
50
+ model_type = "typhoon2audio"
51
+
52
+ def __init__(self, **kwargs):
53
+ # LLM -- Llama3
54
+ self.llama_base_model = "scb10x/typhoon-2-llama31-8b-instruct-beta-v1"
55
+
56
+ # Whisper
57
+ self.whisper_extractor_feature_size=128
58
+ self.whisper = WhisperConfig(
59
+ activation_dropout=0.0,
60
+ activation_function="gelu",
61
+ apply_spec_augment=True,
62
+ attention_dropout=0.0,
63
+ begin_suppress_tokens=[220, 50257],
64
+ bos_token_id=50257,
65
+ d_model=1280,
66
+ decoder_attention_heads=20,
67
+ decoder_ffn_dim=5120,
68
+ decoder_layerdrop=0.0,
69
+ decoder_layers=32,
70
+ decoder_start_token_id=50258,
71
+ dropout=0.0,
72
+ encoder_attention_heads=20,
73
+ encoder_ffn_dim=5120,
74
+ encoder_layerdrop=0.0,
75
+ encoder_layers=32,
76
+ eos_token_id=50257,
77
+ init_std=0.02,
78
+ mask_feature_length=64,
79
+ mask_feature_min_masks=0,
80
+ mask_feature_prob=0.1,
81
+ mask_time_length=10,
82
+ mask_time_min_masks=2,
83
+ mask_time_prob=0.1,
84
+ max_length=448,
85
+ max_source_positions=1500,
86
+ max_target_positions=448,
87
+ median_filter_width=7,
88
+ num_hidden_layers=32,
89
+ num_mel_bins=128,
90
+ pad_token_id=50256,
91
+ scale_embedding=False,
92
+ use_weighted_layer_sum=False,
93
+ vocab_size=51866,
94
+ )
95
+ # BEATs
96
+ self.beats = BEATsConfig()
97
+
98
+ # Speech QFormer
99
+ self.speech_qformer_token_num=1
100
+ self.speech_qformer_layer=2
101
+ self.second_per_frame=0.333333
102
+ self.second_stride=0.333333
103
+
104
+ # SpeechDecoder CTC
105
+ self.pretraining_tp = 1
106
+ self.ctc_decoder_config='(4,4096,32,11008)'
107
+ self.ctc_upsample_factor=25
108
+ self.ctc_loss_weight=1.0
109
+ self.unit_vocab_size=1000
110
+ self.speech_decoder_ignore_index=-100
111
+ self.attention_bias=False
112
+ self.attention_dropout=0.0
113
+ self.bos_token_id=128000
114
+ self.eos_token_id=128009
115
+ self.head_dim=128
116
+ self.hidden_act="silu"
117
+ self.hidden_size=4096
118
+ self.intermediate_size=14336
119
+ self.max_position_embeddings=131072
120
+ self.mlp_bias=False
121
+ self.num_attention_heads=32
122
+ self.num_hidden_layers=32
123
+ self.num_key_value_heads=8
124
+ self.rms_norm_eps=1e-05
125
+ self.rope_scaling={
126
+ "factor": 8.0,
127
+ "high_freq_factor": 4.0,
128
+ "low_freq_factor": 1.0,
129
+ "original_max_position_embeddings": 8192,
130
+ "rope_type": "llama3"
131
+ }
132
+ self.rope_theta=500000.0
133
+ self.vocab_size=128256
134
+
135
+ # Unit Vocoder (HiFiGAN)
136
+ self.vocoder_path = {
137
+ 'repo_id': 'scb10x/unit-vocoder-gcp-th-v1-00206600',
138
+ 'filename': 'checkpoint.pt'
139
+ }
140
+ self.vocoder_config = {
141
+ 'resblock': 1,
142
+ 'upsample_rates': [5, 4, 4, 2, 2],
143
+ 'upsample_kernel_sizes': [11, 8, 8, 4, 4],
144
+ 'upsample_initial_channel': 512,
145
+ 'resblock_kernel_sizes': [3, 7, 11],
146
+ 'resblock_dilation_sizes': [[1, 3, 5], [1, 3, 5], [1, 3, 5]],
147
+ 'num_embeddings': 1000,
148
+ 'embedding_dim': 512,
149
+ 'model_in_dim': 512,
150
+ 'segment_size': 8960,
151
+ 'code_hop_size': 320,
152
+ 'num_mels': 80,
153
+ 'num_freq': 1025,
154
+ 'n_fft': 1024,
155
+ 'hop_size': 256,
156
+ 'win_size': 1024,
157
+ 'sampling_rate': 16000,
158
+ 'dur_prediction_weight': 1.0,
159
+ 'dur_predictor_params': {
160
+ 'encoder_embed_dim': 512,
161
+ 'var_pred_hidden_dim': 512,
162
+ 'var_pred_kernel_size': 3,
163
+ 'var_pred_dropout': 0.5
164
+ }
165
+ }
166
+ super().__init__(**kwargs)
generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.45.0"
4
+ }
modeling_typhoon2audio.py ADDED
The diff for this file is too large to render. See raw diff
 
pytorch_model-00001-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18a5ab4024b1f86f96f88917e374fa65a20faed26604387f537e5cef8fd02a72
3
+ size 4884845301
pytorch_model-00002-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:791f35f49a17984139a624e681d6034265b9f0af6e703e24fda5b61c72ffbf85
3
+ size 4915939914
pytorch_model-00003-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb1b59f02df617d2da6d37ec18556fdc758b7d4851c1e160ee5ba3035f376c21
3
+ size 4915939978
pytorch_model-00004-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ec6b6fb06af427ed91f3cdc51c9228bf0e13eeb0d98c88f4a397a15ef841170
3
+ size 4647114854
pytorch_model.bin.index.json ADDED
The diff for this file is too large to render. See raw diff