Rolv-Arild commited on
Commit
69315b7
1 Parent(s): 045e71b

Add language model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,15 @@ wandb/latest-run filter=lfs diff=lfs merge=lfs -text
33
  wandb/run-20220504_161621-2jrat5mt filter=lfs diff=lfs merge=lfs -text
34
  *.wandb filter=lfs diff=lfs merge=lfs -text
35
  *.log filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  wandb/run-20220504_161621-2jrat5mt filter=lfs diff=lfs merge=lfs -text
34
  *.wandb filter=lfs diff=lfs merge=lfs -text
35
  *.log filter=lfs diff=lfs merge=lfs -text
36
+ language_model/5gram.bin filter=lfs diff=lfs merge=lfs -text
37
+ language_model/unigrams.txt filter=lfs diff=lfs merge=lfs -text
38
+ log_NbAiLab_NPSC_16K_mp3_bokmaal_test_predictions.txt filter=lfs diff=lfs merge=lfs -text
39
+ log_NbAiLab_NPSC_16K_mp3_nynorsk_test_noLM_predictions.txt filter=lfs diff=lfs merge=lfs -text
40
+ log_NbAiLab_NPSC_16K_mp3_nynorsk_test_targets.txt filter=lfs diff=lfs merge=lfs -text
41
+ log_NbAiLab_NPSC_16K_mp3_nynorsk_test_withLM_targets.txt filter=lfs diff=lfs merge=lfs -text
42
+ log_NbAiLab_NPSC_NbAiLab_nb-wav2vec2-1b-bokmaal_16K_mp3_test_noLM_predictions.txt filter=lfs diff=lfs merge=lfs -text
43
+ log_NbAiLab_NPSC_NbAiLab_nb-wav2vec2-1b-bokmaal_16K_mp3_test_noLM_targets.txt filter=lfs diff=lfs merge=lfs -text
44
+ log_NbAiLab_NPSC_16K_mp3_bokmaal_test_targets.txt filter=lfs diff=lfs merge=lfs -text
45
+ log_NbAiLab_NPSC_16K_mp3_nynorsk_test_noLM_targets.txt filter=lfs diff=lfs merge=lfs -text
46
+ log_NbAiLab_NPSC_16K_mp3_nynorsk_test_predictions.txt filter=lfs diff=lfs merge=lfs -text
47
+ log_NbAiLab_NPSC_16K_mp3_nynorsk_test_withLM_predictions.txt filter=lfs diff=lfs merge=lfs -text
alphabet.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"labels": [" ", "(", ")", "0", "3", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "\u00e5", "\u00e6", "\u00f8", "\u2047", "", "<s>", "</s>"], "is_bpe": false}
eval.py CHANGED
@@ -6,14 +6,17 @@ from typing import Dict
6
  import torch
7
  from datasets import Audio, Dataset, load_dataset, load_metric
8
 
9
- from transformers import AutoFeatureExtractor, pipeline
 
10
 
11
 
12
  def log_results(result: Dataset, args: Dict[str, str]):
13
  """DO NOT CHANGE. This function computes and logs the result metrics."""
14
 
15
  log_outputs = args.log_outputs
16
- dataset_id = "_".join(args.dataset.split("/") + [args.config, args.split])
 
 
17
 
18
  # load metric
19
  wer = load_metric("wer")
@@ -107,7 +110,13 @@ def main(args):
107
  # load eval pipeline
108
  if args.device is None:
109
  args.device = 0 if torch.cuda.is_available() else -1
110
- asr = pipeline("automatic-speech-recognition", model=args.model_id, device=args.device)
 
 
 
 
 
 
111
 
112
  # map function to decode audio
113
  def map_to_pred(batch):
@@ -158,6 +167,9 @@ if __name__ == "__main__":
158
  default=None,
159
  help="The device to run the pipeline on. -1 for CPU (default), 0 for the first GPU and so on.",
160
  )
 
 
 
161
  args = parser.parse_args()
162
 
163
  main(args)
 
6
  import torch
7
  from datasets import Audio, Dataset, load_dataset, load_metric
8
 
9
+ from transformers import AutoFeatureExtractor, pipeline, Wav2Vec2Processor, Wav2Vec2ProcessorWithLM, Wav2Vec2FeatureExtractor
10
+ from pyctcdecode import BeamSearchDecoderCTC
11
 
12
 
13
  def log_results(result: Dataset, args: Dict[str, str]):
14
  """DO NOT CHANGE. This function computes and logs the result metrics."""
15
 
16
  log_outputs = args.log_outputs
17
+ lm = "withLM" if args.use_lm else "noLM"
18
+ model_id = args.model_id.replace("/", "_")
19
+ dataset_id = "_".join(args.dataset.split("/") + [model_id, args.config, args.split, lm])
20
 
21
  # load metric
22
  wer = load_metric("wer")
 
110
  # load eval pipeline
111
  if args.device is None:
112
  args.device = 0 if torch.cuda.is_available() else -1
113
+ # asr = pipeline("automatic-speech-recognition", model=args.model_id, device=args.device)
114
+
115
+ feature_extractor_dict, _ = Wav2Vec2FeatureExtractor.get_feature_extractor_dict(args.model_id)
116
+ feature_extractor_dict["processor_class"] = "Wav2Vec2Processor" if not args.use_lm else "Wav2Vec2ProcessorWithLM"
117
+ feature_extractor = Wav2Vec2FeatureExtractor.from_dict(feature_extractor_dict)
118
+
119
+ asr = pipeline("automatic-speech-recognition", model=args.model_id, feature_extractor=feature_extractor, device=args.device, decoder=BeamSearchDecoderCTC.load_from_dir("./"))
120
 
121
  # map function to decode audio
122
  def map_to_pred(batch):
 
167
  default=None,
168
  help="The device to run the pipeline on. -1 for CPU (default), 0 for the first GPU and so on.",
169
  )
170
+ parser.add_argument(
171
+ "--use_lm", action="store_true", help="If defined, use included language model as the decoder."
172
+ )
173
  args = parser.parse_args()
174
 
175
  main(args)
language_model/5gram.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e48d3691208ab8219abd2a0349e88f0e9f88ddb56ab5d56c6f9570a013018d6
3
+ size 8035805872
language_model/attrs.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"alpha": 0.5, "beta": 1.5, "unk_score_offset": -10.0, "score_boundary": true}
language_model/unigrams.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e99e073a2a254cc0b1a03e6e359bc0dd7bf94c8d0cbbb9039a7cee7747fec008
3
+ size 27965514
preprocessor_config.json CHANGED
@@ -4,6 +4,7 @@
4
  "feature_size": 1,
5
  "padding_side": "right",
6
  "padding_value": 0,
 
7
  "return_attention_mask": true,
8
  "sampling_rate": 16000
9
  }
 
4
  "feature_size": 1,
5
  "padding_side": "right",
6
  "padding_value": 0,
7
+ "processor_class": "Wav2Vec2ProcessorWithLM",
8
  "return_attention_mask": true,
9
  "sampling_rate": 16000
10
  }
special_tokens_map.json CHANGED
@@ -1 +1 @@
1
- {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "[UNK]", "pad_token": "[PAD]", "additional_special_tokens": [{"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}]}
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "[UNK]", "pad_token": "[PAD]", "additional_special_tokens": [{"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}]}
tokenizer_config.json CHANGED
@@ -1 +1 @@
1
- {"unk_token": "[UNK]", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "[PAD]", "do_lower_case": false, "word_delimiter_token": "|", "replace_word_delimiter_char": " ", "special_tokens_map_file": null, "name_or_path": "./", "tokenizer_class": "Wav2Vec2CTCTokenizer"}
 
1
+ {"unk_token": "[UNK]", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "[PAD]", "do_lower_case": false, "word_delimiter_token": "|", "replace_word_delimiter_char": " ", "special_tokens_map_file": null, "name_or_path": "./", "tokenizer_class": "Wav2Vec2CTCTokenizer", "processor_class": "Wav2Vec2ProcessorWithLM"}
wandb/run-20220504_161621-2jrat5mt/files/config.yaml CHANGED
@@ -4833,6 +4833,14 @@ _wandb:
4833
  - 51
4834
  - 53
4835
  - 55
 
 
 
 
 
 
 
 
4836
  3:
4837
  - 1
4838
  - 7
 
4833
  - 51
4834
  - 53
4835
  - 55
4836
+ 2:
4837
+ - 1
4838
+ - 5
4839
+ - 11
4840
+ - 49
4841
+ - 51
4842
+ - 53
4843
+ - 55
4844
  3:
4845
  - 1
4846
  - 7
wandb/run-20220504_161621-2jrat5mt/files/wandb-summary.json CHANGED
The diff for this file is too large to render. See raw diff
 
wandb/run-20220504_161621-2jrat5mt/logs/debug.log CHANGED
@@ -1,27 +1,3 @@
1
- 2022-05-04 16:16:21,380 INFO MainThread:171371 [wandb_setup.py:_flush():75] Loading settings from /home/rolvb/.config/wandb/settings
2
- 2022-05-04 16:16:21,380 INFO MainThread:171371 [wandb_setup.py:_flush():75] Loading settings from /mnt/lv_ai_1_dante/ml/models/wav2vec2-large-voxrex-npsc-nst/wandb/settings
3
- 2022-05-04 16:16:21,380 INFO MainThread:171371 [wandb_setup.py:_flush():75] Loading settings from environment variables: {'project': 'wav2vec2', 'entity': 'NbAiLab'}
4
- 2022-05-04 16:16:21,380 INFO MainThread:171371 [wandb_setup.py:_flush():75] Inferring run settings from compute environment: {'program_relpath': 'run_speech_recognition_ctc.py', 'program': '/mnt/lv_ai_1_dante/ml/models/wav2vec2-large-voxrex-npsc-nst/run_speech_recognition_ctc.py'}
5
- 2022-05-04 16:16:21,381 INFO MainThread:171371 [wandb_init.py:_log_setup():437] Logging user logs to /mnt/lv_ai_1_dante/ml/models/wav2vec2-large-voxrex-npsc-nst/wandb/run-20220504_161621-2jrat5mt/logs/debug.log
6
- 2022-05-04 16:16:21,381 INFO MainThread:171371 [wandb_init.py:_log_setup():438] Logging internal logs to /mnt/lv_ai_1_dante/ml/models/wav2vec2-large-voxrex-npsc-nst/wandb/run-20220504_161621-2jrat5mt/logs/debug-internal.log
7
- 2022-05-04 16:16:21,381 INFO MainThread:171371 [wandb_init.py:init():471] calling init triggers
8
- 2022-05-04 16:16:21,381 INFO MainThread:171371 [wandb_init.py:init():474] wandb.init called with sweep_config: {}
9
- config: {}
10
- 2022-05-04 16:16:21,382 INFO MainThread:171371 [wandb_init.py:init():524] starting backend
11
- 2022-05-04 16:16:21,382 INFO MainThread:171371 [backend.py:_multiprocessing_setup():97] multiprocessing start_methods=fork,spawn,forkserver, using: spawn
12
- 2022-05-04 16:16:21,472 INFO MainThread:171371 [backend.py:ensure_launched():217] starting backend process...
13
- 2022-05-04 16:16:21,547 INFO MainThread:171371 [backend.py:ensure_launched():222] started backend process with pid: 171932
14
- 2022-05-04 16:16:21,549 INFO MainThread:171371 [wandb_init.py:init():533] backend started and connected
15
- 2022-05-04 16:16:21,556 INFO MainThread:171371 [wandb_init.py:init():597] updated telemetry
16
- 2022-05-04 16:16:21,746 INFO MainThread:171371 [wandb_init.py:init():628] communicating run to backend with 30 second timeout
17
- 2022-05-04 16:16:22,352 INFO MainThread:171371 [wandb_run.py:_on_init():1923] communicating current version
18
- 2022-05-04 16:16:22,489 INFO MainThread:171371 [wandb_run.py:_on_init():1927] got version response upgrade_message: "wandb version 0.12.16 is available! To upgrade, please run:\n $ pip install wandb --upgrade"
19
-
20
- 2022-05-04 16:16:22,489 INFO MainThread:171371 [wandb_init.py:init():659] starting run threads in backend
21
- 2022-05-04 16:16:22,550 INFO MainThread:171371 [wandb_run.py:_console_start():1897] atexit reg
22
- 2022-05-04 16:16:22,551 INFO MainThread:171371 [wandb_run.py:_redirect():1770] redirect: SettingsConsole.REDIRECT
23
- 2022-05-04 16:16:22,551 INFO MainThread:171371 [wandb_run.py:_redirect():1775] Redirecting console.
24
- 2022-05-04 16:16:22,554 INFO MainThread:171371 [wandb_run.py:_redirect():1831] Redirects installed.
25
- 2022-05-04 16:16:22,554 INFO MainThread:171371 [wandb_init.py:init():684] run started, returning control to user process
26
- 2022-05-04 16:16:22,578 INFO MainThread:171371 [wandb_run.py:_config_callback():1131] config_cb None None {'return_dict': True, 'output_hidden_states': False, 'output_attentions': False, 'torchscript': False, 'torch_dtype': None, 'use_bfloat16': False, 'pruned_heads': {}, 'tie_word_embeddings': True, 'is_encoder_decoder': False, 'is_decoder': False, 'cross_attention_hidden_size': None, 'add_cross_attention': False, 'tie_encoder_decoder': False, 'max_length': 20, 'min_length': 0, 'do_sample': False, 'early_stopping': False, 'num_beams': 1, 'num_beam_groups': 1, 'diversity_penalty': 0.0, 'temperature': 1.0, 'top_k': 50, 'top_p': 1.0, 'typical_p': 1.0, 'repetition_penalty': 1.0, 'length_penalty': 1.0, 'no_repeat_ngram_size': 0, 'encoder_no_repeat_ngram_size': 0, 'bad_words_ids': None, 'num_return_sequences': 1, 'chunk_size_feed_forward': 0, 'output_scores': False, 'return_dict_in_generate': False, 'forced_bos_token_id': None, 'forced_eos_token_id': None, 'remove_invalid_values': False, 'exponential_decay_length_penalty': None, 'architectures': ['Wav2Vec2ForPreTraining'], 'finetuning_task': None, 'id2label': {0: 'LABEL_0', 1: 'LABEL_1'}, 'label2id': {'LABEL_0': 0, 'LABEL_1': 1}, 'tokenizer_class': None, 'prefix': None, 'bos_token_id': 1, 'pad_token_id': 38, 'eos_token_id': 2, 'sep_token_id': None, 'decoder_start_token_id': None, 'task_specific_params': None, 'problem_type': None, '_name_or_path': 'KBLab/wav2vec2-large-voxrex', 'transformers_version': '4.18.0', 'feat_extract_dropout': 0.0, 'mask_channel_length': 10, 'mask_channel_min_space': 1, 'mask_channel_other': 0.0, 'mask_channel_prob': 0.0, 'mask_channel_selection': 'static', 'mask_time_min_space': 1, 'mask_time_other': 0.0, 'mask_time_selection': 'static', 'model_type': 'wav2vec2', 'num_feat_extract_layers': 7, 'hidden_size': 1024, 'feat_extract_norm': 'layer', 'feat_extract_activation': 'gelu', 'conv_dim': [512, 512, 512, 512, 512, 512, 512], 'conv_stride': [5, 2, 2, 2, 2, 2, 2], 'conv_kernel': [10, 3, 3, 3, 3, 2, 2], 'conv_bias': True, 'num_conv_pos_embeddings': 128, 'num_conv_pos_embedding_groups': 16, 'num_hidden_layers': 24, 'intermediate_size': 4096, 'hidden_act': 'gelu', 'num_attention_heads': 16, 'hidden_dropout': 0.047, 'attention_dropout': 0.094, 'activation_dropout': 0.055, 'feat_proj_dropout': 0.04, 'final_dropout': 0.0, 'layerdrop': 0.041, 'layer_norm_eps': 1e-05, 'initializer_range': 0.02, 'vocab_size': 41, 'do_stable_layer_norm': True, 'use_weighted_layer_sum': False, 'apply_spec_augment': True, 'mask_time_prob': 0.082, 'mask_time_length': 10, 'mask_time_min_masks': 2, 'mask_feature_prob': 0.25, 'mask_feature_length': 64, 'mask_feature_min_masks': 0, 'num_codevectors_per_group': 320, 'num_codevector_groups': 2, 'contrastive_logits_temperature': 0.1, 'feat_quantizer_dropout': 0.0, 'num_negatives': 100, 'codevector_dim': 768, 'proj_codevector_dim': 768, 'diversity_loss_weight': 0.1, 'ctc_loss_reduction': 'mean', 'ctc_zero_infinity': True, 'add_adapter': False, 'adapter_kernel_size': 3, 'adapter_stride': 2, 'num_adapter_layers': 3, 'output_hidden_size': 1024, 'classifier_proj_size': 256, 'tdnn_dim': [512, 512, 512, 512, 1500], 'tdnn_kernel': [5, 3, 3, 1, 1], 'tdnn_dilation': [1, 2, 3, 1, 1], 'xvector_output_dim': 512, 'output_dir': './', 'overwrite_output_dir': True, 'do_train': True, 'do_eval': True, 'do_predict': False, 'evaluation_strategy': 'steps', 'prediction_loss_only': False, 'per_device_train_batch_size': 16, 'per_device_eval_batch_size': 16, 'per_gpu_train_batch_size': 'None', 'per_gpu_eval_batch_size': 'None', 'gradient_accumulation_steps': 2, 'eval_accumulation_steps': 'None', 'eval_delay': 0, 'learning_rate': 0.0001, 'weight_decay': 0.0, 'adam_beta1': 0.9, 'adam_beta2': 0.999, 'adam_epsilon': 1e-08, 'max_grad_norm': 1.0, 'num_train_epochs': 15.0, 'max_steps': -1, 'lr_scheduler_type': 'linear', 'warmup_ratio': 0.0, 'warmup_steps': 2000, 'log_level': -1, 'log_level_replica': -1, 'log_on_each_node': True, 'logging_dir': './runs/May04_16-13-20_dante', 'logging_strategy': 'steps', 'logging_first_step': False, 'logging_steps': 100, 'logging_nan_inf_filter': True, 'save_strategy': 'steps', 'save_steps': 500, 'save_total_limit': 3, 'save_on_each_node': False, 'no_cuda': False, 'seed': 42, 'data_seed': 'None', 'bf16': False, 'fp16': True, 'fp16_opt_level': 'O1', 'half_precision_backend': 'amp', 'bf16_full_eval': False, 'fp16_full_eval': False, 'tf32': 'None', 'local_rank': -1, 'xpu_backend': 'None', 'tpu_num_cores': 'None', 'tpu_metrics_debug': False, 'debug': '[]', 'dataloader_drop_last': False, 'eval_steps': 500, 'dataloader_num_workers': 0, 'past_index': -1, 'run_name': './', 'disable_tqdm': False, 'remove_unused_columns': True, 'label_names': 'None', 'load_best_model_at_end': False, 'metric_for_best_model': 'None', 'greater_is_better': 'None', 'ignore_data_skip': False, 'sharded_ddp': '[]', 'deepspeed': 'None', 'label_smoothing_factor': 0.0, 'optim': 'adamw_hf', 'adafactor': False, 'group_by_length': True, 'length_column_name': 'input_length', 'report_to': "['wandb']", 'ddp_find_unused_parameters': 'None', 'ddp_bucket_cap_mb': 'None', 'dataloader_pin_memory': True, 'skip_memory_metrics': True, 'use_legacy_prediction_loop': False, 'push_to_hub': True, 'resume_from_checkpoint': 'None', 'hub_model_id': 'NbAiLab/wav2vec2-large-voxrex-npsc-nst', 'hub_strategy': 'every_save', 'hub_token': '<HUB_TOKEN>', 'gradient_checkpointing': True, 'fp16_backend': 'auto', 'push_to_hub_model_id': 'None', 'push_to_hub_organization': 'None', 'push_to_hub_token': '<PUSH_TO_HUB_TOKEN>', '_n_gpu': 1, 'mp_parameters': '', 'train_batch_size': 16, 'eval_batch_size': 16}
27
- 2022-05-04 16:16:22,581 INFO MainThread:171371 [wandb_watch.py:watch():47] Watching
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ec0e95e8be145bc7776c7c2e3f70f3f5a05a9a4dc5e54d1a56e28de1a32d7f2
3
+ size 13018