File size: 3,496 Bytes
6d31f06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
language:
- fa
- en
license: gpl-3.0
library_name: coreml
pipeline_tag: automatic-speech-recognition
tags: [persian, farsi, asr, zipformer, transducer, shenava, coreml, ios]
base_model: Reza2kn/Shenava-Rizeh-v1.6
---

# 🎙️ Shenava-Rizeh-v1.6-CoreML-fp16

A Core ML export (ML Program, iOS 16 / macOS 13+) of **[Shenava Rizeh v1.6](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6)**, a 60M Zipformer2 RNN-T for Persian. It has the same interface as the v1.5 CoreML repo, so v1.6 is a drop-in upgrade: three models (encoder, decoder, joiner) plus a small RNN-T loop.

| | |
|---|---|
| Uniform Triple Threat, full benchmark (tinyasr + KenLM, beam 16) | **3.119** (v1.5: 3.201) |
| Poetry WER, held-out Ganjoor, no LM | 13.7% (v1.5: 18.8%) |

## Files

Checked on an M2 Mac against the fp32 PyTorch model on a 30 s reference clip.

| File | Target | Size | Error vs fp32 | Tokens identical | M2 per 30 s (CPU / GPU / ALL) |
|---|---|---|---|---|---|
| `encoder.mlpackage` (fp16, with reductions, softmax and norms in fp32) | iOS 16 | 150 MB | 0.08% (GPU, ALL), 0.5% (CPU), 0.1% (ANE) | ✅ on every compute unit | 238 / **64** / 144 ms |
| `encoder-int4.mlpackage` (int4, blocks of 32) | iOS 18 | 70 MB | 8.3% (this is the quantization itself) | ✅ on every compute unit | 228 / 730 / 833 ms |
| `decoder.mlpackage`, `joiner.mlpackage` | iOS 16 | | | | |

- **Encoder input:** `x` float32 (1, 3000, 80) fbank, zero-padded to 30 s, plus `x_lens` int32, the true frame count. Padding is masked exactly.
- **Encoder output:** `encoder_out` (1, 748, 512), already projected for the joiner, plus `encoder_out_lens`.
- **Decoder:** `y` int32 (1, 2), the last two tokens, starting at [0, 0] → `decoder_out` (1, 512).
- **Joiner:** returns `logit` (1, 2080). **Mask ids 32–1055** (the English block). Blank is 0, max 3 symbols per frame.
- **int4 on the Neural Engine:** the ANE compiler rejects the int4 package, so Core ML falls back to CPU/GPU. Use fp16 with `.cpuAndGPU` for speed. Use int4 when app size matters more.

**Features:** kaldi fbank with samples in [-1, 1]: 25 ms / 10 ms, povey window, pre-emphasis 0.97, dither 0, 512-point FFT, 80 mel bins from 20–7600 Hz, log, `snip_edges=false`.

`run_coreml.py` and `reference/` are the parity check. To rebuild: `export_coreml.py` (`FQ=1 IOS18=1` gives the int4 base) plus `cmq2.py`.

**Speaker diarization:** `encoder_spk.mlpackage` in [Shenava-Rizeh-v1.6-Diarization](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6-Diarization) is this encoder with an extra speaker-feature output.

## All formats
- [Shenava-Rizeh-v1.6](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6): int4 `.tzf` for the tinyasr engine (CPU/WASM), KenLM, engine patch, training code
- [Shenava-Rizeh-v1.6-sherpa-onnx](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6-sherpa-onnx): offline + streaming, fp32 / int8 / int4
- [Shenava-Rizeh-v1.6-ONNX-fp16](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6-ONNX-fp16)
- [Shenava-Rizeh-v1.6-tract-streaming](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6-tract-streaming): pure Rust
- [Shenava-Rizeh-v1.6-CoreML-fp16](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6-CoreML-fp16) and [Shenava-Rizeh-v1.6-CoreML-iOS15-fp16](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6-CoreML-iOS15-fp16) (streaming)
- [Shenava-Rizeh-v1.6-Diarization](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.6-Diarization): who spoke when, 3.5M parameters on top of this encoder

## License
GPL-3.0, inherited from tinyasr.