From 37c615cf4b395992c3ba342f3d669cc1d4591134 Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Mon, 2 Nov 2026 03:26:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E7=94=B1ModelHub=20XC=E7=A4=BE=E5=8C=BA=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Model: Harveenchadha/vakyansh-wav2vec2-tamil-tam-250 Source: Original Platform --- .gitattributes | 17 +++++ README.md | 135 +++++++++++++++++++++++++++++++++++++++ config.json | 81 +++++++++++++++++++++++ preprocessor_config.json | 9 +++ pytorch_model.bin | 3 + special_tokens_map.json | 1 + tokenizer_config.json | 1 + vocab.json | 1 + 8 files changed, 248 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 config.json create mode 100644 preprocessor_config.json create mode 100644 pytorch_model.bin create mode 100644 special_tokens_map.json create mode 100644 tokenizer_config.json create mode 100644 vocab.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cefbc13 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +*.bin.* filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tar.gz filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1eba29 --- /dev/null +++ b/README.md @@ -0,0 +1,135 @@ +--- +language: ta +#datasets: +#- Interspeech 2021 +metrics: +- wer +tags: +- audio +- automatic-speech-recognition +- speech +license: mit +model-index: +- name: Wav2Vec2 Vakyansh Tamil Model by Harveen Chadha + results: + - task: + name: Speech Recognition + type: automatic-speech-recognition + dataset: + name: Common Voice ta + type: common_voice + args: ta + metrics: + - name: Test WER + type: wer + value: 53.64 +--- + +## Pretrained Model + +Fine-tuned on Multilingual Pretrained Model [CLSRIL-23](https://arxiv.org/abs/2107.07402). The original fairseq checkpoint is present [here](https://github.com/Open-Speech-EkStep/vakyansh-models). When using this model, make sure that your speech input is sampled at 16kHz. + +**Note: The result from this model is without a language model so you may witness a higher WER in some cases.** + +## Dataset + +This model was trained on 4200 hours of Hindi Labelled Data. The labelled data is not present in public domain as of now. + +## Training Script + +Models were trained using experimental platform setup by Vakyansh team at Ekstep. Here is the [training repository](https://github.com/Open-Speech-EkStep/vakyansh-wav2vec2-experimentation). + +In case you want to explore training logs on wandb they are [here](https://wandb.ai/harveenchadha/tamil-finetuning-multilingual). + + +## [Colab Demo](https://github.com/harveenchadha/bol/blob/main/demos/hf/tamil/hf_tamil_tnm_4200_demo.ipynb) + +## Usage + +The model can be used directly (without a language model) as follows: + +```python +import soundfile as sf +import torch +from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor +import argparse + +def parse_transcription(wav_file): + # load pretrained model + processor = Wav2Vec2Processor.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250") + model = Wav2Vec2ForCTC.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250") + + # load audio + audio_input, sample_rate = sf.read(wav_file) + + # pad input values and return pt tensor + input_values = processor(audio_input, sampling_rate=sample_rate, return_tensors="pt").input_values + + # INFERENCE + # retrieve logits & take argmax + logits = model(input_values).logits + predicted_ids = torch.argmax(logits, dim=-1) + + # transcribe + transcription = processor.decode(predicted_ids[0], skip_special_tokens=True) + print(transcription) + +``` + + +## Evaluation +The model can be evaluated as follows on the hindi test data of Common Voice. + +```python + +import torch +import torchaudio +from datasets import load_dataset, load_metric +from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor +import re + +test_dataset = load_dataset("common_voice", "ta", split="test") +wer = load_metric("wer") + +processor = Wav2Vec2Processor.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250") +model = Wav2Vec2ForCTC.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250") +model.to("cuda") + +resampler = torchaudio.transforms.Resample(48_000, 16_000) + +chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“]' + +# Preprocessing the datasets. +# We need to read the aduio files as arrays +def speech_file_to_array_fn(batch): + batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower() + speech_array, sampling_rate = torchaudio.load(batch["path"]) + batch["speech"] = resampler(speech_array).squeeze().numpy() + return batch + +test_dataset = test_dataset.map(speech_file_to_array_fn) + +# Preprocessing the datasets. +# We need to read the aduio files as arrays +def evaluate(batch): + inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True) + + with torch.no_grad(): + logits = model(inputs.input_values.to("cuda")).logits + + pred_ids = torch.argmax(logits, dim=-1) + batch["pred_strings"] = processor.batch_decode(pred_ids, skip_special_tokens=True) + return batch + +result = test_dataset.map(evaluate, batched=True, batch_size=8) + +print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"]))) + +``` + +**Test Result**: 53.64 % + +[**Colab Evaluation**](https://github.com/harveenchadha/bol/blob/main/demos/hf/tamil/hf_vakyansh_tamil_tnm_4200_evaluation_common_voice.ipynb) + +## Credits +Thanks to Ekstep Foundation for making this possible. The vakyansh team will be open sourcing speech models in all the Indic Languages. \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..84640d6 --- /dev/null +++ b/config.json @@ -0,0 +1,81 @@ +{ + "activation_dropout": 0.1, + "apply_spec_augment": true, + "architectures": [ + "Wav2Vec2ForCTC" + ], + "attention_dropout": 0.1, + "bos_token": "", + "bos_token_id": 0, + "codevector_dim": 256, + "contrastive_logits_temperature": 0.1, + "conv_bias": false, + "conv_dim": [ + 512, + 512, + 512, + 512, + 512, + 512, + 512 + ], + "conv_kernel": [ + 10, + 3, + 3, + 3, + 3, + 2, + 2 + ], + "conv_stride": [ + 5, + 2, + 2, + 2, + 2, + 2, + 2 + ], + "ctc_loss_reduction": "sum", + "ctc_zero_infinity": false, + "diversity_loss_weight": 0.1, + "do_lower_case": false, + "do_stable_layer_norm": false, + "eos_token": "", + "eos_token_id": 2, + "feat_extract_activation": "gelu", + "feat_extract_norm": "group", + "feat_proj_dropout": 0.1, + "feat_quantizer_dropout": 0.0, + "final_dropout": 0.1, + "gradient_checkpointing": false, + "hidden_act": "gelu", + "hidden_dropout": 0.1, + "hidden_size": 768, + "initializer_range": 0.02, + "intermediate_size": 3072, + "layer_norm_eps": 1e-05, + "layerdrop": 0.1, + "mask_feature_length": 10, + "mask_feature_prob": 0.0, + "mask_time_length": 10, + "mask_time_prob": 0.05, + "model_type": "wav2vec2", + "num_attention_heads": 12, + "num_codevector_groups": 2, + "num_codevectors_per_group": 320, + "num_conv_pos_embedding_groups": 16, + "num_conv_pos_embeddings": 128, + "num_feat_extract_layers": 7, + "num_hidden_layers": 12, + "num_negatives": 100, + "pad_token": "[PAD]", + "pad_token_id": 1, + "proj_codevector_dim": 256, + "torch_dtype": "float32", + "transformers_version": "4.9.1", + "unk_token": "[UNK]", + "vocab_size": 53, + "word_delimiter_token": "|" +} diff --git a/preprocessor_config.json b/preprocessor_config.json new file mode 100644 index 0000000..8df8da1 --- /dev/null +++ b/preprocessor_config.json @@ -0,0 +1,9 @@ +{ + "do_normalize": true, + "feature_extractor_type": "Wav2Vec2FeatureExtractor", + "feature_size": 1, + "padding_side": "right", + "padding_value": 0, + "return_attention_mask": false, + "sampling_rate": 16000 +} diff --git a/pytorch_model.bin b/pytorch_model.bin new file mode 100644 index 0000000..f3ac50b --- /dev/null +++ b/pytorch_model.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00adef7dc21c04f9014807f73c21c5fa12f9284aed6a5494a72bfc42ff3e55e7 +size 377731607 diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..25bc396 --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1 @@ +{"bos_token": "", "eos_token": "", "unk_token": "", "pad_token": ""} \ No newline at end of file diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..94d9657 --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1 @@ +{"unk_token": "", "bos_token": "", "eos_token": "", "pad_token": "", "do_lower_case": false, "word_delimiter_token": "|", "tokenizer_class": "Wav2Vec2CTCTokenizer"} \ No newline at end of file diff --git a/vocab.json b/vocab.json new file mode 100644 index 0000000..4fbee55 --- /dev/null +++ b/vocab.json @@ -0,0 +1 @@ +{"": 0, "": 1, "": 2, "": 3, "|": 4, "ஃ": 5, "அ": 6, "ஆ": 7, "இ": 8, "ஈ": 9, "உ": 10, "ஊ": 11, "எ": 12, "ஏ": 13, "ஐ": 14, "ஒ": 15, "ஓ": 16, "ஔ": 17, "க": 18, "ங": 19, "ச": 20, "ஜ": 21, "ஞ": 22, "ட": 23, "ண": 24, "த": 25, "ந": 26, "ன": 27, "ப": 28, "ம": 29, "ய": 30, "ர": 31, "ற": 32, "ல": 33, "ள": 34, "ழ": 35, "வ": 36, "ஶ": 37, "ஷ": 38, "ஸ": 39, "ஹ": 40, "ா": 41, "ி": 42, "ீ": 43, "ு": 44, "ூ": 45, "ெ": 46, "ே": 47, "ை": 48, "ொ": 49, "ோ": 50, "ௌ": 51, "்": 52} \ No newline at end of file