sanchit-gandhi HF staff commited on
Commit
c4e5ff9
1 Parent(s): 68bb20c
config.json ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SpeechEncoderDecoderModel"
4
+ ],
5
+ "decoder": {
6
+ "_name_or_path": "facebook/bart-large-cnn",
7
+ "_num_labels": 3,
8
+ "activation_dropout": 0.0,
9
+ "activation_function": "gelu",
10
+ "add_cross_attention": true,
11
+ "add_final_layer_norm": false,
12
+ "architectures": [
13
+ "BartForConditionalGeneration"
14
+ ],
15
+ "attention_dropout": 0.0,
16
+ "bad_words_ids": null,
17
+ "bos_token_id": 0,
18
+ "chunk_size_feed_forward": 0,
19
+ "classif_dropout": 0.0,
20
+ "classifier_dropout": 0.0,
21
+ "cross_attention_hidden_size": null,
22
+ "d_model": 1024,
23
+ "decoder_attention_heads": 16,
24
+ "decoder_ffn_dim": 4096,
25
+ "decoder_layerdrop": 0.0,
26
+ "decoder_layers": 12,
27
+ "decoder_start_token_id": 2,
28
+ "diversity_penalty": 0.0,
29
+ "do_sample": false,
30
+ "dropout": 0.1,
31
+ "early_stopping": true,
32
+ "encoder_attention_heads": 16,
33
+ "encoder_ffn_dim": 4096,
34
+ "encoder_layerdrop": 0.0,
35
+ "encoder_layers": 12,
36
+ "encoder_no_repeat_ngram_size": 0,
37
+ "eos_token_id": 2,
38
+ "exponential_decay_length_penalty": null,
39
+ "finetuning_task": null,
40
+ "force_bos_token_to_be_generated": true,
41
+ "forced_bos_token_id": 0,
42
+ "forced_eos_token_id": 2,
43
+ "gradient_checkpointing": false,
44
+ "id2label": {
45
+ "0": "LABEL_0",
46
+ "1": "LABEL_1",
47
+ "2": "LABEL_2"
48
+ },
49
+ "init_std": 0.02,
50
+ "is_decoder": true,
51
+ "is_encoder_decoder": false,
52
+ "label2id": {
53
+ "LABEL_0": 0,
54
+ "LABEL_1": 1,
55
+ "LABEL_2": 2
56
+ },
57
+ "length_penalty": 2.0,
58
+ "max_length": 142,
59
+ "max_position_embeddings": 1024,
60
+ "min_length": 56,
61
+ "model_type": "bart",
62
+ "no_repeat_ngram_size": 3,
63
+ "normalize_before": false,
64
+ "num_beam_groups": 1,
65
+ "num_beams": 4,
66
+ "num_hidden_layers": 12,
67
+ "num_return_sequences": 1,
68
+ "output_attentions": false,
69
+ "output_hidden_states": false,
70
+ "output_past": true,
71
+ "output_scores": false,
72
+ "pad_token_id": 1,
73
+ "prefix": " ",
74
+ "problem_type": null,
75
+ "pruned_heads": {},
76
+ "remove_invalid_values": false,
77
+ "repetition_penalty": 1.0,
78
+ "return_dict": true,
79
+ "return_dict_in_generate": false,
80
+ "scale_embedding": false,
81
+ "sep_token_id": null,
82
+ "task_specific_params": {
83
+ "summarization": {
84
+ "early_stopping": true,
85
+ "length_penalty": 2.0,
86
+ "max_length": 142,
87
+ "min_length": 56,
88
+ "no_repeat_ngram_size": 3,
89
+ "num_beams": 4
90
+ }
91
+ },
92
+ "temperature": 1.0,
93
+ "tie_encoder_decoder": false,
94
+ "tie_word_embeddings": true,
95
+ "tokenizer_class": null,
96
+ "top_k": 50,
97
+ "top_p": 1.0,
98
+ "torch_dtype": null,
99
+ "torchscript": false,
100
+ "transformers_version": "4.18.0.dev0",
101
+ "typical_p": 1.0,
102
+ "use_bfloat16": false,
103
+ "use_cache": true,
104
+ "vocab_size": 50264
105
+ },
106
+ "decoder_start_token_id": 0,
107
+ "encoder": {
108
+ "_name_or_path": "facebook/wav2vec2-large-lv60",
109
+ "activation_dropout": 0.1,
110
+ "adapter_kernel_size": 3,
111
+ "adapter_stride": 2,
112
+ "add_adapter": true,
113
+ "add_cross_attention": false,
114
+ "apply_spec_augment": true,
115
+ "architectures": [
116
+ "Wav2Vec2ForPreTraining"
117
+ ],
118
+ "attention_dropout": 0.1,
119
+ "bad_words_ids": null,
120
+ "bos_token_id": 1,
121
+ "chunk_size_feed_forward": 0,
122
+ "classifier_proj_size": 256,
123
+ "codevector_dim": 768,
124
+ "contrastive_logits_temperature": 0.1,
125
+ "conv_bias": true,
126
+ "conv_dim": [
127
+ 512,
128
+ 512,
129
+ 512,
130
+ 512,
131
+ 512,
132
+ 512,
133
+ 512
134
+ ],
135
+ "conv_kernel": [
136
+ 10,
137
+ 3,
138
+ 3,
139
+ 3,
140
+ 3,
141
+ 2,
142
+ 2
143
+ ],
144
+ "conv_stride": [
145
+ 5,
146
+ 2,
147
+ 2,
148
+ 2,
149
+ 2,
150
+ 2,
151
+ 2
152
+ ],
153
+ "cross_attention_hidden_size": null,
154
+ "ctc_loss_reduction": "sum",
155
+ "ctc_zero_infinity": false,
156
+ "decoder_start_token_id": null,
157
+ "diversity_loss_weight": 0.1,
158
+ "diversity_penalty": 0.0,
159
+ "do_sample": false,
160
+ "do_stable_layer_norm": true,
161
+ "early_stopping": false,
162
+ "encoder_no_repeat_ngram_size": 0,
163
+ "eos_token_id": 2,
164
+ "exponential_decay_length_penalty": null,
165
+ "feat_extract_activation": "gelu",
166
+ "feat_extract_dropout": 0.0,
167
+ "feat_extract_norm": "layer",
168
+ "feat_proj_dropout": 0.0,
169
+ "feat_quantizer_dropout": 0.0,
170
+ "final_dropout": 0.0,
171
+ "finetuning_task": null,
172
+ "forced_bos_token_id": null,
173
+ "forced_eos_token_id": null,
174
+ "gradient_checkpointing": false,
175
+ "hidden_act": "gelu",
176
+ "hidden_dropout": 0.1,
177
+ "hidden_dropout_prob": 0.1,
178
+ "hidden_size": 1024,
179
+ "id2label": {
180
+ "0": "LABEL_0",
181
+ "1": "LABEL_1"
182
+ },
183
+ "initializer_range": 0.02,
184
+ "intermediate_size": 4096,
185
+ "is_decoder": false,
186
+ "is_encoder_decoder": false,
187
+ "label2id": {
188
+ "LABEL_0": 0,
189
+ "LABEL_1": 1
190
+ },
191
+ "layer_norm_eps": 1e-05,
192
+ "layerdrop": 0.0,
193
+ "length_penalty": 1.0,
194
+ "mask_feature_length": 10,
195
+ "mask_feature_min_masks": 0,
196
+ "mask_feature_prob": 0.0,
197
+ "mask_time_length": 10,
198
+ "mask_time_min_masks": 2,
199
+ "mask_time_prob": 0.1,
200
+ "max_length": 20,
201
+ "min_length": 0,
202
+ "model_type": "wav2vec2",
203
+ "no_repeat_ngram_size": 0,
204
+ "num_adapter_layers": 3,
205
+ "num_attention_heads": 16,
206
+ "num_beam_groups": 1,
207
+ "num_beams": 1,
208
+ "num_codevector_groups": 2,
209
+ "num_codevectors_per_group": 320,
210
+ "num_conv_pos_embedding_groups": 16,
211
+ "num_conv_pos_embeddings": 128,
212
+ "num_feat_extract_layers": 7,
213
+ "num_hidden_layers": 24,
214
+ "num_negatives": 100,
215
+ "num_return_sequences": 1,
216
+ "output_attentions": false,
217
+ "output_hidden_size": 1024,
218
+ "output_hidden_states": false,
219
+ "output_scores": false,
220
+ "pad_token_id": 0,
221
+ "prefix": null,
222
+ "problem_type": null,
223
+ "proj_codevector_dim": 768,
224
+ "pruned_heads": {},
225
+ "remove_invalid_values": false,
226
+ "repetition_penalty": 1.0,
227
+ "return_dict": true,
228
+ "return_dict_in_generate": false,
229
+ "sep_token_id": null,
230
+ "task_specific_params": null,
231
+ "tdnn_dilation": [
232
+ 1,
233
+ 2,
234
+ 3,
235
+ 1,
236
+ 1
237
+ ],
238
+ "tdnn_dim": [
239
+ 512,
240
+ 512,
241
+ 512,
242
+ 512,
243
+ 1500
244
+ ],
245
+ "tdnn_kernel": [
246
+ 5,
247
+ 3,
248
+ 3,
249
+ 1,
250
+ 1
251
+ ],
252
+ "temperature": 1.0,
253
+ "tie_encoder_decoder": false,
254
+ "tie_word_embeddings": true,
255
+ "tokenizer_class": null,
256
+ "top_k": 50,
257
+ "top_p": 1.0,
258
+ "torch_dtype": null,
259
+ "torchscript": false,
260
+ "transformers_version": "4.18.0.dev0",
261
+ "typical_p": 1.0,
262
+ "use_bfloat16": false,
263
+ "use_weighted_layer_sum": false,
264
+ "vocab_size": 32,
265
+ "xvector_output_dim": 512
266
+ },
267
+ "eos_token_id": 2,
268
+ "is_encoder_decoder": true,
269
+ "max_length": 40,
270
+ "model_type": "speech-encoder-decoder",
271
+ "pad_token_id": 1,
272
+ "processor_class": "Wav2Vec2Processor",
273
+ "transformers_version": null,
274
+ "use_cache": false
275
+ }
create_model.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import jax.numpy as jnp
2
+ from transformers import AutoFeatureExtractor, AutoTokenizer, FlaxSpeechEncoderDecoderModel
3
+
4
+ encoder_id = "facebook/wav2vec2-large-lv60"
5
+ decoder_id = "facebook/bart-large-cnn"
6
+
7
+ model = FlaxSpeechEncoderDecoderModel.from_encoder_decoder_pretrained(encoder_id, decoder_id, encoder_add_adapter=True)
8
+
9
+ model.config.encoder.feat_proj_dropout = 0.0
10
+ model.config.encoder.final_dropout = 0.0
11
+ model.config.encoder.mask_time_prob = 0.1
12
+ model.config.decoder_start_token_id = model.config.decoder.bos_token_id
13
+ model.config.pad_token_id = model.config.decoder.pad_token_id
14
+ model.config.eos_token_id = model.config.decoder.eos_token_id
15
+ model.config.max_length = 40
16
+ model.config.num_beams = 1
17
+ model.config.encoder.layerdrop = 0.0
18
+ model.config.use_cache = False
19
+ model.config.processor_class = "Wav2Vec2Processor"
20
+
21
+ # check if generation works
22
+ out = model.generate(jnp.ones((1, 2000)))
23
+
24
+ model.save_pretrained("./")
25
+
26
+ feature_extractor = AutoFeatureExtractor.from_pretrained(encoder_id)
27
+ feature_extractor.save_pretrained("./")
28
+ tokenizer = AutoTokenizer.from_pretrained(decoder_id)
29
+ tokenizer.save_pretrained("./")
flax_model.msgpack ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59f268b5fa61d5eb20929dce97dfcfbd6123017d61789aef700566461af24242
3
+ size 2353635949
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
preprocessor_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "feature_extractor_type": "Wav2Vec2FeatureExtractor",
4
+ "feature_size": 1,
5
+ "padding_side": "right",
6
+ "padding_value": 0.0,
7
+ "return_attention_mask": true,
8
+ "sampling_rate": 16000
9
+ }
run_flax_speech_recognition_seq2seq.py ADDED
@@ -0,0 +1 @@
 
 
1
+ /home/sanchit_huggingface_co/transformers/examples/flax/speech-recognition/run_flax_speech_recognition_seq2seq.py
run_librispeech.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ python run_flax_speech_recognition_seq2seq.py \
3
+ --dataset_name="librispeech_asr" \
4
+ --model_name_or_path="./" \
5
+ --dataset_config_name="clean" \
6
+ --train_split_name="train.100" \
7
+ --eval_split_name="validation" \
8
+ --output_dir="./" \
9
+ --preprocessing_num_workers="16" \
10
+ --length_column_name="input_length" \
11
+ --overwrite_output_dir \
12
+ --num_train_epochs="5" \
13
+ --per_device_train_batch_size="4" \
14
+ --per_device_eval_batch_size="4" \
15
+ --gradient_accumulation_steps="2" \
16
+ --logging_steps="25" \
17
+ --max_duration_in_seconds="15" \
18
+ --max_target_length="64" \
19
+ --generation_max_length="40" \
20
+ --generation_num_beams="1" \
21
+ --learning_rate="3e-4" \
22
+ --warmup_steps="500" \
23
+ --text_column_name="text" \
24
+ --save_total_limit="1" \
25
+ --freeze_feature_encoder \
26
+ --predict_with_generate \
27
+ --do_lower_case \
28
+ --do_eval \
29
+ --do_train \
30
+ --push_to_hub \
31
+ --use_auth_token
32
+
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}}
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"errors": "replace", "bos_token": "<s>", "eos_token": "</s>", "sep_token": "</s>", "cls_token": "<s>", "unk_token": "<unk>", "pad_token": "<pad>", "mask_token": "<mask>", "add_prefix_space": false, "trim_offsets": true, "model_max_length": 1024, "special_tokens_map_file": null, "name_or_path": "facebook/bart-large-cnn", "tokenizer_class": "BartTokenizer"}
vocab.json ADDED
The diff for this file is too large to render. See raw diff