--- license: other license_name: indic-open-model-license-v1 license_link: https://huggingface.co/simple-voice/indic-transcribe-flex-coreml/blob/main/Indic_Open_Model_License.md base_model: bodhan-ai/indic-transcribe-flex base_model_relation: quantized pipeline_tag: automatic-speech-recognition library_name: coreml language: - en - as - bn - brx - doi - gu - hi - kn - ks - kok - mai - ml - mni - mr - ne - or - pa - sa - sat - sd - ta - te - ur - bho - hne - bgc - bhb tags: - coreml - apple-silicon - ane - fluidaudio - canary - indic - hinglish - romanization --- # Indic-Transcribe-Flex — Core ML int4 (FluidAudio Canary layout) **Built with Indic-Transcribe-Flex from Bodhan AI / AI4Bharat.** Core ML conversion of [`bodhan-ai/indic-transcribe-flex`](https://huggingface.co/bodhan-ai/indic-transcribe-flex) at revision `ecba9bac9013c0340fe814b336897ee51ed80be9`, packaged for FluidAudio's `CanaryManager`, plus `DecoderKV`, the same decoder with a key/value cache in Core ML states that runs on the Neural Engine. Used by Simple Voice (with `DecoderKV`), where it is the default Hindi / Hinglish model ("Indic (Hinglish)"). Indic-Transcribe-Flex is Bodhan AI / AI4Bharat's fine-tune of [NVIDIA Canary-1B-v2](https://huggingface.co/nvidia/canary-1b-v2) (CC BY 4.0): 27 languages, with native-script, mixed-script or romanized output chosen by a prompt token. ## Licence This is a Derivative of Indic-Transcribe-Flex and is licensed under the **Indic Open Model License v1.0** (full text: [`Indic_Open_Model_License.md`](Indic_Open_Model_License.md); attribution: [`NOTICE.md`](NOTICE.md)). - **Share-alike:** any further derivative you make available must stay under the Indic Open Model License v1.0 (section 5.1), with the attribution notice above (section 2). - **Use cap (section 14, verbatim):** "If Your own product or service — other than through Third-Party Hosting under Section 3 — is powered by the Software or a Derivative and exceeds 500 million monthly active users or US$250 million in annual revenue, You must obtain a separate license from Licensor. This Section 14 does not apply to Eligible Public-Interest Entities." - Canary-1B-v2, the upstream architecture and base weights, is by NVIDIA under CC BY 4.0. ## Files | File | Role | Precision | Size | |------|------|-----------|------| | `Preprocessor.mlmodelc` | waveform `[1,240000]` fp32 → mel `processed` `[1,128,1501]` | fp32, CPU | 3.8 MB | | `EncoderInt4.mlmodelc` | mel → `encoder` `[1,1024,188]` | int4 per-block-32 symmetric, iOS 18 / macOS 15 | 446.6 MB | | `DecoderInt4.mlmodelc` | `input_ids` `[1,256]` + encoder context → hidden `decoder` `[1,256,1024]` (no KV cache) | int4 per-block-32 symmetric, iOS 18 / macOS 15 | 232.7 MB | | `Projection.mlmodelc` | hidden `[1,1024]` → `logits` `[1,7152]` | fp16 | 14.7 MB | | `DecoderKV.mlmodelc` | KV-cache decoder and head (functions `fill`, `prompt` and `step`, see below) | 4-bit palettized (DecoderInt4's weights), head fp16, iOS 18 / macOS 15 | 224.2 MB | | `vocab.json` | 7152 SentencePiece pieces, JSON object `{"id": "piece"}` | — | 0.2 MB | | `metadata.json` | shapes, special token ids, prompts, upstream revision | — | 0.0 MB | Total for FluidAudio's `CanaryManager` (Preprocessor, EncoderInt4, DecoderInt4, Projection, vocab, metadata): 698.0 MB (697974804 bytes). Contract: 15 s window (240000 samples at 16 kHz), 256 decoder steps, `eos=3`, `pad=2`, `bos=4`, vocabulary 7152. Same feature names and shapes as FluidAudio 0.17.4's Canary loader. Total for the KV-cache path (Preprocessor, EncoderInt4, DecoderKV, vocab, licence, notice): 674.8 MB (674849088 bytes). ## Prompts (10 tokens, pass as `[Int32]` to `CanaryManager(models:prompt:)`) Layout `<|startofcontext|> <|startoftranscript|> <|emo:undefined|> <|L|> <|L|> <|pnc|> <|noitn|/|itn|> <|noromanized|/|romanized|> <|notimestamp|> <|nodiarize|>`, ids from Flex's `tokenizer_spl_tokens.model` (no leading `▁` piece; (c) equals `prompt_ids_by_lang.hi` in Flex's `tokenizer_config.json`). | Prompt | Token ids | |--------|-----------| | (a) Hindi, romanized (Roman Hinglish), punctuation | `[7, 4, 18, 89, 89, 5, 9, 10, 13, 15]` | | (b) Hindi, mixed script (ITN) | `[7, 4, 18, 89, 89, 5, 8, 11, 13, 15]` | | (c) Hindi, native script | `[7, 4, 18, 89, 89, 5, 9, 11, 13, 15]` | | (d) English | `[7, 4, 18, 66, 66, 5, 9, 11, 13, 15]` | ```swift let models = try CanaryModels.load(from: directory, precision: .int4) let manager = CanaryManager(models: models, prompt: [7, 4, 18, 89, 89, 5, 9, 10, 13, 15]) let text = try await manager.transcribe(audioURL: url) ``` ## Validation Greedy decode with FluidAudio's algorithm (int4 Core ML, CPU+ANE) against NeMo's PyTorch greedy decode (same prompt, no KV cache), on the fixed clips in `scripts/models/indic-flex/clips/` (macOS `say`, 16 kHz). Pass thresholds: CER against NeMo ≤ 0.1 per clip and ≤ 0.05 on average; romanized-prompt output ≥ 95% Latin letters. Mean CER: 0.0057. | Clip | Prompt | NeMo (PyTorch) | Core ML int4 | CER | NeMo latency | Core ML latency | |------|--------|----------------|--------------|-----|--------------|-----------------| | hinglish1 (Lekha, 4.43 s) | a hi romanized | Main kal office aaunga aur meeting ke baad code review karunga theek hai | Main kal office aaunga aur meeting ke baad code review karunga theek hai | 0.000 | 29.85 s | 11.05 s | | hinglish2 (Lekha, 4.77 s) | a hi romanized | Aaj shaam ko project ki deadline hai isliye please report jaldi bhej dena | Aaj shaam ko project ki deadline hai isliye please report jaldi bhej dena | 0.000 | 31.69 s | 4.39 s | | hinglish3 (Lekha, 4.28 s) | a hi romanized | Mera phone charge nahi ho raha kya tumhare paas Type C cable hai | Mera phone charge nahi ho raha kya tumhare paas Type C cable hai | 0.000 | 31.65 s | 4.46 s | | hinglish4 (Lekha, 4.56 s) | a hi romanized | Hum log weekend par Gorba ja rahe hain tickets maine online book kar di hain | Hum log weekend par Goa ja rahe hain tickets maine online book kar di hain | 0.026 | 31.17 s | 4.5 s | | hinglish5 (Lekha, 3.91 s) | a hi romanized | Boss ne bola ki naya feature agle hafte tak live hona chahiye | Boss ne bola ki naya feature agle hafte tak live hona chahiye | 0.000 | 31.11 s | 3.81 s | | english1 (Rishi, 5.12 s) | d en | Please schedule the meeting for tomorrow afternoon and send the invite to the whole team | Please schedule the meeting for tomorrow afternoon and send the invite to the whole team | 0.000 | 31.21 s | 4.3 s | | english2 (Samantha, 3.98 s) | d en | The quick brown fox jumps over the lazy dog while the weather stays sunny | the quick brown fox jumps over the lazy dog while the weather stays sunny | 0.014 | 30.95 s | 4.32 s | ## Conversion - Script: `scripts/models/indic-flex/publish.sh ecba9bac9013c0340fe814b336897ee51ed80be9` in yuyudhan/simple-voice (run before the script was committed there), uv-locked environment (Python 3.11, torch 2.7.0, coremltools 9.0, nemo_toolkit 2.7.3). - Decode algorithm reference: FluidInference/mobius `588b8e7077d454e9613bdb2672b89824c2f7095d` (`models/stt/canary-1b-v2/coreml/torch_reference.py`; that folder ships no conversion scripts). - Steps: NeMo restore → `torch.jit.trace` of the featurizer, FastConformer encoder, transformer decoder (full sequence, `[1,256]`) and the 1024→7152 head → `coremltools.convert` (mlprogram; preprocessor fp32 iOS 17, encoder/decoder fp16 iOS 18, projection fp16 iOS 17) → `linear_quantize_weights` int4 `linear_symmetric` `per_block` 32 on encoder and decoder → compiled to `.mlmodelc` with Core ML's `MLModel.compileModel`. ## DecoderKV: the decoder with a KV cache (Neural Engine) `DecoderInt4` has no memory between tokens, so every step re-runs all 256 positions. `DecoderKV` keeps the attention keys and values in Core ML states (macOS 15 / iOS 18 `MLState`) and runs one token per call; Core ML places every op of it on the Neural Engine except the token-embedding lookup and the mask arithmetic around it. One multifunction package, three functions sharing one state (load each with `MLModelConfiguration.functionName`, make the state from `step`): | Function | Inputs | Outputs | Effect on the state | |----------|--------|---------|---------------------| | `fill` | `encoder` `[1,1024,188]` fp16 (EncoderInt4's output) | `ready` `[1,1,8]` | writes the cross-attention keys/values of every layer, zeroes the self-attention cache | | `prompt` | `prompt_ids` `[1,10]` int32 (the canary2 prompt), `cross_mask` `[1,1,1,188]` fp16 (0 for valid encoder frames, −10000 after) | `logits` `[1,1,7152]` fp16, after the last prompt token | writes the keys and values of positions 0–9 | | `step` | `input_id` `[1,1]` int32, `position` `[1,256,1]` fp16 one-hot, `self_mask` `[1,1,1,256]` fp16 (0 up to the position, −10000 after), `cross_mask` as above | `logits` `[1,1,7152]` fp16 | writes the token's key and value at `position` | States: `self0`…`self23` `[1,2,256,1024]` and `cross0`…`cross23` `[1,2,188,1024]` fp16 (keys, then values). Per window: `fill`, `prompt`, then `step` for each argmax token from position 10 on, until `<|endoftext|>` (3) or position 254 — the same tokens as the full-sequence loop. Weights: DecoderInt4's own (each int4 block times its fp16 scale, the int4 position table included), re-compressed as 4-bit k-means palettes per 16 output channels because the Neural Engine does not run per-block int4 weights; the head is the Projection's fp16 weights. Built by `scripts/models/indic-flex/indic_kv.py` in yuyudhan/simple-voice (`trace --published`, `coreml --weights pal4`). Validation: on the fixed clips above, with the encoder on the GPU, DecoderKV (CPU + Neural Engine) gives the same token ids as DecoderInt4 + Projection (GPU) on all 7 clips; the KV-cache algorithm itself equals NeMo's full-sequence greedy decode token for token in PyTorch on all 7 clips.