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

karna-base v2: full-pass fine-tune, 961 h LibriSpeech, 24k-step recovery

Browse files

Replaces the first-release weights (still in this repo's history) with v2. Card, figures and eval results updated.

README.md CHANGED
@@ -15,8 +15,8 @@ tags:
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
 
@@ -29,29 +29,30 @@ Test sets; greedy CTC decoding, no language model. CER for Khmer, WER for Englis
29
  | Model | Params | GMAC / s audio | DDD (km) | FLEURS-km | FLEURS-en | LibriSpeech test-clean | LibriSpeech test-other |
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
 
@@ -60,15 +61,15 @@ Test sets; greedy CTC decoding, no language model. CER for Khmer, WER for Englis
60
  The recipe follows *Fine-tune Before Structured Pruning* (arXiv 2505.24111), with the pruning method of
61
  DPHuBERT (arXiv 2305.17651) as used in DiariZen.
62
 
63
- 1. **Fine-tune.** Train `omniASR_CTC_300M` with CTC on the training mix. The result is the teacher, [omniASR-CTC-300M-km-en](https://huggingface.co/Darayut/omniASR-CTC-300M-km-en).
64
- 2. **Prune** (12k steps). Hard Concrete L0 gates sit on the attention heads and FFN units. An augmented-Lagrangian constraint ramps the target sparsity to 80%. The pruned model is distilled to the teacher with an L1 − cosine loss on hidden states at layers 6, 12, 18 and 24.
65
  3. **Cut.** Remove the pruned units for good.
66
  4. **Distil** (5k steps). Keep the mask frozen and continue the layer distillation.
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
 
15
 
16
  # karna-base
17
 
18
+ A **71M-parameter** Khmer + English CTC speech recogniser, made by structured pruning of
19
+ Meta's Omnilingual ASR `omniASR_CTC_300M` to **about 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
 
 
29
  | Model | Params | GMAC / s audio | DDD (km) | FLEURS-km | FLEURS-en | LibriSpeech test-clean | LibriSpeech test-other |
30
  |---|---|---|---|---|---|---|---|
31
  | `omniASR_CTC_300M` (stock) | 325M | 18.3 | 9.65 | 16.26 | – | 6.53 | 14.45 |
32
+ | Fine-tuned 300M (teacher) | 325M | 18.3 | 1.47 | 9.95 | 18.78 | 5.57 | 13.20 |
33
+ | **karna-base** | **71M** | **5.8** | **1.94** | **15.20** | **29.66** | **10.96** | **23.53** |
34
 
35
+ - **Khmer:** on DDD it is within 0.5 points of its unpruned fine-tuned teacher, and its error is a fifth of the stock model's.
36
+ - **English:** it keeps much less of its teacher's accuracy, with about 1.5–2× the teacher's WER, and is behind the stock model.
37
+ - **Version:** this is v2. The first release (73M; DDD 2.60, test-clean 11.15) is at revision [`5cadb20f7e`](https://huggingface.co/Netra-Lab/karna-base/tree/5cadb20f7e); v2 improves every test set.
38
  - **In-domain test sets:** FLEURS-km and FLEURS-en train are in the training mix, so their test sets are in-domain.
39
 
40
  <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>
41
 
42
+ *Inference time* for one 60 s utterance (batch 1, bf16, median of 20 runs), at 0% sparsity (the fine-tuned teacher) and about 80% (Karna).
43
 
44
  ## Architecture
45
 
46
  <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>
47
 
48
+ *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: 11 of 16 heads and 3,788 of 5,120 FFN units kept; which ones are kept is schematic.
49
 
50
  <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>
51
 
52
  *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.
53
 
54
  - **Base:** a wav2vec2-style CTC encoder with Omnilingual's 9,812-entry character vocabulary, which covers Khmer and Latin script.
55
+ - **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 61M parameters, 19% of the 300M's 315M.
56
  - **Unchanged parts:** the CNN feature extractor and the output layer.
57
  - **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.
58
 
 
61
  The recipe follows *Fine-tune Before Structured Pruning* (arXiv 2505.24111), with the pruning method of
62
  DPHuBERT (arXiv 2305.17651) as used in DiariZen.
63
 
64
+ 1. **Fine-tune** (62k steps, about one pass over the mix). Train `omniASR_CTC_300M` with CTC on the training mix. The result is the teacher. The first release's teacher, fine-tuned for 6k steps, is [omniASR-CTC-300M-km-en](https://huggingface.co/Darayut/omniASR-CTC-300M-km-en).
65
+ 2. **Prune** (12k steps). Hard Concrete L0 gates sit on the attention heads and FFN units. An augmented-Lagrangian constraint ramps the target sparsity to 80% over the first 6k steps. The pruned model is distilled to the teacher with an L1 − cosine loss on hidden states at layers 6, 12, 18 and 24.
66
  3. **Cut.** Remove the pruned units for good.
67
  4. **Distil** (5k steps). Keep the mask frozen and continue the layer distillation.
68
+ 5. **Recover** (24k steps). Train with CTC plus a frame-level KL divergence to the teacher's output distribution (temperature 1, weight 1).
69
 
70
  **Training mix**, 50/50 by language:
71
  - Khmer: [DDD](https://huggingface.co/datasets/Digital-Divide-Data/khmer-speech-dataset) train and FLEURS-km train.
72
+ - English: LibriSpeech train-clean-100 + 360 + other-500 (961 h) and FLEURS-en train.
73
  - FLEURS is fixed at 20% of each language's audio.
74
 
75
  ## Usage
assets/architecture.png CHANGED

Git LFS Details

  • SHA256: bea2d6e3deccc0826b9c7008550498070f38dddd6c888be9e7fa6155ca2cf061
  • Pointer size: 131 Bytes
  • Size of remote file: 580 kB

Git LFS Details

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

Git LFS Details

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

Git LFS Details

  • SHA256: fda9ff290db4f4c2a9dcff78d0a17debf7a72cb918c755c4385dce23f27e8847
  • Pointer size: 131 Bytes
  • Size of remote file: 197 kB
config.json CHANGED
@@ -37,56 +37,56 @@
37
  ]
38
  ],
39
  "num_heads": [
 
40
  2,
41
  5,
42
  4,
43
- 5,
44
- 3,
45
- 10,
46
- 8,
47
  4,
48
- 1,
49
- 3,
50
  9,
 
 
51
  5,
52
- 1,
53
  4,
54
  5,
 
55
  8,
56
- 5,
57
- 11,
58
- 2,
59
  3,
 
60
  0,
 
61
  0,
62
- 0,
63
- 0
64
  ],
65
  "ffn_dims": [
66
- 506,
67
- 326,
68
- 309,
69
- 362,
70
- 554,
71
- 1112,
72
- 114,
73
- 148,
74
- 266,
75
- 481,
76
- 991,
77
- 1713,
78
- 106,
79
- 132,
80
- 218,
81
- 300,
82
- 649,
83
- 2117,
84
- 64,
85
- 159,
86
- 132,
87
- 202,
88
- 270,
89
- 432
90
  ],
91
  "model_dim": 1024,
92
  "head_dim": 64,
 
37
  ]
38
  ],
39
  "num_heads": [
40
+ 3,
41
  2,
42
  5,
43
  4,
44
+ 6,
45
+ 9,
46
+ 7,
 
47
  4,
48
+ 2,
49
+ 2,
50
  9,
51
+ 3,
52
+ 0,
53
  5,
 
54
  4,
55
  5,
56
+ 6,
57
  8,
 
 
 
58
  3,
59
+ 2,
60
  0,
61
+ 1,
62
  0,
63
+ 1
 
64
  ],
65
  "ffn_dims": [
66
+ 590,
67
+ 389,
68
+ 406,
69
+ 405,
70
+ 636,
71
+ 1034,
72
+ 158,
73
+ 186,
74
+ 331,
75
+ 572,
76
+ 957,
77
+ 1649,
78
+ 126,
79
+ 156,
80
+ 258,
81
+ 335,
82
+ 634,
83
+ 1907,
84
+ 50,
85
+ 119,
86
+ 143,
87
+ 162,
88
+ 179,
89
+ 358
90
  ],
91
  "model_dim": 1024,
92
  "head_dim": 64,
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b7b12a6f9f1b33f633043c45c61678f3a4f1de377e5e3929f15208509f6063e1
3
- size 291804460
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee6d26527a9dd05786211e798224c47defa129c738b8b0f15e100b39c8661b99
3
+ size 285090968