SakshiRathi77 commited on
Commit
c41c330
1 Parent(s): 9f083ac

Upload 8 files

Browse files
README.md ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: facebook/wav2vec2-xls-r-300m
4
+ tags:
5
+ - generated_from_trainer
6
+ metrics:
7
+ - wer
8
+ - cer
9
+ model-index:
10
+ - name: wav2vec2-large-xls-r-300m-hi
11
+ results:
12
+ - task:
13
+ name: Automatic Speech Recognition
14
+ type: automatic-speech-recognition
15
+ dataset:
16
+ name: Common Voice 15
17
+ type: mozilla-foundation/common_voice_15_0
18
+ args: hi
19
+ metrics:
20
+ - name: Test WER
21
+ type: wer
22
+ value: 0.2934
23
+ - name: Test CER
24
+ type: cer
25
+ value: 0.0786
26
+ - task:
27
+ name: Automatic Speech Recognition
28
+ type: automatic-speech-recognition
29
+ dataset:
30
+ name: Common Voice 8
31
+ type: mozilla-foundation/common_voice_8_0
32
+ args: hi
33
+ metrics:
34
+ - name: Test WER
35
+ type: wer
36
+ value: 0.5209
37
+ - name: Test CER
38
+ type: cer
39
+ value: 0.1790
40
+ datasets:
41
+ - mozilla-foundation/common_voice_15_0
42
+ language:
43
+ - hi
44
+ library_name: transformers
45
+ pipeline_tag: automatic-speech-recognition
46
+ ---
47
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
48
+ should probably proofread and complete it, then remove this comment. -->
49
+
50
+ # wav2vec2-large-xls-r-300m-hi
51
+
52
+ This model is a fine-tuned version of [facebook/wav2vec2-xls-r-300m](https://huggingface.co/facebook/wav2vec2-xls-r-300m) on the None dataset.
53
+ It achieves the following results on the evaluation set:
54
+ - Loss: 0.3611
55
+ - Wer: 0.2992
56
+ - Cer: 0.0786
57
+
58
+ View the results on Kaggle Notebook: https://www.kaggle.com/code/kingabzpro/wav2vec-2-eval
59
+
60
+ ## Evaluation
61
+
62
+ ```python
63
+ import torch
64
+ from datasets import load_dataset, load_metric
65
+ from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
66
+ import librosa
67
+ import unicodedata
68
+ import re
69
+
70
+
71
+ test_dataset = load_dataset("mozilla-foundation/common_voice_8_0", "hi", split="test")
72
+ wer = load_metric("wer")
73
+ cer = load_metric("cer")
74
+
75
+ processor = Wav2Vec2Processor.from_pretrained("kingabzpro/wav2vec2-large-xls-r-300m-hi")
76
+ model = Wav2Vec2ForCTC.from_pretrained("kingabzpro/wav2vec2-large-xls-r-300m-hi")
77
+ model.to("cuda")
78
+
79
+
80
+ # Preprocessing the datasets.
81
+ def speech_file_to_array_fn(batch):
82
+ chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\”\�\’\'\|\&\–]'
83
+ remove_en = '[A-Za-z]'
84
+ batch["sentence"] = re.sub(chars_to_ignore_regex, "", batch["sentence"].lower())
85
+ batch["sentence"] = re.sub(remove_en, "", batch["sentence"]).lower()
86
+ batch["sentence"] = unicodedata.normalize("NFKC", batch["sentence"])
87
+
88
+ speech_array, sampling_rate = librosa.load(batch["path"], sr=16_000)
89
+ batch["speech"] = speech_array
90
+ return batch
91
+
92
+ test_dataset = test_dataset.map(speech_file_to_array_fn)
93
+
94
+ # Preprocessing the datasets.
95
+ # We need to read the aduio files as arrays
96
+ def evaluate(batch):
97
+ inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
98
+
99
+ with torch.no_grad():
100
+ logits = model(inputs.input_values.to("cuda")).logits
101
+
102
+ pred_ids = torch.argmax(logits, dim=-1)
103
+ batch["pred_strings"] = processor.batch_decode(pred_ids, skip_special_tokens=True)
104
+ return batch
105
+
106
+ result = test_dataset.map(evaluate, batched=True, batch_size=8)
107
+
108
+ print("WER: {}".format(wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
109
+ print("CER: {}".format(cer.compute(predictions=result["pred_strings"], references=result["sentence"])))
110
+
111
+ ```
112
+ **WER: 0.5209850206372026**
113
+
114
+ **CER: 0.17902923538230883**
115
+
116
+ ### Training hyperparameters
117
+
118
+ The following hyperparameters were used during training:
119
+ - learning_rate: 0.0001
120
+ - train_batch_size: 32
121
+ - eval_batch_size: 8
122
+ - seed: 42
123
+ - gradient_accumulation_steps: 4
124
+ - total_train_batch_size: 128
125
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
126
+ - lr_scheduler_type: linear
127
+ - lr_scheduler_warmup_steps: 300
128
+ - num_epochs: 100
129
+
130
+ ### Training results
131
+
132
+ | Training Loss | Epoch | Step | Validation Loss | Wer | Cer |
133
+ |:-------------:|:-----:|:----:|:---------------:|:------:|:------:|
134
+ | 7.0431 | 19.05 | 300 | 3.4423 | 1.0 | 1.0 |
135
+ | 2.3233 | 38.1 | 600 | 0.5965 | 0.4757 | 0.1329 |
136
+ | 0.5676 | 57.14 | 900 | 0.3962 | 0.3584 | 0.0954 |
137
+ | 0.3611 | 76.19 | 1200 | 0.3651 | 0.3190 | 0.0820 |
138
+ | 0.2996 | 95.24 | 1500 | 0.3611 | 0.2992 | 0.0786 |
139
+
140
+
141
+ ### Framework versions
142
+
143
+ - Transformers 4.33.0
144
+ - Pytorch 2.0.0
145
+ - Datasets 2.1.0
146
+ - Tokenizers 0.13.3
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "</s>": 65,
3
+ "<s>": 64
4
+ }
config.json ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/wav2vec2-xls-r-300m",
3
+ "activation_dropout": 0.0,
4
+ "adapter_attn_dim": null,
5
+ "adapter_kernel_size": 3,
6
+ "adapter_stride": 2,
7
+ "add_adapter": false,
8
+ "apply_spec_augment": true,
9
+ "architectures": [
10
+ "Wav2Vec2ForCTC"
11
+ ],
12
+ "attention_dropout": 0.1,
13
+ "bos_token_id": 1,
14
+ "classifier_proj_size": 256,
15
+ "codevector_dim": 768,
16
+ "contrastive_logits_temperature": 0.1,
17
+ "conv_bias": true,
18
+ "conv_dim": [
19
+ 512,
20
+ 512,
21
+ 512,
22
+ 512,
23
+ 512,
24
+ 512,
25
+ 512
26
+ ],
27
+ "conv_kernel": [
28
+ 10,
29
+ 3,
30
+ 3,
31
+ 3,
32
+ 3,
33
+ 2,
34
+ 2
35
+ ],
36
+ "conv_stride": [
37
+ 5,
38
+ 2,
39
+ 2,
40
+ 2,
41
+ 2,
42
+ 2,
43
+ 2
44
+ ],
45
+ "ctc_loss_reduction": "mean",
46
+ "ctc_zero_infinity": false,
47
+ "diversity_loss_weight": 0.1,
48
+ "do_stable_layer_norm": true,
49
+ "eos_token_id": 2,
50
+ "feat_extract_activation": "gelu",
51
+ "feat_extract_dropout": 0.0,
52
+ "feat_extract_norm": "layer",
53
+ "feat_proj_dropout": 0.0,
54
+ "feat_quantizer_dropout": 0.0,
55
+ "final_dropout": 0.0,
56
+ "gradient_checkpointing": false,
57
+ "hidden_act": "gelu",
58
+ "hidden_dropout": 0.1,
59
+ "hidden_size": 1024,
60
+ "initializer_range": 0.02,
61
+ "intermediate_size": 4096,
62
+ "layer_norm_eps": 1e-05,
63
+ "layerdrop": 0.1,
64
+ "mask_feature_length": 10,
65
+ "mask_feature_min_masks": 0,
66
+ "mask_feature_prob": 0.0,
67
+ "mask_time_length": 10,
68
+ "mask_time_min_masks": 2,
69
+ "mask_time_prob": 0.05,
70
+ "model_type": "wav2vec2",
71
+ "num_adapter_layers": 3,
72
+ "num_attention_heads": 16,
73
+ "num_codevector_groups": 2,
74
+ "num_codevectors_per_group": 320,
75
+ "num_conv_pos_embedding_groups": 16,
76
+ "num_conv_pos_embeddings": 128,
77
+ "num_feat_extract_layers": 7,
78
+ "num_hidden_layers": 24,
79
+ "num_negatives": 100,
80
+ "output_hidden_size": 1024,
81
+ "pad_token_id": 63,
82
+ "proj_codevector_dim": 768,
83
+ "tdnn_dilation": [
84
+ 1,
85
+ 2,
86
+ 3,
87
+ 1,
88
+ 1
89
+ ],
90
+ "tdnn_dim": [
91
+ 512,
92
+ 512,
93
+ 512,
94
+ 512,
95
+ 1500
96
+ ],
97
+ "tdnn_kernel": [
98
+ 5,
99
+ 3,
100
+ 3,
101
+ 1,
102
+ 1
103
+ ],
104
+ "torch_dtype": "float32",
105
+ "transformers_version": "4.33.0",
106
+ "use_weighted_layer_sum": false,
107
+ "vocab_size": 66,
108
+ "xvector_output_dim": 512
109
+ }
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
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": true,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ },
10
+ {
11
+ "content": "</s>",
12
+ "lstrip": false,
13
+ "normalized": true,
14
+ "rstrip": false,
15
+ "single_word": false
16
+ }
17
+ ],
18
+ "bos_token": "<s>",
19
+ "eos_token": "</s>",
20
+ "pad_token": "[PAD]",
21
+ "unk_token": "[UNK]"
22
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "clean_up_tokenization_spaces": true,
4
+ "do_lower_case": false,
5
+ "eos_token": "</s>",
6
+ "model_max_length": 1000000000000000019884624838656,
7
+ "pad_token": "[PAD]",
8
+ "replace_word_delimiter_char": " ",
9
+ "target_lang": null,
10
+ "tokenizer_class": "Wav2Vec2CTCTokenizer",
11
+ "unk_token": "[UNK]",
12
+ "word_delimiter_token": "|"
13
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba2c75a2ae554e1c46e400b58d8b91391c6ab8c243e2e90fb6e343b8b07b2436
3
+ size 4027
vocab.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "[PAD]": 63,
3
+ "[UNK]": 62,
4
+ "|": 0,
5
+ "ँ": 1,
6
+ "ं": 2,
7
+ "ः": 3,
8
+ "अ": 4,
9
+ "आ": 5,
10
+ "इ": 6,
11
+ "ई": 7,
12
+ "उ": 8,
13
+ "ऊ": 9,
14
+ "ऋ": 10,
15
+ "ए": 11,
16
+ "ऐ": 12,
17
+ "ऑ": 13,
18
+ "ओ": 14,
19
+ "औ": 15,
20
+ "क": 16,
21
+ "ख": 17,
22
+ "ग": 18,
23
+ "घ": 19,
24
+ "च": 20,
25
+ "छ": 21,
26
+ "ज": 22,
27
+ "झ": 23,
28
+ "ञ": 24,
29
+ "ट": 25,
30
+ "ठ": 26,
31
+ "ड": 27,
32
+ "ढ": 28,
33
+ "ण": 29,
34
+ "त": 30,
35
+ "थ": 31,
36
+ "द": 32,
37
+ "ध": 33,
38
+ "न": 34,
39
+ "प": 35,
40
+ "फ": 36,
41
+ "ब": 37,
42
+ "भ": 38,
43
+ "म": 39,
44
+ "य": 40,
45
+ "र": 41,
46
+ "ल": 42,
47
+ "व": 43,
48
+ "श": 44,
49
+ "ष": 45,
50
+ "स": 46,
51
+ "ह": 47,
52
+ "़": 48,
53
+ "ा": 49,
54
+ "ि": 50,
55
+ "ी": 51,
56
+ "ु": 52,
57
+ "ू": 53,
58
+ "ृ": 54,
59
+ "े": 55,
60
+ "ै": 56,
61
+ "ॉ": 57,
62
+ "ो": 58,
63
+ "ौ": 59,
64
+ "्": 60,
65
+ "।": 61
66
+ }