File size: 3,945 Bytes
19dfbde
32ca414
f52a598
19dfbde
 
 
32ca414
9ffa6b7
19dfbde
32ca414
 
 
d774a97
19dfbde
32ca414
 
9ffa6b7
32ca414
 
 
 
d774a97
32ca414
 
9ffa6b7
 
 
d774a97
9ffa6b7
d774a97
19dfbde
 
 
 
 
32ca414
19dfbde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32ca414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
language:
- ha
license: apache-2.0
tags:
- generated_from_trainer
- robust-speech-event
- hf-asr-leaderboard
datasets:
- mozilla-foundation/common_voice_8_0
metrics:
- wer
base_model: facebook/wav2vec2-xls-r-300m
model-index:
- name: XLS-R-300M - Hausa
  results:
  - task:
      type: automatic-speech-recognition
      name: Speech Recognition
    dataset:
      name: Common Voice 8
      type: mozilla-foundation/common_voice_8_0
      args: ha
    metrics:
    - type: wer
      value: 36.295
      name: Test WER
    - type: cer
      value: 11.073
      name: Test CER
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# XLS-R-300M - Hausa

This model is a fine-tuned version of [facebook/wav2vec2-xls-r-300m](https://huggingface.co/facebook/wav2vec2-xls-r-300m) on the common_voice dataset.
It achieves the following results on the evaluation set:
- Loss: 0.6094
- Wer: 0.5234

## Model description

More information needed

## Intended uses & limitations

More information needed

## Training and evaluation data

More information needed

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.0001
- train_batch_size: 16
- eval_batch_size: 8
- seed: 13
- gradient_accumulation_steps: 2
- total_train_batch_size: 32
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: cosine_with_restarts
- lr_scheduler_warmup_steps: 1000
- num_epochs: 100

### Training results

| Training Loss | Epoch | Step | Validation Loss | Wer    |
|:-------------:|:-----:|:----:|:---------------:|:------:|
| 2.9599        | 6.56  | 400  | 2.8650          | 1.0    |
| 2.7357        | 13.11 | 800  | 2.7377          | 0.9951 |
| 1.3012        | 19.67 | 1200 | 0.6686          | 0.7111 |
| 1.0454        | 26.23 | 1600 | 0.5686          | 0.6137 |
| 0.9069        | 32.79 | 2000 | 0.5576          | 0.5815 |
| 0.82          | 39.34 | 2400 | 0.5502          | 0.5591 |
| 0.7413        | 45.9  | 2800 | 0.5970          | 0.5586 |
| 0.6872        | 52.46 | 3200 | 0.5817          | 0.5428 |
| 0.634         | 59.02 | 3600 | 0.5636          | 0.5314 |
| 0.6022        | 65.57 | 4000 | 0.5780          | 0.5229 |
| 0.5705        | 72.13 | 4400 | 0.6036          | 0.5323 |
| 0.5408        | 78.69 | 4800 | 0.6119          | 0.5336 |
| 0.5225        | 85.25 | 5200 | 0.6105          | 0.5270 |
| 0.5265        | 91.8  | 5600 | 0.6034          | 0.5231 |
| 0.5154        | 98.36 | 6000 | 0.6094          | 0.5234 |


### Framework versions

- Transformers 4.16.1
- Pytorch 1.10.0+cu111
- Datasets 1.18.2
- Tokenizers 0.11.0

#### Evaluation Commands
1. To evaluate on `mozilla-foundation/common_voice_8_0` with split `test`

```bash
python eval.py --model_id anuragshas/wav2vec2-large-xls-r-300m-ha-cv8 --dataset mozilla-foundation/common_voice_8_0 --config ha --split test
```


### Inference With LM

```python
import torch
from datasets import load_dataset
from transformers import AutoModelForCTC, AutoProcessor
import torchaudio.functional as F
model_id = "anuragshas/wav2vec2-large-xls-r-300m-ha-cv8"
sample_iter = iter(load_dataset("mozilla-foundation/common_voice_8_0", "ha", split="test", streaming=True, use_auth_token=True))
sample = next(sample_iter)
resampled_audio = F.resample(torch.tensor(sample["audio"]["array"]), 48_000, 16_000).numpy()
model = AutoModelForCTC.from_pretrained(model_id)
processor = AutoProcessor.from_pretrained(model_id)
input_values = processor(resampled_audio, return_tensors="pt").input_values
with torch.no_grad():
    logits = model(input_values).logits
transcription = processor.batch_decode(logits.numpy()).text
# => "kakin hade ya ke da kyautar"
```

### Eval results on Common Voice 8 "test" (WER):

| Without LM | With LM (run `./eval.py`) |
|---|---|
| 47.821 | 36.295 |