Darayut commited on
Commit
5cadb20
·
verified ·
1 Parent(s): ac9e7d9

Rename Sota to Karna: card, figures and links

Browse files
README.md CHANGED
@@ -13,14 +13,14 @@ tags:
13
  - khmer
14
  ---
15
 
16
- # sota-base
17
 
18
  A **73M-parameter** Khmer + English CTC speech recogniser, made by structured pruning of
19
  Meta's Omnilingual ASR `omniASR_CTC_300M` to **80% encoder sparsity**. It is the Base size of a pair,
20
  named after DiariZen's Base-s80 / Large-s80 pruned WavLM models. The other size is
21
- [Darayut/sota-large](https://huggingface.co/Darayut/sota-large).
22
 
23
- **Code:** [github.com/netra-ai-lab/Sota](https://github.com/netra-ai-lab/Sota), with the `sota` inference package and the full training recipe.
24
 
25
  ## Results
26
 
@@ -30,30 +30,30 @@ Test sets; greedy CTC decoding, no language model. CER for Khmer, WER for Englis
30
  |---|---|---|---|---|---|---|---|
31
  | `omniASR_CTC_300M` (stock) | 325M | 18.3 | 9.65 | 16.26 | – | 6.53 | 14.45 |
32
  | [omniASR-CTC-300M-km-en](https://huggingface.co/Darayut/omniASR-CTC-300M-km-en) (fine-tuned teacher) | 325M | 18.3 | 3.68 | 12.64 | 19.51 | 5.89 | 13.86 |
33
- | **sota-base** | **73M** | **5.8** | **2.60** | **16.39** | **30.24** | **11.15** | **27.36** |
34
 
35
  - **Khmer:** on DDD it is more accurate than both its unpruned fine-tuned teacher and the stock model.
36
  - **English:** it keeps much less of its teacher's accuracy, with about 1.5–2× the teacher's WER.
37
  - **In-domain test sets:** FLEURS-km and FLEURS-en train are in the training mix, so their test sets are in-domain.
38
 
39
- <p align="center"><img src="https://huggingface.co/Darayut/sota-base/resolve/main/assets/inference_time.png" width="60%" alt="Inference time for 60 s of audio at 0% and 80% encoder sparsity, for the base and large models"></p>
40
 
41
- *Inference time* for one 60 s utterance (batch 1, bf16, median of 20 runs), at 0% sparsity (the fine-tuned teacher) and 80% (SOTA).
42
 
43
  ## Architecture
44
 
45
- <p align="center"><img src="https://huggingface.co/Darayut/sota-base/resolve/main/assets/architecture.png" width="70%" alt="Sota's architecture, reading upwards from 16 kHz audio to the CTC head, with one transformer layer opened up"></p>
46
 
47
- *The model*, reading upwards, with one transformer layer opened up: 16 kHz audio, a feature extractor of 7 convolutional layers giving one frame every 20 ms, a convolutional position encoder added back to the frames, 48 pre-LayerNorm transformer layers of width 1,280, a final LayerNorm and a CTC head over 9,812 characters. Every attention head and every FFN unit has its own Hard Concrete gate z. The cells in the opened layer are layer 12 of sota-large: 8 of 16 heads and 3,355 of 5,120 FFN units kept; which ones are kept is schematic.
48
 
49
- <p align="center"><img src="https://huggingface.co/Darayut/sota-base/resolve/main/assets/pruning.png" width="100%" alt="The fine-tuned omniASR CTC-1B before structured pruning and sota-large after: CNN and CTC head kept, attention heads and FFN units removed"></p>
50
 
51
- *What is pruned*, shown for sota-large: whole attention heads (MHA) and FFN units are removed from every transformer layer, and the CNN front end is kept. Each cell is a quarter of a layer's heads or units.
52
 
53
  - **Base:** a wav2vec2-style CTC encoder with Omnilingual's 9,812-entry character vocabulary, which covers Khmer and Latin script.
54
  - **Pruned parts:** per-layer attention heads and FFN units, so every layer has its own width. `config.json` lists the exact `num_heads` and `ffn_dims`; the encoder has 63M parameters.
55
  - **Unchanged parts:** the CNN feature extractor and the output layer.
56
- - **Loading:** the layer widths are non-uniform, so fairseq2 / `omnilingual-asr` cannot load it. Use the `sota` package (see Usage) or the code bundled in this repo.
57
 
58
  ## How it was made
59
 
@@ -67,34 +67,34 @@ DPHuBERT (arXiv 2305.17651) as used in DiariZen.
67
  5. **Recover** (16k steps). Train with CTC plus a frame-level KL divergence to the teacher's output distribution (temperature 1, weight 1).
68
 
69
  **Training mix**, 50/50 by language:
70
- - Khmer: DDD train and FLEURS-km train.
71
  - English: LibriSpeech train-clean-100 + 360 and FLEURS-en train.
72
  - FLEURS is fixed at 20% of each language's audio.
73
 
74
  ## Usage
75
 
76
  ```bash
77
- pip install git+https://github.com/netra-ai-lab/SOTA
78
  ```
79
 
80
  ```python
81
- import sota
82
 
83
- asr = sota.load_model("sota-base") # downloads this repo's weights once
84
  print(asr.transcribe("audio.wav"))
85
  print(asr.transcribe(["a.wav", "b.flac"]))
86
  ```
87
 
88
  ```bash
89
- sota transcribe audio.wav --model sota-base
90
  ```
91
 
92
  Without installing the package, the code bundled in this repo also works:
93
 
94
  ```bash
95
- huggingface-cli download Darayut/sota-base --local-dir sota-base
96
  pip install torch torchaudio soundfile safetensors
97
- python sota-base/inference.py audio.wav
98
  ```
99
 
100
  Audio of any sample rate is accepted; it is mixed to mono and resampled to 16 kHz. Output text is in the
 
13
  - khmer
14
  ---
15
 
16
+ # karna-base
17
 
18
  A **73M-parameter** Khmer + English CTC speech recogniser, made by structured pruning of
19
  Meta's Omnilingual ASR `omniASR_CTC_300M` to **80% encoder sparsity**. It is the Base size of a pair,
20
  named after DiariZen's Base-s80 / Large-s80 pruned WavLM models. The other size is
21
+ [Netra-Lab/karna-large](https://huggingface.co/Netra-Lab/karna-large).
22
 
23
+ **Code:** [github.com/netra-ai-lab/Karna](https://github.com/netra-ai-lab/Karna), with the `karna` inference package and the full training recipe.
24
 
25
  ## Results
26
 
 
30
  |---|---|---|---|---|---|---|---|
31
  | `omniASR_CTC_300M` (stock) | 325M | 18.3 | 9.65 | 16.26 | – | 6.53 | 14.45 |
32
  | [omniASR-CTC-300M-km-en](https://huggingface.co/Darayut/omniASR-CTC-300M-km-en) (fine-tuned teacher) | 325M | 18.3 | 3.68 | 12.64 | 19.51 | 5.89 | 13.86 |
33
+ | **karna-base** | **73M** | **5.8** | **2.60** | **16.39** | **30.24** | **11.15** | **27.36** |
34
 
35
  - **Khmer:** on DDD it is more accurate than both its unpruned fine-tuned teacher and the stock model.
36
  - **English:** it keeps much less of its teacher's accuracy, with about 1.5–2× the teacher's WER.
37
  - **In-domain test sets:** FLEURS-km and FLEURS-en train are in the training mix, so their test sets are in-domain.
38
 
39
+ <p align="center"><img src="https://huggingface.co/Netra-Lab/karna-base/resolve/main/assets/inference_time.png" width="60%" alt="Inference time for 60 s of audio at 0% and 80% encoder sparsity, for the base and large models"></p>
40
 
41
+ *Inference time* for one 60 s utterance (batch 1, bf16, median of 20 runs), at 0% sparsity (the fine-tuned teacher) and 80% (Karna).
42
 
43
  ## Architecture
44
 
45
+ <p align="center"><img src="https://huggingface.co/Netra-Lab/karna-base/resolve/main/assets/architecture.png" width="45%" alt="Karna's architecture, reading upwards from 16 kHz audio to the CTC head, with one transformer layer opened up"></p>
46
 
47
+ *The model*, reading upwards, with one transformer layer opened up: 16 kHz audio, a feature extractor of 7 convolutional layers giving one frame every 20 ms, a convolutional position encoder added back to the frames, 48 pre-LayerNorm transformer layers of width 1,280, a final LayerNorm and a CTC head over 9,812 characters. Every attention head and every FFN unit has its own Hard Concrete gate z. The cells in the opened layer are layer 12 of karna-large: 8 of 16 heads and 3,355 of 5,120 FFN units kept; which ones are kept is schematic.
48
 
49
+ <p align="center"><img src="https://huggingface.co/Netra-Lab/karna-base/resolve/main/assets/pruning.png" width="100%" alt="The fine-tuned omniASR CTC-1B before structured pruning and karna-large after: CNN and CTC head kept, attention heads and FFN units removed"></p>
50
 
51
+ *What is pruned*, shown for karna-large: whole attention heads (MHA) and FFN units are removed from every transformer layer, and the CNN front end is kept. Each cell is a quarter of a layer's heads or units.
52
 
53
  - **Base:** a wav2vec2-style CTC encoder with Omnilingual's 9,812-entry character vocabulary, which covers Khmer and Latin script.
54
  - **Pruned parts:** per-layer attention heads and FFN units, so every layer has its own width. `config.json` lists the exact `num_heads` and `ffn_dims`; the encoder has 63M parameters.
55
  - **Unchanged parts:** the CNN feature extractor and the output layer.
56
+ - **Loading:** the layer widths are non-uniform, so fairseq2 / `omnilingual-asr` cannot load it. Use the `karna` package (see Usage) or the code bundled in this repo.
57
 
58
  ## How it was made
59
 
 
67
  5. **Recover** (16k steps). Train with CTC plus a frame-level KL divergence to the teacher's output distribution (temperature 1, weight 1).
68
 
69
  **Training mix**, 50/50 by language:
70
+ - Khmer: [DDD](https://huggingface.co/datasets/Digital-Divide-Data/khmer-speech-dataset) train and FLEURS-km train.
71
  - English: LibriSpeech train-clean-100 + 360 and FLEURS-en train.
72
  - FLEURS is fixed at 20% of each language's audio.
73
 
74
  ## Usage
75
 
76
  ```bash
77
+ pip install git+https://github.com/netra-ai-lab/Karna
78
  ```
79
 
80
  ```python
81
+ import karna
82
 
83
+ asr = karna.load_model("karna-base") # downloads this repo's weights once
84
  print(asr.transcribe("audio.wav"))
85
  print(asr.transcribe(["a.wav", "b.flac"]))
86
  ```
87
 
88
  ```bash
89
+ karna transcribe audio.wav --model karna-base
90
  ```
91
 
92
  Without installing the package, the code bundled in this repo also works:
93
 
94
  ```bash
95
+ huggingface-cli download Netra-Lab/karna-base --local-dir karna-base
96
  pip install torch torchaudio soundfile safetensors
97
+ python karna-base/inference.py audio.wav
98
  ```
99
 
100
  Audio of any sample rate is accepted; it is mixed to mono and resampled to 16 kHz. Output text is in the
assets/architecture.png CHANGED

Git LFS Details

  • SHA256: ce2104d870326f05bd31dda3fda263fe509b165d01d183121d7306d785117f94
  • Pointer size: 131 Bytes
  • Size of remote file: 228 kB

Git LFS Details

  • SHA256: bea2d6e3deccc0826b9c7008550498070f38dddd6c888be9e7fa6155ca2cf061
  • Pointer size: 131 Bytes
  • Size of remote file: 580 kB
assets/inference_time.png CHANGED
assets/pruning.png CHANGED

Git LFS Details

  • SHA256: ec7f903754cdc10d127172f0781f1b9bba3ff67de914c621b59dd2d112a328ca
  • Pointer size: 130 Bytes
  • Size of remote file: 98 kB

Git LFS Details

  • SHA256: 152b5c68b482d0b993dd0e81152330b3a406203c408b7c334aa136c1e2290b6e
  • Pointer size: 131 Bytes
  • Size of remote file: 200 kB