Download README.md from Reza2kn/Shenava-Rizeh-v1.5-CoreML-fp16: direct link, hf CLI and curl.
- Browser
- Download file 5.72 kB
-
https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5-CoreML-fp16/resolve/main/README.md
- Command line
-
hf download hf://Reza2kn/Shenava-Rizeh-v1.5-CoreML-fp16/README.md
-
curl -L -o README.md https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5-CoreML-fp16/resolve/main/README.md
language:
- fa
- en
license: gpl-3.0
library_name: coreml
pipeline_tag: automatic-speech-recognition
base_model:
- Reza2kn/Shenava-Rizeh-v1.5
base_model_relation: quantized
tags:
- automatic-speech-recognition
- persian
- farsi
- zipformer
- rnnt
- transducer
- on-device
- shenava
- coreml
- fp16
- ios
- macos
🎙️ Shenava-Rizeh-v1.5-CoreML-fp16
Core ML (fp16, ML Program, iOS 16 / macOS 13+) export of Shenava Rizeh v1.5, a 60M-parameter Zipformer2 RNN-T model for Persian. It is a fine-tune of dkaraush/tinyasr en-fa.
This is not a drop-in for the v1.0 CoreML file. Rizeh v1.0 was a CTC model, while v1.5 is a transducer. You get three models instead of one, and the app decodes with a small RNN-T loop (below) instead of CTC argmax.
| Uniform Triple Threat (full benchmark, tinyasr engine + KenLM, beam 16) | 3.201 (#4 on the board) |
| Same engine, no LM | 3.692 |
| This Core ML graph | Verified on an M2 Mac against the fp32 PyTorch model, 8 clips: see the table below |
Files
| File | Target | Size | Error vs fp32 (8 clips) | Tokens identical | M2 latency per 30 s window (CPU / GPU / ALL) |
|---|---|---|---|---|---|
encoder.mlpackage (fp16, with reductions, softmax and norms kept in fp32) |
iOS 16 / macOS 13 | 144 MB | 0.08 % | 8/8 on every compute unit | 248 / 71 / 110 ms |
encoder-int4.mlpackage (int4 weights, blocks of 32, fp16 activations) |
iOS 18 / macOS 15 | 67 MB | see note | n/a | 235 / 732 / 800 ms |
decoder.mlpackage, joiner.mlpackage |
iOS 16 | 2.6 + 2.1 MB |
Inputs and outputs:
- Encoder: takes
xfloat32 (1, 3000, 80) fbank, zero-padded to 30 s, plusx_lensint32 (1,), the true frame count. It returnsencoder_out(1, 748, 512), already projected for the joiner, andencoder_out_lens. - Decoder: takes
yint32 (1, 2), the last two tokens (starting at[0, 0]), and returnsdecoder_out(1, 512). - Joiner: takes one encoder frame (1, 512) plus
decoder_outand returnslogit(1, 2080).
Why fp32 islands: a pure fp16 export drifts about 12 % on the Neural Engine, and 3/8 clips decode differently. It is fine on CPU and GPU. Keeping the reductions, softmax and normalisation ops in fp32 makes every compute unit match fp32 to within 0.1 %.
int4 note:
- The int4 package's weights sit on an int4 grid: codes −8..7, one scale per 32 inputs.
- The fp32-vs-int4 difference (about 9 % on encoder outputs) is the quantization itself, not a runtime error. On the M2 the int4 package matches a PyTorch model with the same int4 weights to within 0.08 %.
- That PyTorch model scores TT 4.45 vs 4.35 fp32 on the held-out half (official TT, no LM, beam 4).
- On the M2, int4 is slower than fp16 on GPU/ANE (weight decompression), and the same speed on CPU. Use it when download or app size matters more than speed. Use fp16 with
.cpuAndGPUor.allfor speed.
tokens.txt maps token ids to pieces. run_coreml.py [encoder package] and reference/ are the parity check. export_coreml.py (with FQ=1 for the int4 grid) and cmq2.py reproduce every file.
Padding is handled exactly: the subsampling ConvNeXt, the downsampling edges and the chunk-edge scales of the causal convs are all masked at the true length. A short clip padded to 3000 frames therefore gives the same output as unpadded. Split longer audio on VAD silences.
Features (must match exactly)
Kaldi-style fbank (kaldi-native-fbank defaults), with samples as float in [-1, 1] (not int16 scale):
- 16 kHz audio, 25 ms window, 10 ms shift, povey window, pre-emphasis 0.97, dither 0, remove DC offset
- 512-point FFT, 80 mel bins from 20 to 7600 Hz, power spectrum, log
snip_edges = false
Decoding
- Blank id 0, decoder context 2, max 3 symbols per frame.
- Mask the English block (ids 32–1055) and keep ids 0–31 plus 1056–2079. This is the language-selection mechanism; the Persian language vector is already baked into the encoder.
- Greedy decoding is in
run_coreml.py. The published benchmark numbers use beam search (beam 4 without the LM, 16 with it). - The best scores come from the n-gram LM fusion in the tinyasr engine patch. The 4-gram LM is in the main repo, if you want to port the fusion: on each completed word, add α·ln P(word) + β with α 0.2 and β 1.5.
Other formats
- Shenava-Rizeh-v1.5: int4
.tzffor the tinyasr engine (CPU/WASM), KenLM, engine patch, training code - Shenava-Rizeh-v1.5-sherpa-onnx: fp32 + int8 (Android, desktop)
- Shenava-Rizeh-v1.5-ONNX-fp16
فارسی
خروجی Core ML (fp16) از مدل شنوا ریزه نسخهٔ ۱.۵. این مدل ترنسدیوسر (RNN-T) است، نه CTC؛ پس بهجای یک فایل، سه مدل (انکودر، دیکودر، جوینر) دارد و حلقهٔ دیکود فرق میکند. ورودی انکودر ویژگیهای fbank هشتادتایی است که تا ۳۰۰۰ فریم (۳۰ ثانیه) صفرگذاری میشود و طول واقعی جداگانه داده میشود. هنگام دیکود، توکنهای انگلیسی (شناسههای ۳۲ تا ۱۰۵۵) را ماسک کنید. پیش از استفادهٔ اصلی، اسکریپت run_coreml.py را یک بار روی مک اجرا کنید.
License
GPL-3.0, inherited from tinyasr.