karna-base v2: full-pass fine-tune, 961 h LibriSpeech, 24k-step recovery
Browse filesReplaces the first-release weights (still in this repo's history) with v2. Card, figures and eval results updated.
- README.md +14 -13
- assets/architecture.png +2 -2
- assets/inference_time.png +0 -0
- assets/pruning.png +2 -2
- config.json +36 -36
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -15,8 +15,8 @@ tags:
|
|
| 15 |
|
| 16 |
# karna-base
|
| 17 |
|
| 18 |
-
A **
|
| 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 |
-
|
|
| 33 |
-
| **karna-base** | **
|
| 34 |
|
| 35 |
-
- **Khmer:** on DDD it is
|
| 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:
|
| 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
|
| 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
|
| 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** (
|
| 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
|
|
Git LFS Details
|
assets/inference_time.png
CHANGED
|
|
assets/pruning.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
config.json
CHANGED
|
@@ -37,56 +37,56 @@
|
|
| 37 |
]
|
| 38 |
],
|
| 39 |
"num_heads": [
|
|
|
|
| 40 |
2,
|
| 41 |
5,
|
| 42 |
4,
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
8,
|
| 47 |
4,
|
| 48 |
-
|
| 49 |
-
|
| 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 |
-
|
| 63 |
-
0
|
| 64 |
],
|
| 65 |
"ffn_dims": [
|
| 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 |
"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:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ee6d26527a9dd05786211e798224c47defa129c738b8b0f15e100b39c8661b99
|
| 3 |
+
size 285090968
|