Skip to main content
Netra Lab Netra

GitHub | Docker Image | PyPI | Karna-base | Karna-large | Fine-tuned 1B | Fine-tuned 300M | Khmer Dataset

License: Apache-2.0 Python 3.10+ 71M and 217M parameters PyPI: netra-karna Docker image Runs on CPU, offline

Karna: Structured Pruning of Omnilingual ASR for Khmer and English

Khmer and English speech in, text out. Two compact models, 71M and 217M parameters, pruned from Meta's Omnilingual ASR.

Test error of the stock, fine-tuned and pruned models at both sizes on DDD, FLEURS-km and LibriSpeech

Test error for each size: the stock Omnilingual model, our fine-tuned teacher and the pruned Karna model. Lower is better. On DDD, the pruned models beat both larger models; on LibriSpeech they keep 1.7–1.9× the teacher's error.

1. Abstract

This repository presents Karna, a pair of 71M- and 217M-parameter CTC speech recognisers for Khmer and English. They are built by structurally pruning Meta's Omnilingual ASR CTC models (omniASR_CTC_300M and omniASR_CTC_1B) to about 80% encoder sparsity. The recipe follows Fine-tune Before Structured Pruning:

  1. The full model is fine-tuned on the target languages.
  2. Hard Concrete L0 gates remove attention heads and FFN units while the model is distilled to that fine-tuned teacher.
  3. The pruned model recovers with CTC plus distillation of the teacher's output distribution.

On the DDD test set, the 217M model reaches 1.33% CER, against 1.22% for its 975M teacher and 5.95% for the stock 1B, at a quarter of the compute (12.9 against 50.3 GMAC per second of audio). The 71M model reaches 1.94% CER, against its 325M teacher's 1.47%, at 5.8 GMAC/s. These are the v2 models; the first release and what changed are in docs/RESULTS.md.

2. Dataset

Karna was trained on about 2,034 hours of speech, mixed 50/50 between Khmer and English by audio seconds. FLEURS is fixed at 20% of each language's audio and repeated as needed.

Sources

Dataset Type Size Domains
DDD Khmer Speech Khmer speech 1,058 h Cambodian culture, 61 topics, native speakers
FLEURS km_kh train Khmer read speech 7.1 h Wikipedia sentences
LibriSpeech train-clean-100 + 360 + other-500 English read speech 961 h Audiobooks
FLEURS en_us train English read speech 7.5 h Wikipedia sentences
Total 2,034 h

Preprocessing

  1. Held-out sets. The DDD test set, a DDD dev pool and an exclude list are removed from DDD training at the shard-row level.
  2. Duration filter. Utterances shorter than 1 s or longer than 25 s are dropped.
  3. Resampling. Audio is resampled to 16 kHz mono, which affects some 48 kHz DDD rows.
  4. Text normalisation.
    • NFC, with zero-width characters removed and whitespace collapsed; English is lowercased.
    • Text is filtered to the Omnilingual character vocabulary, which has no Khmer punctuation such as ។. This drops 1.2% of DDD characters.
  5. Loudness normalisation. Each utterance is normalised to zero mean and unit variance, as in Omnilingual ASR.

3. Model Architecture

Karna's architecture, reading upwards from 16 kHz audio to the CTC head, with one transformer layer opened up

Figure 1: 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.

The base model. A wav2vec2-style encoder:

  • a 7-layer CNN feature extractor (20 ms frames);
  • a convolutional position encoder;
  • pre-LayerNorm transformer layers;
  • a linear CTC head over Omnilingual's 9,812-character vocabulary.

What pruning removes. Each encoder layer keeps only the attention heads and FFN units that the L0 gates leave open, so every layer has its own width. The model dimension, the CNN front end and the CTC head stay intact.

The fine-tuned omniASR CTC-1B before structured pruning and karna-large after: CNN and CTC head kept, attention heads and FFN units removed

Figure 2: Structured pruning removes whole attention heads (MHA) and FFN units from every transformer layer, chosen by one Hard Concrete gate each; the CNN front end is kept. Each cell is a quarter of a layer's heads or FFN units: layer 12 of karna-large keeps 11 of 16 heads and 3,788 of 5,120 FFN units, and layer 40 keeps no heads and 264 FFN units. Training runs in five steps: fine-tune, prune, cut, distil with the mask frozen, and recover with CTC and logit distillation ([docs/DESIGN.md](docs/DESIGN.md)).

Inference time for 60 s of audio at 0% and 80% encoder sparsity, for the base and large models

Figure 3: Inference time before and after pruning, for one 60 s utterance (batch 1, bf16, median of 20 runs on one machine; `training/scripts/07_time_inference.py`). At about 80% encoder sparsity karna-base runs 1.6× faster than its teacher and karna-large 2.2× faster. Over the batched test sets (the Speed column below) the speed-ups are 1.8× and 2.4×.

Feature Detail
Pruned units Attention heads and FFN intermediate units (Hard Concrete L0 gates)
Sparsity control Augmented Lagrangian; target ramps 0 → 80% over the first 50% of Stage 2
Distillation L1 − cosine on hidden states at 5 layers (Stages 2 and 2b); frame-level KL on outputs (Stage 3)
Decoding Greedy CTC, no language model
Hyperparameter karna-base karna-large
Pruned from omniASR CTC-300M omniASR CTC-1B
Encoder layers × model dim 24 × 1024 48 × 1280
Heads kept (of 384 / 768) 91 198
FFN units kept (of 98,304 / 245,760) 11,740 41,045
Encoder sparsity 80.6% 78.7%
Stage 1 / 2 / 2b / 3 steps 62k / 12k / 5k / 24k 62k / 12k / 5k / 24k
Compute (GMAC / s of audio) 5.8 12.9
Total parameters 71M 217M

4. Evaluation

Model Params Speed DDD (CER) FLEURS-km (CER) LibriSpeech (WER)
omniASR CTC-1B (stock) 975M 1.0× 5.95 11.26 4.40
Fine-tuned 1B (teacher) 975M 1.0× 1.22 7.77 3.54
karna-large (ours) 217M 2.4× 1.33 10.20 5.44
omniASR CTC-300M (stock) 325M 1.0× 9.65 16.26 6.53
Fine-tuned 300M (teacher) 325M 1.0× 1.47 9.95 5.57
karna-base (ours) 71M 1.8× 1.94 15.20 10.96
  • Scoring. Greedy decoding, error rates in %, on the full test sets:

    Test set Utterances
    DDD 1,993
    FLEURS-km 771
    LibriSpeech test-clean 2,620
  • Speed. Inference speed relative to the unpruned model of the same size, measured as the real-time factor on one machine.

  • In-domain. FLEURS-km train is in the training mix, so its test set is in-domain.

  • Teachers. The teachers here are the v2 fine-tuned models (a full pass over the training mix). The teachers on Hugging Face are still the first release's, which score 2.47 (1B) and 3.68 (300M) on DDD.

  • More results. docs/RESULTS.md adds FLEURS-en and LibriSpeech test-other, the first release against v2, and the ablations behind the recipe: pruning without fine-tuning first, and Stage 3 without distillation or with a shorter schedule.

5. Quick start

The quickest way in is the Docker image: a web app and REST API with both models inside.

  1. Install Docker Desktop for Windows, Mac or Linux. In its settings, give it at least 4 GB of memory.

  2. Open a terminal (PowerShell on Windows, Terminal on Mac) and run:

    docker run -d --name karna -p 8000:8000 -v karna-data:/data ghcr.io/netra-ai-lab/karna
    
  3. Open http://localhost:8000. Drop an audio file on the page, or record from the microphone.

The page won't open? The app needs port 8000, which -p 8000:8000 sets up. If you start the image from Docker Desktop's Images tab instead, open Optional settings and set Host port to 8000. The models load in the background for the first few seconds, and the header says Ready once they have.

Platforms Windows and Linux PCs (x86-64) and ARM64, including Apple Silicon Macs
GPU Not needed; runs on the CPU
Download , both models included
Memory
Speed karna-base 8.7 s and karna-large 17.0 s per minute of audio (16-thread AMD Zen 3 laptop CPU, batch 8)
Internet Not needed after the download. Audio never leaves your computer.
Input wav, flac, ogg or mp3 of Khmer or English speech, up to 30 s per file
Output Lowercase text without punctuation, as txt or json

Python package. For scripts and pipelines, install from PyPI. Inference runs on ONNX Runtime, so PyTorch isn't needed.

pip install "netra-karna[cpu]"          # or [gpu] for CUDA, [full] for the web app too
Extra Adds
(none) The karna library and command: numpy, soundfile, soxr, huggingface_hub. Add one runtime below.
cpu ONNX Runtime for the CPU
gpu ONNX Runtime with CUDA (instead of cpu)
server The web app and REST API (karna serve): fastapi, uvicorn
full cpu and server

The first run downloads the ONNX model from Hugging Face and caches it under ~/.cache/huggingface (HF_HOME): karna-base is 287 MB and karna-large 871 MB. karna download fetches them ahead of time, for offline use.

6. Usage

Python. Two lines to a transcript. Load a model once, then transcribe files, arrays or batches of either.

import karna

asr = karna.load_model("karna-base")              # or "karna-large", a Hugging Face id, a local folder
print(asr.transcribe("speech.wav"))             # one file -> one string
print(asr.transcribe(["a.wav", "b.flac"]))      # a list -> a list, batched
print(asr.transcribe((waveform, 44100)))        # a numpy array with its sample rate

Command line. Each file prints as one line: the path, a tab, then the text.

karna transcribe speech.wav other.flac --model karna-large    # --format txt|json, --device cpu|cuda
karna models                                                  # list the released models
karna download karna-base karna-large                         # fetch now, run offline later
karna serve --port 8000                                       # the web app and REST API ([server] extra)

REST API. Upload, then poll, or wait for the text in one call. Interactive docs are at http://localhost:8000/docs.

curl -F file=@speech.wav "http://localhost:8000/v1/transcribe?wait=true"           # the finished job, with result.text
curl -F file=@speech.wav -F model=karna-large http://localhost:8000/v1/transcribe  # -> 202, the queued job
curl http://localhost:8000/v1/jobs/<id>                                            # until "status": "done"
curl -o speech.txt "http://localhost:8000/v1/jobs/<id>/export?format=txt"          # or json
Setting Default Meaning
KARNA_API_KEY (unset) Require X-API-Key / Authorization: Bearer on /v1/*. Set it before exposing the port beyond your machine.
KARNA_MODEL karna-base The model loaded at start; the other loads on first use
KARNA_MAX_SECONDS 30 Longer audio is refused with HTTP 422

docs/USAGE.md lists every flag, route, environment variable and device.

Train it yourself. One script runs the whole recipe: data, conversion, fine-tune, prune, distil, recover, evaluate and export to ONNX. It resumes where it stopped. Training is a separate package in training/, with PyTorch.

pip install -e . -e training                       # or: bash training/setup.sh
cp training/local.env.example training/local.env   # point it at your data
training/run.sh base                               # or: training/run.sh large
Reference
Usage Python API, CLI flags, REST routes, environment variables, devices
Training run.sh step by step, data layout, environment variables, checkpoints and resuming
Design The pruning recipe, each decision and how it departs from DiariZen, the code map
Results All test and dev numbers, the ablations, the pruning run step by step
Releasing Exporting to ONNX, uploading, PyPI and Docker releases

7. Limitations

  • English is the weak side. Pruning to about 80% costs English far more than Khmer, at 1.5–2× the teacher's WER. Use karna-large, or a fine-tuned teacher, when English accuracy matters.
  • No punctuation or casing. Output is lowercase with no punctuation, because the Omnilingual character vocabulary has no Khmer punctuation.
  • Greedy decoding only. There is no language model or beam search.
  • One pass per file. Each file is decoded in a single pass, so split long recordings into utterances first. Training used clips of 1–25 s, and the web app and REST API refuse files over 30 s (KARNA_MAX_SECONDS).
  • Two languages only. The models were trained and tested on Khmer and English only; other languages Omnilingual supports will have degraded.
  • The Khmer corpus is a manual download. DDD is public, but training/run.sh doesn't fetch it, and it reads DDD through its own shard index (see docs/TRAINING.md).

8. Licensing

This project is released under the Apache License 2.0 (see LICENSE); THIRD_PARTY_LICENSES.md lists what it builds on.

  • Weights: derived from Meta's Omnilingual ASR CTC models, released under Apache 2.0.
  • training/karna_train/hardconcrete.py: ported from DiariZen, which is MIT-licensed.
  • Training data: DDD is CC BY-SA 4.0 (Digital Divide Data), LibriSpeech is CC BY 4.0, and FLEURS is CC BY 4.0.

References

  1. Omnilingual ASR: Open-Source Multilingual Speech Recognition for 1600+ Languages
    Omnilingual ASR team, Meta AI
    2025.
    facebookresearch/omnilingual-asr

  2. Fine-tune Before Structured Pruning: Towards Compact and Accurate Self-Supervised Models for Speaker Diarization
    Jiangyu Han et al.
    Interspeech 2025.
    arXiv:2505.24111

  3. Efficient and Generalizable Speaker Diarization via Structured Pruning of Self-Supervised Models
    Jiangyu Han et al.
    2025.
    arXiv:2506.18623

  4. DPHuBERT: Joint Distillation and Pruning of Self-Supervised Speech Models
    Yifan Peng, Yui Sudo, Shakeel Muhammad, Shinji Watanabe
    Interspeech 2023.
    arXiv:2305.17651

  5. Learning Sparse Neural Networks through L0 Regularization
    Christos Louizos, Max Welling, Diederik P. Kingma
    ICLR 2018.
    arXiv:1712.01312

  6. FLEURS: Few-shot Learning Evaluation of Universal Representations of Speech
    Alexis Conneau et al.
    SLT 2022.
    arXiv:2205.12446

  7. LibriSpeech: an ASR corpus based on public domain audio books
    Vassil Panayotov, Guoguo Chen, Daniel Povey, Sanjeev Khudanpur
    ICASSP 2015.
    OpenSLR 12

  8. Khmer ASR Cultural Dataset
    Digital Divide Data
    Hugging Face Datasets.
    Digital-Divide-Data/khmer-speech-dataset

Metadata

Release files for netra-karna 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netra-karna 0.2.0
File Size Uploaded Provenance Actions
netra_karna-0.2.0.tar.gz 169.5 kB With provenance Details for netra_karna-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netra-karna 0.2.0
File Interpreter ABI Platform Actions
netra_karna-0.2.0-py3-none-any.whl Python 3 none any Details for netra_karna-0.2.0-py3-none-any.whl

Total release size: 332.9 kB

Release files / netra_karna-0.2.0.tar.gz

Download URL netra_karna-0.2.0.tar.gz
Size 169.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d9282bb2fa79d46a699a6332282fa83a34bcd589f926893d12187313f84b846b
BLAKE2b-256 checksum
How to use checksums
fd3c93591a08bb52db164c4fe24a5887b74dd047e1158f90dbb0856db3a25bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / netra_karna-0.2.0-py3-none-any.whl

Download URL netra_karna-0.2.0-py3-none-any.whl
Size 163.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
888b93d508b0127be9a8b5f1f06dbfd7ba626048556a742fa0d879608cc3633a
BLAKE2b-256 checksum
How to use checksums
bb5031ead531662d5868a380d0d7c68e52281cbd2a24765322046d50a7c1d852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for netra-karna 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for netra_karna-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page