Automatic Speech Recognition
Transformers
Safetensors
Malagasy
wav2vec2-bert
speech
malagasy
madagascar
w2v-bert-2.0
ctc
low-resource
african-languages
Eval Results (legacy)
Run this model with HF Jobs
Run Flo976/w2v-bert-malagasy on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Flo976/w2v-bert-malagasy. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Flo976/w2v-bert-malagasy on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Flo976/w2v-bert-malagasy with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Flo976/w2v-bert-malagasy with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="Flo976/w2v-bert-malagasy")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForCTC processor = AutoProcessor.from_pretrained("Flo976/w2v-bert-malagasy") model = AutoModelForCTC.from_pretrained("Flo976/w2v-bert-malagasy", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Decodage sur log-probabilites, LM v2, ponctuation, version int8 : chiffres et code mis a jour
Browse files30 unmodified lines31323334353637389 unmodified lines48495051525354554 unmodified lines60616263646566676869707172737475763 unmodified lines808182838485868788899091924 unmodified lines9798991001011021031041051061071084 unmodified lines11311411511611711821 unmodified lines14014114214314414514614714814915015115215315415515615715815916016116216316416516616716824 unmodified lines19319419519619719819920020120220320420520620720830 unmodified linessplit: testmetrics:- type: wervalue: 13.40name: WER (KenLM 4-gram + apostrophe rule)- type: wervalue: 14.33name: WER (greedy)9 unmodified linessplit: testmetrics:- type: wervalue: 10.60name: WER (KenLM 4-gram)- type: wervalue: 12.01name: WER (greedy)4 unmodified lines<p align="center"><img src="assets/banner.png" alt="Malagasy speech recognition: a 5.2 s Malagasy phrase drawn as a waveform, each word placed under the moment it is spoken" width="100%"></p><p align="center"><a href="#results"><img src="https://img.shields.io/badge/WER%2C%202%20to%208%20s%20phrases-13.4%20%25-2F7D55?style=flat-square&labelColor=1E2A5E" alt="WER, 2 to 8 s phrases: 13.4 %"></a> <a href="#full-length-clips--no-regression"><img src="https://img.shields.io/badge/WER%2C%20full%20clips-10.6%20%25-2F7D55?style=flat-square&labelColor=1E2A5E" alt="WER, full clips: 10.6 %"></a> <a href="#speed"><img src="https://img.shields.io/badge/latency-52%20ms%20on%20GPU-E9C46A?style=flat-square&labelColor=1E2A5E" alt="latency: 52 ms on GPU"></a> <a href="https://huggingface.co/Flo976/w2v-bert-malagasy#license-and-attribution"><img src="https://img.shields.io/badge/license-CC--BY--4.0-8A93A6?style=flat-square&labelColor=1E2A5E" alt="license: CC-BY-4.0"></a> <a href="https://huggingface.co/spaces/Flo976/malagasy-asr-demo"><img src="https://img.shields.io/badge/demo-try%20it%20in%20the%20browser-E9C46A?style=flat-square&labelColor=1E2A5E" alt="demo: try it in the browser"></a> <a href="https://huggingface.co/Flo976/malagasy-kenlm-4gram"><img src="https://img.shields.io/badge/language%20model-KenLM%204--gram-8A93A6?style=flat-square&labelColor=1E2A5E" alt="language model: KenLM 4-gram"></a></p># w2v-BERT 2.0 — Malagasy speech recognition, robust on short utterances**13.4 % word error rate on short Malagasy utterances (2–8 s), against 21.5 % for a Whisper medium fine-tuned on the same data** — and 5× faster on GPU.This CTC model transcribes Malagasy speech. It is built for voice assistants and dictation, where speech arrives as short segments cut by voice-activity detection. Most Malagasy ASR models are trained and measured on 15–30 s recordings, and make about 65 % more errors on short segments; this one was trained on both.**Try it:** [Flo976/malagasy-asr-demo](https://huggingface.co/spaces/Flo976/malagasy-asr-demo) · **Language model:** [Flo976/malagasy-kenlm-4gram](https://huggingface.co/Flo976/malagasy-kenlm-4gram)**Résumé en français.** Modèle de reconnaissance vocale malgache (w2v-BERT 2.0, CTC), entraîné pour rester fiable sur les énoncés courts d'un assistant vocal. Sur 11 625 énoncés de 2 à 8 s jamais vus à l'entraînement, il fait 13,4 % d'erreurs de mots avec le modèle de langue, contre 21,5 % pour un Whisper medium fine-tuné sur les mêmes données, et répond 5 fois plus vite. Il ne régresse pas sur les extraits longs (10,6 %). Sortie en minuscules, sans ponctuation.## Results3 unmodified lines| Model | Decoding | WER | CER || --- | --- | --- | --- || **this model** | KenLM 4-gram + apostrophe rule | **13.40 %** | 3.74 % || **this model** | KenLM 4-gram | 13.63 % | 3.76 % || **this model** | greedy | 14.33 % | 3.76 % || [badrex/w2v-bert-2.0-malagasy-asr](https://huggingface.co/badrex/w2v-bert-2.0-malagasy-asr) | KenLM 4-gram | 17.77 % | 5.45 % || [badrex/w2v-bert-2.0-malagasy-asr](https://huggingface.co/badrex/w2v-bert-2.0-malagasy-asr) | greedy | 19.87 % | 5.79 % || [Flo976/whisper-malagasy-medium](https://huggingface.co/Flo976/whisper-malagasy-medium) | greedy | 21.49 % | 8.97 % |Each comparison quoted on this card is significant at 95 % (paired bootstrap on the same utterances, 2,000 resamples). Against the Whisper medium, this model gains 8.1 points (95 % CI [−8.64, −7.64]). At equal decoding this model beats its starting point badrex by 5.5 points greedy (95 % CI [−5.76, −5.34]) and by 4.1 points with the language model ([−4.34, −3.93]).<p align="center"><img src="assets/wer_by_length.png" alt="Word error rate by phrase length: under 3 s, 17.4 % for this model against 27.3 % for badrex and 32.4 % for Whisper medium; 3 to 5 s, 14.6 % against 20.1 % and 21.6 %; 5 to 8 s, 14.1 % against 19.4 % and 21.0 %" width="100%"></p>4 unmodified lines| Model | Decoding | WER | CER || --- | --- | --- | --- || **this model** | KenLM 4-gram | **10.60 %** | 2.65 % || badrex/w2v-bert-2.0-malagasy-asr | KenLM 4-gram | 10.86 % | 2.67 % || **this model** | greedy | 12.01 % | 2.85 % || badrex/w2v-bert-2.0-malagasy-asr | greedy | 12.20 % | 2.88 % || Flo976/whisper-malagasy-medium | greedy | 13.07 % | 3.48 % |### SpeedOne utterance at a time (2–8 s), as a voice assistant receives them:4 unmodified lines| this model, with KenLM | RTX 5070 Ti | 74 ms | 92 ms || Whisper medium (Flo976) | RTX 5070 Ti | 259 ms | 648 ms || this model, greedy | 2 CPU cores (Intel Core Ultra 7 265K) | 1.45 s | 1.53 s |A CTC model reads the audio in one pass; Whisper writes its output token by token, so its latency grows with the sentence. On CPU the acoustic model dominates: the language model adds no measurable time. Set PyTorch's thread count to the cores actually allotted (`torch.set_num_threads`): in a container, the default host count oversubscribes the CPU and triples latency.21 unmodified lines### With the Malagasy language model (recommended)```bashpip install pyctcdecode https://github.com/kpu/kenlm/archive/master.zip``````pythonimport refrom huggingface_hub import hf_hub_downloadfrom pyctcdecode import build_ctcdecodertok = processor.tokenizervocab = tok.get_vocab()labels = ["" if t == tok.pad_token else " " if t == tok.word_delimiter_token else "⁇" if t == tok.unk_token else tfor t in sorted(vocab, key=vocab.get)]lm_repo = "Flo976/malagasy-kenlm-4gram"unigrams = [w.strip() for w in open(hf_hub_download(lm_repo, "unigrams.txt"), encoding="utf-8") if w.strip()]decoder = build_ctcdecoder(labels, kenlm_model_path=hf_hub_download(lm_repo, "mg_4gram.bin"),unigrams=unigrams, alpha=0.3, beta=-1.0) # beta=0.0 for clips over 10 stext = decoder.decode(logits[0].numpy(), beam_width=100)text = re.sub(r"'\s+", "'", re.sub(r"\s+'", "'", text)) # "amin' ny" -> "amin'ny"print(text)```The parameters were tuned on the validation split: α = 0.3 with β = −1.0 for utterances of 10 s or less, β = 0.0 for longer clips. A spell-checking pass on top of the language model was measured and **hurts** (+0.17 point); it helps only without the language model (−0.38 point).Recordings longer than about 30 s are best split at pauses; see `app.py` in the demo for a simple approach.24 unmodified lines- **Short utterances are a proxy.** They are cut from read descriptions of images, not conversational speech captured by a microphone and a voice-activity detector. Results on real assistant traffic may differ.- **Segment boundaries come from badrex's alignment**, which may slightly favour models of the same family over Whisper on the short-utterance set.- **Under 3 s remains the weakest regime**: 15.9 % WER with the language model.- **Single training run**: run-to-run variance was not measured.- **Domain and dialect**: the training data is read speech, mostly official Malagasy (Merina). Coastal dialects and noisy environments are not evaluated.- **No punctuation or casing**, numbers as digits.## License and attributionThis model is released under **CC-BY-4.0**. It is a derivative of [badrex/w2v-bert-2.0-malagasy-asr](https://huggingface.co/badrex/w2v-bert-2.0-malagasy-asr) by Badr al-Absi (CC-BY-4.0), itself derived from [facebook/w2v-bert-2.0](https://huggingface.co/facebook/w2v-bert-2.0) (MIT). Please credit both when you reuse it.The training data, [badrex/malagasy-speech-full](https://huggingface.co/datasets/badrex/malagasy-speech-full), does not declare a license or a source on the Hub. The language model is published separately under CC-BY-SA-3.0, because it is built from Malagasy Wikipedia.## Citation30 unmodified lines31323334353637389 unmodified lines48495051525354554 unmodified lines60616263646566676869707172737475763 unmodified lines8081828384858687888990919293944 unmodified lines991001011021031041051061071081091101111121134 unmodified lines11811912012112212312412512621 unmodified lines14814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718824 unmodified lines21321421521621721821922022122222322422522622722822930 unmodified linessplit: testmetrics:- type: wervalue: 12.68name: WER (KenLM 4-gram v2 + apostrophe rule)- type: wervalue: 14.33name: WER (greedy)9 unmodified linessplit: testmetrics:- type: wervalue: 10.13name: WER (KenLM 4-gram v2 + apostrophe rule)- type: wervalue: 12.01name: WER (greedy)4 unmodified lines<p align="center"><img src="assets/banner.png" alt="Malagasy speech recognition: a 5.2 s Malagasy phrase drawn as a waveform, each word placed under the moment it is spoken" width="100%"></p><p align="center"><a href="#results"><img src="https://img.shields.io/badge/WER%2C%202%20to%208%20s%20phrases-12.7%20%25-2F7D55?style=flat-square&labelColor=1E2A5E" alt="WER, 2 to 8 s phrases: 12.7 %"></a> <a href="#full-length-clips--no-regression"><img src="https://img.shields.io/badge/WER%2C%20full%20clips-10.1%20%25-2F7D55?style=flat-square&labelColor=1E2A5E" alt="WER, full clips: 10.1 %"></a> <a href="#speed"><img src="https://img.shields.io/badge/latency-52%20ms%20on%20GPU-E9C46A?style=flat-square&labelColor=1E2A5E" alt="latency: 52 ms on GPU"></a> <a href="https://huggingface.co/Flo976/w2v-bert-malagasy#license-and-attribution"><img src="https://img.shields.io/badge/license-CC--BY--4.0-8A93A6?style=flat-square&labelColor=1E2A5E" alt="license: CC-BY-4.0"></a> <a href="https://huggingface.co/spaces/Flo976/malagasy-asr-demo"><img src="https://img.shields.io/badge/demo-try%20it%20in%20the%20browser-E9C46A?style=flat-square&labelColor=1E2A5E" alt="demo: try it in the browser"></a> <a href="https://huggingface.co/Flo976/malagasy-kenlm-4gram-v2"><img src="https://img.shields.io/badge/language%20model-KenLM%204--gram%20v2-8A93A6?style=flat-square&labelColor=1E2A5E" alt="language model: KenLM 4-gram v2"></a> <a href="https://huggingface.co/Flo976/malagasy-punctuation"><img src="https://img.shields.io/badge/punctuation-restoration%20model-8A93A6?style=flat-square&labelColor=1E2A5E" alt="punctuation: restoration model"></a> <a href="https://huggingface.co/Flo976/w2v-bert-malagasy-onnx-int8"><img src="https://img.shields.io/badge/CPU-int8%20ONNX-8A93A6?style=flat-square&labelColor=1E2A5E" alt="CPU: int8 ONNX"></a></p># w2v-BERT 2.0 — Malagasy speech recognition, robust on short utterances**12.7 % word error rate on short Malagasy utterances (2–8 s), against 21.5 % for a Whisper medium fine-tuned on the same data** — and 5× faster on GPU.This CTC model transcribes Malagasy speech. It is built for voice assistants and dictation, where speech arrives as short segments cut by voice-activity detection. Most Malagasy ASR models are trained and measured on 15–30 s recordings, and make about 65 % more errors on short segments; this one was trained on both.**Try it:** [Flo976/malagasy-asr-demo](https://huggingface.co/spaces/Flo976/malagasy-asr-demo) · **Language model:** [Flo976/malagasy-kenlm-4gram-v2](https://huggingface.co/Flo976/malagasy-kenlm-4gram-v2) · **Punctuation:** [Flo976/malagasy-punctuation](https://huggingface.co/Flo976/malagasy-punctuation) · **CPU version:** [Flo976/w2v-bert-malagasy-onnx-int8](https://huggingface.co/Flo976/w2v-bert-malagasy-onnx-int8)**Résumé en français.** Modèle de reconnaissance vocale malgache (w2v-BERT 2.0, CTC), entraîné pour rester fiable sur les énoncés courts d'un assistant vocal. Sur 11 625 énoncés de 2 à 8 s jamais vus à l'entraînement, il fait 12,7 % d'erreurs de mots avec le modèle de langue v2, contre 21,5 % pour un Whisper medium fine-tuné sur les mêmes données, et répond 5 fois plus vite. Il ne régresse pas sur les extraits longs (10,1 %). Sortie en minuscules, sans ponctuation : un modèle séparé remet majuscules et ponctuation.## Results3 unmodified lines| Model | Decoding | WER | CER || --- | --- | --- | --- || **this model** | KenLM 4-gram **v2** + apostrophe rule | **12.68 %** | 3.63 % || **this model** | KenLM 4-gram + apostrophe rule | 13.20 % | 3.71 % || **this model** | greedy | 14.33 % | 3.76 % || [badrex/w2v-bert-2.0-malagasy-asr](https://huggingface.co/badrex/w2v-bert-2.0-malagasy-asr) | KenLM 4-gram ¹ | 17.77 % | 5.45 % || [badrex/w2v-bert-2.0-malagasy-asr](https://huggingface.co/badrex/w2v-bert-2.0-malagasy-asr) | greedy | 19.87 % | 5.79 % || [Flo976/whisper-malagasy-medium](https://huggingface.co/Flo976/whisper-malagasy-medium) | greedy | 21.49 % | 8.97 % |¹ Measured with the first version of this card's decoding, which passed raw logits instead of log-probabilities to `pyctcdecode`. With that same decoding this model scored 13.63 % (13.40 % with the apostrophe rule), so badrex comparisons with a language model hold at equal decoding. Passing log-probabilities brings 0.2 point on short utterances (95 % CI [−0.23, −0.15]); the 134 M-word language model v2 brings a further 0.5 point ([−0.65, −0.40]).Each comparison quoted on this card is significant at 95 % (paired bootstrap on the same utterances, 2,000 resamples). Against the Whisper medium, this model gains 8.1 points (95 % CI [−8.64, −7.64]). At equal decoding this model beats its starting point badrex by 5.5 points greedy (95 % CI [−5.76, −5.34]) and by 4.1 points with the language model ([−4.34, −3.93]).<p align="center"><img src="assets/wer_by_length.png" alt="Word error rate by phrase length: under 3 s, 17.4 % for this model against 27.3 % for badrex and 32.4 % for Whisper medium; 3 to 5 s, 14.6 % against 20.1 % and 21.6 %; 5 to 8 s, 14.1 % against 19.4 % and 21.0 %" width="100%"></p>4 unmodified lines| Model | Decoding | WER | CER || --- | --- | --- | --- || **this model** | KenLM 4-gram **v2** + apostrophe rule | **10.13 %** | 2.59 % || **this model** | KenLM 4-gram + apostrophe rule | 10.41 % | 2.63 % || badrex/w2v-bert-2.0-malagasy-asr | KenLM 4-gram ² | 10.86 % | 2.67 % || **this model** | greedy | 12.01 % | 2.85 % || badrex/w2v-bert-2.0-malagasy-asr | greedy | 12.20 % | 2.88 % || Flo976/whisper-malagasy-medium | greedy | 13.07 % | 3.48 % |² Raw logits, no apostrophe rule. With that same decoding this model scored 10.60 %, the figure first published on this card.### SpeedOne utterance at a time (2–8 s), as a voice assistant receives them:4 unmodified lines| this model, with KenLM | RTX 5070 Ti | 74 ms | 92 ms || Whisper medium (Flo976) | RTX 5070 Ti | 259 ms | 648 ms || this model, greedy | 2 CPU cores (Intel Core Ultra 7 265K) | 1.45 s | 1.53 s || [int8 ONNX version](https://huggingface.co/Flo976/w2v-bert-malagasy-onnx-int8), greedy | 2 CPU cores (Intel Core Ultra 7 265K) | 0.63 s ³ | |³ Measured on 100 utterances of 4.8 s on average, against 1.70 s for this model in the same run. No significant accuracy loss on 1,500 short utterances; see its card.A CTC model reads the audio in one pass; Whisper writes its output token by token, so its latency grows with the sentence. On CPU the acoustic model dominates: the language model adds no measurable time. Set PyTorch's thread count to the cores actually allotted (`torch.set_num_threads`): in a container, the default host count oversubscribes the CPU and triples latency.21 unmodified lines### With the Malagasy language model (recommended)```bashpip install --no-deps pyctcdecode==0.5.0pip install pygtrie https://github.com/kpu/kenlm/archive/master.zip``````pythonimport json, reimport numpy as npfrom huggingface_hub import snapshot_downloadfrom pyctcdecode import build_ctcdecoderlm = snapshot_download("Flo976/malagasy-kenlm-4gram-v2")params = json.load(open(f"{lm}/params.json"))unigrams = [w.strip() for w in open(f"{lm}/unigrams.txt", encoding="utf-8") if w.strip()]tok = processor.tokenizervocab = tok.get_vocab()labels = ["" if t == tok.pad_token else " " if t == tok.word_delimiter_token else "⁇" if t == tok.unk_token else tfor t in sorted(vocab, key=vocab.get)]p = params["short" if len(audio) / 16000 <= 10 else "long"] # α 0.6 β 0.5 up to 10 s, α 0.5 β 0.5 abovedecoder = build_ctcdecoder(labels, kenlm_model_path=f"{lm}/{params['lm']}", unigrams=unigrams,alpha=p["alpha"], beta=p["beta"]) # build once, reuselogp = torch.log_softmax(logits[0].float(), -1).numpy() # log-probabilities, not raw logitstext = decoder.decode(logp, beam_width=100)text = re.sub(r"'\s+", "'", re.sub(r"\s+'", "'", text)) # "amin' ny" -> "amin'ny"print(text)```The parameters were tuned on the validation split only. Pass **log-probabilities** to `pyctcdecode`: the first version of this card passed raw logits, which costs 0.2 point. The language model v2 contains web text; for a model under a clean CC-BY-SA licence, use [Flo976/malagasy-kenlm-4gram](https://huggingface.co/Flo976/malagasy-kenlm-4gram) with α = 0.3, β = −1.0 up to 10 s and β = 0.0 above (13.20 % and 10.41 %).A spell-checking pass on top of the language model was measured and **hurts** (+0.17 point); it helps only without the language model (−0.38 point).### Casing, punctuation and confidence- [Flo976/malagasy-punctuation](https://huggingface.co/Flo976/malagasy-punctuation) restores capital letters and punctuation without changing any word.- The [demo](https://huggingface.co/spaces/Flo976/malagasy-asr-demo) also shows a **calibrated confidence for each word** (`asr_extras.py` in its files): a word at 80 % is right about 8 times out of 10. Asking the user to repeat the 10 % least confident utterances lowers the WER of the others from 12.7 % to 11.4 % on the short test set.Recordings longer than about 30 s are best split at pauses; see `app.py` in the demo for a simple approach.24 unmodified lines- **Short utterances are a proxy.** They are cut from read descriptions of images, not conversational speech captured by a microphone and a voice-activity detector. Results on real assistant traffic may differ.- **Segment boundaries come from badrex's alignment**, which may slightly favour models of the same family over Whisper on the short-utterance set.- **Under 3 s remains the weakest regime**: 15.9 % WER with the first language model; on 0.5–2 s segments, 24.4 % greedy.- **Noise**: with added noise at 10 dB SNR, greedy WER on short utterances rises from 14.3 % to 18.7 %, and to 30.9 % at 0 dB.- **Single training run**: run-to-run variance was not measured.- **Domain and dialect**: the training data is read speech, mostly official Malagasy (Merina). Coastal dialects and noisy environments are not evaluated.- **No punctuation or casing** in the model output (see [Flo976/malagasy-punctuation](https://huggingface.co/Flo976/malagasy-punctuation)), numbers as digits.## License and attributionThis model is released under **CC-BY-4.0**. It is a derivative of [badrex/w2v-bert-2.0-malagasy-asr](https://huggingface.co/badrex/w2v-bert-2.0-malagasy-asr) by Badr al-Absi (CC-BY-4.0), itself derived from [facebook/w2v-bert-2.0](https://huggingface.co/facebook/w2v-bert-2.0) (MIT). Please credit both when you reuse it.The training data, [badrex/malagasy-speech-full](https://huggingface.co/datasets/badrex/malagasy-speech-full), does not declare a license or a source on the Hub. The language models are published separately: [malagasy-kenlm-4gram](https://huggingface.co/Flo976/malagasy-kenlm-4gram) under CC-BY-SA-3.0 (Malagasy Wikipedia), and [malagasy-kenlm-4gram-v2](https://huggingface.co/Flo976/malagasy-kenlm-4gram-v2) with mixed sources including web text.## Citation
README.md+46-25