Masterx commited on
Commit
28246f3
Β·
verified Β·
1 Parent(s): 50488c6

Add files using upload-large-folder tool

Browse files
README.md CHANGED
@@ -1,45 +1,51 @@
1
- ---
2
- license: apache-2.0
3
- language:
4
- - ar
5
- - en
6
- pipeline_tag: automatic-speech-recognition
7
- tags:
8
- - audio
9
- - speech-recognition
10
- - transcription
11
- - onnx
12
- base_model:
13
- - CohereLabs/cohere-transcribe-arabic-07-2026
14
- library_name: onnx
15
- ---
16
-
17
- # Cohere Transcribe Arabic (07-2026) β€” ONNX
18
-
19
- ONNX export of [`CohereLabs/cohere-transcribe-arabic-07-2026`](https://huggingface.co/CohereLabs/cohere-transcribe-arabic-07-2026),
20
- a 2B-parameter Arabic + English dedicated ASR model (Conformer encoder + lightweight Transformer decoder).
21
-
22
- Exported to the same merged encoder / KV-cache decoder graph layout as
23
- [`onnx-community/cohere-transcribe-03-2026-ONNX`](https://huggingface.co/onnx-community/cohere-transcribe-03-2026-ONNX)
24
- for use with [WinSTT](https://github.com/dahshury/WinSTT).
25
-
26
- ## Graphs (`onnx/`)
27
-
28
- | File | Inputs | Outputs |
29
- |------|--------|---------|
30
- | `encoder_model*.onnx` | `input_features [B,T,128]` | `last_hidden_state [B,S,1024]` |
31
- | `decoder_model_merged*.onnx` | `input_ids`, `attention_mask`, `position_ids`, `num_logits_to_keep`, `encoder_hidden_states`, `past_key_values.{0..7}.{decoder,encoder}.{key,value}` | `logits`, `present.{0..7}.{decoder,encoder}.{key,value}` |
32
-
33
- ## Precisions
34
-
35
- - `` (default) β€” fp32. Best accuracy; also the fastest on the CPU EP this model runs on.
36
- - `q4` β€” 4-bit (`MatMulNBitsQuantizer`, block_size=32, symmetric), ~2.2 GB.
37
-
38
- fp16 / q4f16 are not shipped: the model is CPU-only (its attention kernel is not DirectML-compatible)
39
- and the ONNX Runtime CPU EP up-casts fp16β†’fp32, so they'd be slower and larger with no benefit.
40
-
41
- Verified numerically against the original PyTorch model (encoder/decoder parity ~1e-5 in fp32) and by
42
- end-to-end greedy decoding. See `export_merged.py` / `quantize.py` to reproduce.
43
-
44
-
45
- License: Apache-2.0 (inherited from the base model).
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - ar
5
+ - en
6
+ pipeline_tag: automatic-speech-recognition
7
+ tags:
8
+ - audio
9
+ - speech-recognition
10
+ - transcription
11
+ - onnx
12
+ - directml
13
+ base_model:
14
+ - CohereLabs/cohere-transcribe-arabic-07-2026
15
+ ---
16
+
17
+ # Cohere Transcribe Arabic 07-2026 β€” DirectML-optimized ONNX
18
+
19
+ ONNX export of [CohereLabs/cohere-transcribe-arabic-07-2026](https://huggingface.co/CohereLabs/cohere-transcribe-arabic-07-2026)
20
+ (2B, Arabic + English) restructured to run **fast on the ONNX Runtime DirectML EP**. Same
21
+ architecture as [cohere-transcribe-03-2026](https://huggingface.co/Masterx/cohere-transcribe-03-2026-ONNX),
22
+ hand-exported from the reference PyTorch weights (stock `optimum` can't export `cohere_asr`).
23
+
24
+ ## What changed (`tools/onnx/cohere_decompose_attention.py` in [WinSTT](https://github.com/dahshury/WinSTT))
25
+
26
+ 1. **Loop-invariant cross-KV hoisted into the encoder** β€” cross-attention K/V (which depend only on
27
+ the audio) are computed once per utterance in `encoder_model*.onnx`, not per decoded token.
28
+ 2. **Static self-KV decode** β€” the self-attention KV cache is a fixed-length buffer updated by a
29
+ masked write, so the DirectML EP compiles the decoder **once** per utterance instead of re-fusing
30
+ its graph on every autoregressive step. Measured ~3.5 ms/token on DirectML (RTX 3080 Ti) vs
31
+ ~16 ms/token on the CPU EP β€” **~4.6Γ— faster**, entirely on the GPU.
32
+
33
+ Two decoders per precision (both fed by the hoisted encoder, sharing the decoder sidecar):
34
+ `decoder_model_merged*.onnx` (**static self-KV**, marker `winstt_static_kv`, fastest on DirectML) and
35
+ `decoder_model_merged*_dyn.onnx` (**growing self-KV**, faster on the CPU EP). WinSTT picks per device.
36
+
37
+ Numerically verified against the source on CPU (autoregressive logits parity: bit-exact fp32/q4).
38
+
39
+ **Notes vs the multilingual export:** this torch-traced graph uses a `(B, S, nh, hd)` head layout, so
40
+ the cross-attention is left dynamic (not padded to a fixed bucket) β€” perfectly fast for the ≀10 s
41
+ segments a dictation VAD produces; only unrealistically long single clips would benefit from
42
+ bucketing. The **int8** decoder ships **dynamic-only** (`decoder_model_merged_int8.onnx` is the
43
+ growing-self graph): its `DynamicQuantizeLinear` scales interact badly with the fixed-KV write, so it
44
+ runs the hybrid path (encoder-DML / decoder-CPU). fp32 and q4 get the full static decode.
45
+
46
+ ## Files
47
+
48
+ - `onnx/encoder_model[_int8|_q4].onnx` (+ external data) β€” hoisted encoders (cross-KV outputs).
49
+ - `onnx/decoder_model_merged[_q4].onnx` (+ `_dyn`) β€” static / dynamic decoders (fp32, q4).
50
+ - `onnx/decoder_model_merged_int8.onnx` β€” dynamic-only (int8).
51
+ - Tokenizer / configs β€” unchanged.
onnx/decoder_model_merged.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3b00b8c5744fa39b79d215bc9a53ebdc3c9d0a3ba7e4fa8272cfa6d5c0fba6b4
3
- size 147878
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5800d1290f24c78f312a57fb79e40cc7ef873df09e3c2870c66cd6744e52405a
3
+ size 134525
onnx/decoder_model_merged_dyn.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b00b8c5744fa39b79d215bc9a53ebdc3c9d0a3ba7e4fa8272cfa6d5c0fba6b4
3
+ size 147878
onnx/decoder_model_merged_q4.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3efcd8bc7ac501e6991fb9bb9677ad7143b88870aeac85a14b350cc4c88e62d7
3
- size 165682
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e9a47d683b5d89925c61ba4de6b69f142a08fa2b7fa877618aca9e5b5d7482e
3
+ size 152329
onnx/decoder_model_merged_q4_dyn.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3efcd8bc7ac501e6991fb9bb9677ad7143b88870aeac85a14b350cc4c88e62d7
3
+ size 165682