dd3434 commited on
Commit
a4dffe3
·
verified ·
1 Parent(s): 814e889

Upload word_asr/chunk_streaming_word_fastemit.yaml with huggingface_hub

Browse files
word_asr/chunk_streaming_word_fastemit.yaml ADDED
@@ -0,0 +1,428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ############################################################################
2
+ # Model: E2E ASR with transformer and transducer
3
+ # Encoder: Conformer
4
+ # Decoder: LSTM + beamsearch + RNNLM
5
+ # Tokens: BPE with unigram
6
+ # losses: Transducer + CTC (optional) + CE (optional)
7
+ # Training: Librispeech 960h
8
+ # Authors: Titouan Parcollet 2023, Abdel HEBA, Mirco Ravanelli, Sung-Lin Yeh 2020
9
+ # ############################################################################
10
+
11
+ # Seed needs to be set at top of yaml, before objects with parameters are made
12
+
13
+ seed: 3419
14
+ __set_seed: !apply:speechbrain.utils.seed_everything [3419]
15
+ output_folder: results/conformer_transducer_char/3419_fastemit
16
+ output_wer_folder: results/conformer_transducer_char/3419_fastemit/
17
+ save_folder: results/conformer_transducer_char/3407/save
18
+ checkpoint_folder: results/conformer_transducer_char/3419_fastemit/save
19
+ train_log: results/conformer_transducer_char/3419_fastemit/train_log.txt
20
+ pretrain_source: speechbrain/asr-streaming-conformer-librispeech
21
+ pretrain_folder: results/conformer_transducer_char/3419_fastemit/pretrained
22
+
23
+ # Data files
24
+ data_folder: /gallery_rijks/jinyoung.park/datasets/LibriSpeech
25
+ emilia_data_folder: /gallery_goya/kangwook.kim/datasets/Emilia-Dataset/Emilia/EN
26
+ emilia_train_csv: /gallery_rijks/jinyoung.park/datasets/Emilia/emilia_en_400h.csv
27
+
28
+ # CSV files (LibriSpeech, pre-existing from 3409 save)
29
+ train_csv:
30
+ - results/conformer_transducer_char/3409/train-clean-100.csv
31
+ - results/conformer_transducer_char/3409/train-clean-360.csv
32
+ - results/conformer_transducer_char/3409/train-other-500.csv
33
+
34
+ valid_csv: results/conformer_transducer_char/3409/dev-clean.csv
35
+
36
+ test_csv:
37
+ - results/conformer_transducer_char/3409/test-clean.csv
38
+ - results/conformer_transducer_char/3409/test-other.csv
39
+
40
+ ckpt_interval_minutes: 5
41
+ # Language model (LM) pretraining
42
+ # NB: To avoid mismatch, the speech recognizer must be trained with the same
43
+ # tokenizer used for LM training. Here, we download everything from the
44
+ # speechbrain HuggingFace repository. However, a local path pointing to a
45
+ # directory containing the lm.ckpt and tokenizer.ckpt may also be specified
46
+ # instead. E.g if you want to use your own LM / tokenizer.
47
+ pretrained_lm_tokenizer_path: speechbrain/asr-crdnn-rnnlm-librispeech
48
+
49
+
50
+ ####################### Training Parameters ####################################
51
+
52
+ # To make Transformers converge, the global bath size should be large enough.
53
+ # The global batch size is computed as batch_size * n_gpus * grad_accumulation_factor.
54
+ # Empirically, we found that this value should be >= 128.
55
+ # Please, set your parameters accordingly.
56
+ number_of_epochs: 100
57
+ num_workers: 4
58
+ batch_size_valid: 4
59
+ lr: 0.0004
60
+ weight_decay: 0.01
61
+ number_of_ctc_epochs: 60
62
+ ctc_weight: 0.3 # Multitask with CTC for the encoder (0.0 = disabled)
63
+ ce_weight: 0.0 # Multitask with CE for the decoder (0.0 = disabled)
64
+ max_grad_norm: 5.0
65
+ loss_reduction: 'batchmean'
66
+ precision: fp16 # bf16, fp16 or fp32
67
+
68
+ # The batch size is used if and only if dynamic batching is set to False
69
+ # Validation and testing are done with fixed batches and not dynamic batching.
70
+ batch_size: 6
71
+ grad_accumulation_factor: 4
72
+ sorting: random
73
+ avg_checkpoints: 10 # Number of checkpoints to average for evaluation
74
+
75
+ # Feature parameters
76
+ sample_rate: 16000
77
+ n_fft: 512
78
+ n_mels: 80
79
+ win_length: 32
80
+
81
+ # Streaming & dynamic chunk training options
82
+ # At least for the current architecture on LibriSpeech, we found out that
83
+ # non-streaming accuracy is very similar between `streaming: True` and
84
+ # `streaming: False`.
85
+ streaming: True # controls all Dynamic Chunk Training & chunk size & left context mechanisms
86
+
87
+ # Configuration for Dynamic Chunk Training.
88
+ # In this model, a chunk is roughly equivalent to 40ms of audio.
89
+ dynchunktrain_config_sampler: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfigRandomSampler # yamllint disable-line rule:line-length
90
+ chunkwise_prob: 1.0 # Probability during a batch to limit attention and sample a random chunk size in the following range
91
+ chunk_size_min: 4 # Minimum chunk size (if in a DynChunkTrain batch)
92
+ chunk_size_max: 4 # Maximum chunk size (if in a DynChunkTrain batch)
93
+ limited_left_context_prob: 1.0 # If in a DynChunkTrain batch, the probability during a batch to restrict left context to a random number of chunks
94
+ left_context_chunks_min: 32 # Minimum left context size (in # of chunks)
95
+ left_context_chunks_max: 32 # Maximum left context size (in # of chunks)
96
+ # If you specify a valid/test config, you can optionally have evaluation be
97
+ # done with a specific DynChunkTrain configuration.
98
+ valid_config: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfig
99
+ chunk_size: 4
100
+ left_context_size: 32
101
+
102
+ # Dataloader options
103
+ train_dataloader_opts:
104
+ batch_size: !ref <batch_size>
105
+ num_workers: !ref <num_workers>
106
+
107
+ valid_dataloader_opts:
108
+ batch_size: !ref <batch_size_valid>
109
+
110
+ test_dataloader_opts:
111
+ batch_size: !ref <batch_size_valid>
112
+
113
+ # This setup works well for 3090 24GB GPU, adapt it to your needs.
114
+ # Adjust grad_accumulation_factor depending on the DDP node count (here 3)
115
+ # Or turn it off (but training speed will decrease)
116
+ dynamic_batching: True
117
+ max_batch_len: 80
118
+ max_batch_len_val: 50 # we reduce it as the beam is much wider (VRAM)
119
+ num_bucket: 200
120
+
121
+ dynamic_batch_sampler:
122
+ max_batch_len: !ref <max_batch_len>
123
+ max_batch_len_val: !ref <max_batch_len_val>
124
+ num_buckets: !ref <num_bucket>
125
+ shuffle_ex: True # if true re-creates batches at each epoch shuffling examples.
126
+ batch_ordering: random
127
+ max_batch_ex: 256
128
+
129
+ ####################### Model Parameters #######################################
130
+
131
+ # Transformer
132
+ d_model: 512
133
+ joint_dim: 640
134
+ nhead: 8
135
+ num_encoder_layers: 12
136
+ num_decoder_layers: 0
137
+ d_ffn: 2048
138
+ transformer_dropout: 0.1
139
+ activation: !name:torch.nn.GELU
140
+ output_neurons: 1000
141
+ dec_dim: 512
142
+ dec_emb_dropout: 0.2
143
+ dec_dropout: 0.1
144
+ attention_type: RelPosMHAXL
145
+
146
+ # Decoding parameters
147
+ blank_index: 0
148
+ bos_index: 0
149
+ eos_index: 0
150
+ pad_index: 0
151
+ beam_size: 10
152
+ nbest: 1
153
+ # by default {state,expand}_beam = 2.3 as mention in paper
154
+ # https://arxiv.org/abs/1904.02619
155
+ state_beam: 2.3
156
+ expand_beam: 2.3
157
+ lm_weight: 0.50
158
+
159
+ # If True uses torchaudio loss. Otherwise, the numba one
160
+ use_torchaudio: False
161
+
162
+ epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter
163
+ limit: !ref <number_of_epochs>
164
+
165
+ normalize: !new:speechbrain.processing.features.InputNormalization
166
+ norm_type: global
167
+ update_until_epoch: 4
168
+
169
+ compute_features: !new:speechbrain.lobes.features.Fbank
170
+ sample_rate: !ref <sample_rate>
171
+ n_fft: !ref <n_fft>
172
+ n_mels: !ref <n_mels>
173
+ win_length: !ref <win_length>
174
+
175
+ ############################## Augmentations ###################################
176
+
177
+ # Speed perturbation
178
+ speed_perturb: !new:speechbrain.augment.time_domain.SpeedPerturb
179
+ orig_freq: !ref <sample_rate>
180
+ speeds: [95, 100, 105]
181
+
182
+ # Augmenter: Combines previously defined augmentations to perform data augmentation
183
+ wav_augment: !new:speechbrain.augment.augmenter.Augmenter
184
+ min_augmentations: 1
185
+ max_augmentations: 1
186
+ augment_prob: 1.0
187
+ augmentations: [!ref <speed_perturb>]
188
+
189
+
190
+ # Time Drop
191
+ time_drop: !new:speechbrain.augment.freq_domain.SpectrogramDrop
192
+ drop_length_low: 12
193
+ drop_length_high: 20
194
+ drop_count_low: 5
195
+ drop_count_high: 5
196
+ replace: "zeros"
197
+
198
+ # Frequency Drop
199
+ freq_drop: !new:speechbrain.augment.freq_domain.SpectrogramDrop
200
+ drop_length_low: 20
201
+ drop_length_high: 25
202
+ drop_count_low: 2
203
+ drop_count_high: 2
204
+ replace: "zeros"
205
+ dim: 2
206
+
207
+ # Time warp
208
+ time_warp: !new:speechbrain.augment.freq_domain.Warping
209
+
210
+ fea_augment: !new:speechbrain.augment.augmenter.Augmenter
211
+ parallel_augment: False
212
+ concat_original: False
213
+ repeat_augment: 1
214
+ shuffle_augmentations: False
215
+ min_augmentations: 3
216
+ max_augmentations: 3
217
+ augment_prob: 1.0
218
+ augmentations: [
219
+ !ref <time_drop>,
220
+ !ref <freq_drop>,
221
+ !ref <time_warp>]
222
+
223
+ ############################## Models ##########################################
224
+
225
+ CNN: !new:speechbrain.lobes.models.convolution.ConvolutionFrontEnd
226
+ input_shape: (8, 10, 80)
227
+ num_blocks: 2
228
+ num_layers_per_block: 1
229
+ out_channels: (64, 32)
230
+ kernel_sizes: (3, 3)
231
+ strides: (2, 2)
232
+ residuals: (False, False)
233
+
234
+ Transformer: !new:speechbrain.lobes.models.transformer.TransformerASR.TransformerASR # yamllint disable-line rule:line-length
235
+ input_size: 640
236
+ tgt_vocab: !ref <output_neurons>
237
+ d_model: !ref <d_model>
238
+ nhead: !ref <nhead>
239
+ num_encoder_layers: !ref <num_encoder_layers>
240
+ num_decoder_layers: !ref <num_decoder_layers>
241
+ d_ffn: !ref <d_ffn>
242
+ dropout: !ref <transformer_dropout>
243
+ activation: !ref <activation>
244
+ encoder_module: conformer
245
+ attention_type: !ref <attention_type>
246
+ normalize_before: True
247
+ causal: False
248
+
249
+ # We must call an encoder wrapper so the decoder isn't run (we don't have any)
250
+ enc: !new:speechbrain.lobes.models.transformer.TransformerASR.EncoderWrapper
251
+ transformer: !ref <Transformer>
252
+
253
+ # For MTL CTC over the encoder
254
+ proj_ctc: !new:speechbrain.nnet.linear.Linear
255
+ input_size: !ref <joint_dim>
256
+ n_neurons: !ref <output_neurons>
257
+
258
+ # Define some projection layers to make sure that enc and dec
259
+ # output dim are the same before joining
260
+ proj_enc: !new:speechbrain.nnet.linear.Linear
261
+ input_size: !ref <d_model>
262
+ n_neurons: !ref <joint_dim>
263
+ bias: False
264
+
265
+ proj_dec: !new:speechbrain.nnet.linear.Linear
266
+ input_size: !ref <dec_dim>
267
+ n_neurons: !ref <joint_dim>
268
+ bias: False
269
+
270
+ # Uncomment for MTL with CTC
271
+ ctc_cost: !name:speechbrain.nnet.losses.ctc_loss
272
+ blank_index: !ref <blank_index>
273
+ reduction: !ref <loss_reduction>
274
+
275
+ emb: !new:speechbrain.nnet.embedding.Embedding
276
+ num_embeddings: !ref <output_neurons>
277
+ consider_as_one_hot: True
278
+ blank_id: !ref <blank_index>
279
+
280
+ dec: !new:speechbrain.nnet.RNN.LSTM
281
+ input_shape: [null, null, !ref <output_neurons> - 1]
282
+ hidden_size: !ref <dec_dim>
283
+ num_layers: 1
284
+ re_init: True
285
+
286
+ # For MTL with LM over the decoder (need to uncomment to activate)
287
+ # dec_lin: !new:speechbrain.nnet.linear.Linear
288
+ # input_size: !ref <joint_dim>
289
+ # n_neurons: !ref <output_neurons>
290
+ # bias: False
291
+
292
+ # For MTL
293
+ ce_cost: !name:speechbrain.nnet.losses.nll_loss
294
+ label_smoothing: 0.1
295
+
296
+ Tjoint: !new:speechbrain.nnet.transducer.transducer_joint.Transducer_joint
297
+ joint: sum # joint [sum | concat]
298
+ nonlinearity: !ref <activation>
299
+
300
+ transducer_lin: !new:speechbrain.nnet.linear.Linear
301
+ input_size: !ref <joint_dim>
302
+ n_neurons: !ref <output_neurons>
303
+ bias: False
304
+
305
+ log_softmax: !new:speechbrain.nnet.activations.Softmax
306
+ apply_log: True
307
+
308
+ transducer_cost: !name:speechbrain.nnet.losses.transducer_loss
309
+ blank_index: !ref <blank_index>
310
+ use_torchaudio: !ref <use_torchaudio>
311
+
312
+ # This is the RNNLM that is used according to the Huggingface repository
313
+ # NB: It has to match the pre-trained RNNLM!!
314
+ lm_model: !new:speechbrain.lobes.models.RNNLM.RNNLM
315
+ output_neurons: !ref <output_neurons>
316
+ embedding_dim: 128
317
+ activation: !name:torch.nn.LeakyReLU
318
+ dropout: 0.0
319
+ rnn_layers: 2
320
+ rnn_neurons: 2048
321
+ dnn_blocks: 1
322
+ dnn_neurons: 512
323
+ return_hidden: True # For inference
324
+
325
+ # for MTL
326
+ # update model if any HEAD module is added
327
+ modules:
328
+ CNN: !ref <CNN>
329
+ enc: !ref <enc>
330
+ emb: !ref <emb>
331
+ dec: !ref <dec>
332
+ Tjoint: !ref <Tjoint>
333
+ transducer_lin: !ref <transducer_lin>
334
+ normalize: !ref <normalize>
335
+ lm_model: !ref <lm_model>
336
+ proj_ctc: !ref <proj_ctc>
337
+ proj_dec: !ref <proj_dec>
338
+ proj_enc: !ref <proj_enc>
339
+ # dec_lin: !ref <dec_lin>
340
+
341
+ # for MTL
342
+ # update model if any HEAD module is added
343
+ model: !new:torch.nn.ModuleList
344
+ - [!ref <CNN>, !ref <enc>, !ref <emb>, !ref <dec>, !ref <proj_enc>, !ref <proj_dec>, !ref <proj_ctc>, !ref <transducer_lin>]
345
+
346
+ ############################## Decoding & optimiser ############################
347
+
348
+ # Tokenizer initialization
349
+ tokenizer: !new:sentencepiece.SentencePieceProcessor
350
+
351
+ Greedysearcher: !new:speechbrain.decoders.transducer.TransducerBeamSearcher
352
+ decode_network_lst: [!ref <emb>, !ref <dec>, !ref <proj_dec>]
353
+ tjoint: !ref <Tjoint>
354
+ classifier_network: [!ref <transducer_lin>]
355
+ blank_id: !ref <blank_index>
356
+ beam_size: 1
357
+ nbest: 1
358
+
359
+ Beamsearcher: !new:speechbrain.decoders.transducer.TransducerBeamSearcher
360
+ decode_network_lst: [!ref <emb>, !ref <dec>, !ref <proj_dec>]
361
+ tjoint: !ref <Tjoint>
362
+ classifier_network: [!ref <transducer_lin>]
363
+ blank_id: !ref <blank_index>
364
+ beam_size: !ref <beam_size>
365
+ nbest: !ref <nbest>
366
+ lm_module: !ref <lm_model>
367
+ lm_weight: !ref <lm_weight>
368
+ state_beam: !ref <state_beam>
369
+ expand_beam: !ref <expand_beam>
370
+
371
+ opt_class: !name:torch.optim.AdamW
372
+ lr: !ref <lr>
373
+ betas: (0.9, 0.98)
374
+ eps: 1.e-8
375
+ weight_decay: !ref <weight_decay>
376
+
377
+ ############################## Logging and Pretrainer ##########################
378
+
379
+ checkpointer: !new:speechbrain.utils.checkpoints.Checkpointer
380
+ checkpoints_dir: !ref <checkpoint_folder>
381
+ recoverables:
382
+ model: !ref <model>
383
+ normalizer: !ref <normalize>
384
+ counter: !ref <epoch_counter>
385
+
386
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
387
+ collect_in: !ref <pretrain_folder>
388
+ loadables:
389
+ model: !ref <model>
390
+ tokenizer: !ref <tokenizer>
391
+ normalizer: !ref <normalize>
392
+ paths:
393
+ model: !ref <pretrain_source>/model.ckpt
394
+ tokenizer: !ref <pretrain_source>/tokenizer.ckpt
395
+ normalizer: !ref <pretrain_source>/normalizer.ckpt
396
+
397
+ train_logger: !new:speechbrain.utils.train_logger.WandBLogger
398
+ initializer: !name:wandb.init
399
+ project: streaming-asr
400
+ name: conformer_transducer_char
401
+ dir: results/conformer_transducer_char/3419_casual/wandb
402
+ reinit: true
403
+ resume: false
404
+
405
+
406
+ error_rate_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats
407
+
408
+ cer_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats
409
+ split_tokens: True
410
+
411
+
412
+ make_tokenizer_streaming_context: !name:speechbrain.tokenizers.SentencePiece.SentencePieceDecoderStreamingContext
413
+ tokenizer_decode_streaming: !name:speechbrain.tokenizers.SentencePiece.spm_decode_preserve_leading_space
414
+
415
+ make_decoder_streaming_context: !name:speechbrain.decoders.transducer.TransducerGreedySearcherStreamingContext # default constructor
416
+ decoding_function: !name:speechbrain.decoders.transducer.TransducerBeamSearcher.transducer_greedy_decode_streaming
417
+ - !ref <Greedysearcher> # self
418
+
419
+ fea_streaming_extractor: !new:speechbrain.lobes.features.StreamingFeatureWrapper
420
+ module: !new:speechbrain.nnet.containers.LengthsCapableSequential
421
+ - !ref <compute_features>
422
+ - !ref <normalize>
423
+ - !ref <CNN>
424
+ # don't consider normalization as part of the input filter chain.
425
+ # normalization will operate at chunk level, which mismatches training
426
+ # somewhat, but does not appear to result in noticeable degradation.
427
+ properties: !apply:speechbrain.utils.filter_analysis.stack_filter_properties
428
+ - [!ref <compute_features>, !ref <CNN>]