-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scripts for SummaryMixing SSL #9
Open
shucongzhang
wants to merge
1
commit into
SamsungLabs:SummaryMixing_w2v2
Choose a base branch
from
shucongzhang:SummaryMixing_w2v2
base: SummaryMixing_w2v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
# ################################ | ||
# SummaryMixing © 2023 by Samsung Electronics is licensed under CC BY-NC 4.0. | ||
|
||
# This is configurations of SummaryMixing wav2vec 2.0 downstream ASR on CommonVoice cy with a LSTM downstream model | ||
|
||
# Usage: Install SpeechBrain MP3S | ||
# Create a folder benchmarks/MP3S/CommonVoice/LSTM | ||
# Copy this file under benchmarks/MP3S/CommonVoice/LSTM/hparams | ||
# SummaryMixing: https://arxiv.org/abs/2307.07421 | ||
# SummaryMixing SSL: | ||
|
||
# Authors | ||
# * Titouan Parcollet 2023, 2024 | ||
# * Shucong Zhang 2023, 2024 | ||
# * Rogier van Dalen 2023, 2024 | ||
# * Sourav Bhattacharya 2023, 2024 | ||
# ################################ | ||
|
||
# Seed needs to be set at top of yaml, before objects with parameters are made | ||
seed: 1986 | ||
__set_seed: !apply:torch.manual_seed [!ref <seed>] | ||
language: cy # use 'it' for Italian, 'rw' for Kinyarwanda, 'en' for english | ||
output_folder: !ref results/CommonVoice/<language>/<seed> | ||
wer_file: !ref <output_folder>/wer.txt | ||
save_folder: !ref <output_folder>/save | ||
train_log: !ref <output_folder>/train_log.txt | ||
|
||
# Data files | ||
data_folder: !PLACEHOLDER # e.g, /local/cv-corpus-11.0-2022-09-21/<language> | ||
train_tsv_file: !ref <data_folder>/train.tsv # Standard CommonVoice .tsv files | ||
dev_tsv_file: !ref <data_folder>/dev.tsv # Standard CommonVoice .tsv files | ||
test_tsv_file: !ref <data_folder>/test.tsv # Standard CommonVoice .tsv files | ||
accented_letters: True | ||
train_csv: !ref <save_folder>/train.csv | ||
valid_csv: !ref <save_folder>/dev.csv | ||
test_csv: !ref <save_folder>/test.csv | ||
skip_prep: False # Skip data preparation | ||
|
||
avoid_if_longer_than: 10.0 | ||
|
||
num_layers_ssl: 13 #Number of layers in the SSL model (should be 25 for large ) | ||
pretrained_path: !PLACEHOLDER # e,g./path/to/pre-trained_SummaryMixing_w2v2 | ||
encoder_dim: 768 | ||
|
||
# Training parameters | ||
number_of_epochs: 20 | ||
lr: 0.0004 | ||
lr_weights: 0.02 | ||
sorting: ascending | ||
auto_mix_prec: False | ||
sample_rate: 16000 | ||
token_type: bpe # ["unigram", "bpe", "char"] | ||
character_coverage: 1.0 | ||
|
||
|
||
# With data_parallel batch_size is split into N jobs | ||
# With DDP batch_size is multiplied by N jobs | ||
# Must be 3 per GPU to fit 32GB of VRAM | ||
batch_size: 4 | ||
test_batch_size: 4 | ||
|
||
# Dataloader options | ||
train_dataloader_opts: | ||
batch_size: !ref <batch_size> | ||
dataloader_options: | ||
batch_size: !ref <batch_size> | ||
num_workers: 4 | ||
test_dataloader_options: | ||
batch_size: !ref <test_batch_size> | ||
num_workers: 4 | ||
|
||
|
||
valid_dataloader_opts: | ||
batch_size: !ref <batch_size> | ||
|
||
# Model parameters | ||
activation: !name:torch.nn.Sigmoid | ||
dnn_layers: 1 | ||
dnn_neurons: 768 | ||
freeze_encoder: True | ||
|
||
# Outputs | ||
output_neurons: 100 # BPE size, index(blank/eos/bos) = 0 | ||
|
||
|
||
# Functions and classes | ||
# | ||
epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter | ||
limit: !ref <number_of_epochs> | ||
|
||
augmentation: !new:speechbrain.lobes.augment.TimeDomainSpecAugment | ||
sample_rate: !ref <sample_rate> | ||
speeds: [95, 100, 105] | ||
|
||
encoder: !new:speechbrain.lobes.models.transformer.Conformer.ConformerEncoder | ||
d_model: 768 | ||
num_layers: 12 | ||
nhead: 8 | ||
d_ffn: 3072 | ||
dropout: 0.1 | ||
layerdrop_prob: 0.0 | ||
attention_type: SummaryMixing | ||
local_proj_hid_dim: [768] | ||
local_proj_out_dim: 768 | ||
summary_hid_dim: [768] | ||
mode: SummaryMixing | ||
output_hidden_states: True | ||
|
||
latentextractor_kernels: [3, 3] | ||
latentextractor_strides: [2, 1] | ||
extractor_dim: 512 | ||
embedding_dim: 768 | ||
|
||
CNN: !new:speechbrain.lobes.models.wav2vec.W2VLatentExtractor | ||
kernel_sizes: !ref <latentextractor_kernels> | ||
strides: !ref <latentextractor_strides> | ||
out_channels: [512, 512] | ||
input_dim: 80 | ||
|
||
weighted_ssl_model: !new:speechbrain.lobes.models.wav2vec.WeightedSSLModel | ||
pretrained_path: !ref <pretrained_path> | ||
num_layers: 13 | ||
latent_encoder: !ref <encoder> | ||
CNN: !ref <CNN> | ||
in_dim: 512 | ||
embedding_dim: 768 | ||
dropout_encoder_input: 0.1 | ||
output_hidden_states: True | ||
|
||
enc: !new:speechbrain.nnet.RNN.LSTM | ||
input_shape: [Null, Null, !ref <encoder_dim>] | ||
num_layers: 2 | ||
bidirectional: True | ||
dropout: 0.2 | ||
hidden_size: 1024 | ||
|
||
ctc_lin: !new:speechbrain.nnet.linear.Linear | ||
input_size: 2048 | ||
n_neurons: !ref <output_neurons> | ||
|
||
log_softmax: !new:speechbrain.nnet.activations.Softmax | ||
apply_log: True | ||
|
||
ctc_cost: !name:speechbrain.nnet.losses.ctc_loss | ||
blank_index: !ref <blank_index> | ||
|
||
modules: | ||
enc: !ref <enc> | ||
ctc_lin: !ref <ctc_lin> | ||
weighted_ssl_model: !ref <weighted_ssl_model> | ||
|
||
model: !new:torch.nn.ModuleList | ||
- [!ref <enc>, !ref <ctc_lin>] | ||
|
||
model_opt_class: !name:torch.optim.Adam | ||
lr: !ref <lr> | ||
|
||
weights_opt_class: !name:torch.optim.Adam | ||
lr: !ref <lr_weights> | ||
|
||
lr_annealing_model: !new:speechbrain.nnet.schedulers.NewBobScheduler | ||
initial_value: !ref <lr> | ||
improvement_threshold: 0.0025 | ||
annealing_factor: 0.8 | ||
patient: 0 | ||
|
||
lr_annealing_weights: !new:speechbrain.nnet.schedulers.NewBobScheduler | ||
initial_value: !ref <lr_weights> | ||
improvement_threshold: 0.0025 | ||
annealing_factor: 0.9 | ||
patient: 0 | ||
|
||
label_encoder: !new:speechbrain.dataio.encoder.CTCTextEncoder | ||
|
||
checkpointer: !new:speechbrain.utils.checkpoints.Checkpointer | ||
checkpoints_dir: !ref <save_folder> | ||
recoverables: | ||
model: !ref <model> | ||
ssl_model: !ref <weighted_ssl_model> | ||
scheduler_model: !ref <lr_annealing_model> | ||
scheduler_encoder: !ref <lr_annealing_weights> | ||
counter: !ref <epoch_counter> | ||
tokenizer: !ref <label_encoder> | ||
|
||
blank_index: 0 | ||
unk_index: 1 | ||
|
||
|
||
train_logger: !new:speechbrain.utils.train_logger.FileTrainLogger | ||
save_file: !ref <train_log> | ||
|
||
error_rate_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats | ||
|
||
cer_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats | ||
split_tokens: True |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not erase the previous Readme, it should be combined.