ONNX export of CohereLabs/cohere-transcribe-03-2026 (nemo-conformer-aed)
Browse files- .gitattributes +2 -0
- README.md +107 -0
- REPORT.md +199 -0
- config.json +4 -0
- decoder-model.int8.onnx +3 -0
- decoder-model.onnx +3 -0
- encoder-model.int8.onnx +3 -0
- encoder-model.int8.onnx.data +3 -0
- encoder-model.onnx +3 -0
- encoder-model.onnx.data +3 -0
- vocab.txt +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
encoder-model.int8.onnx.data filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
encoder-model.onnx.data filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language: [ar, de, el, en, es, fr, it, ja, ko, nl, pl, pt, vi, zh]
|
| 4 |
+
tags: [automatic-speech-recognition, onnx, onnx-asr, nemo-conformer-aed, cohere]
|
| 5 |
+
base_model: CohereLabs/cohere-transcribe-03-2026
|
| 6 |
+
pipeline_tag: automatic-speech-recognition
|
| 7 |
+
library_name: onnx-asr
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Cohere Transcribe 2B — ONNX (nemo-conformer-aed)
|
| 11 |
+
|
| 12 |
+
ONNX export of [CohereLabs/cohere-transcribe-03-2026](https://huggingface.co/CohereLabs/cohere-transcribe-03-2026)
|
| 13 |
+
for [onnx-asr](https://github.com/istupakov/onnx-asr).
|
| 14 |
+
|
| 15 |
+
**Stock onnx-asr loads this model. No patches and no new model family are needed.**
|
| 16 |
+
|
| 17 |
+
Despite the "2B ASR" framing, `cohere_asr` is not a speech-LLM. It is an attention
|
| 18 |
+
encoder-decoder built on a NeMo FastConformer: `CohereAsrConfig` declares
|
| 19 |
+
`sub_configs = {"encoder_config": ParakeetEncoderConfig}`, and its decoder prompt is
|
| 20 |
+
token-for-token the NVIDIA Canary prompt. It therefore drops straight into the existing
|
| 21 |
+
`nemo-conformer-aed` family that already serves Canary.
|
| 22 |
+
|
| 23 |
+
## Usage
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
import onnx_asr
|
| 27 |
+
|
| 28 |
+
model = onnx_asr.load_model("nemo-conformer-aed", "path/to/this/repo") # or quantization="int8"
|
| 29 |
+
print(model.recognize("audio_16khz.wav", language="en"))
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
`language` accepts any of the 14 supported codes: `ar de el en es fr it ja ko nl pl pt vi zh`.
|
| 33 |
+
`pnc=True|False` toggles punctuation and capitalisation.
|
| 34 |
+
|
| 35 |
+
## Graph contract
|
| 36 |
+
|
| 37 |
+
Two graphs, drop-in compatible with `istupakov/canary-1b-v2-onnx`:
|
| 38 |
+
|
| 39 |
+
| graph | inputs | outputs |
|
| 40 |
+
|---|---|---|
|
| 41 |
+
| `encoder-model.onnx` | `audio_signal` [B,128,T] f32, `length` [B] i64 | `encoder_embeddings` [B,T/8,1024] f32, `encoder_mask` [B,T/8] i64 |
|
| 42 |
+
| `decoder-model.onnx` | `input_ids` [B,C] i64, `encoder_embeddings` [B,E,1024] f32, `encoder_mask` [B,E] i64, `decoder_mems` [9,B,P,1024] f32 | `logits` [B,C,16384] f32 (log-softmax), `decoder_hidden_states` [9,B,P+C,1024] f32 |
|
| 43 |
+
|
| 44 |
+
Two details make the zero-patch fit work:
|
| 45 |
+
|
| 46 |
+
- The 1280 -> 1024 `decoder.proj` linear is **folded into the encoder output**, so the decoder
|
| 47 |
+
graph sees 1024-dim memories exactly as the contract requires.
|
| 48 |
+
- The HF `CohereAsrDecoder` uses a standard transformers KV cache. The export re-expresses it as
|
| 49 |
+
NeMo-style `decoder_mems` (per-layer pre-layernorm hidden states, `num_layers + 1 = 9` entries),
|
| 50 |
+
which is what the onnx-asr AED decode loop drives.
|
| 51 |
+
|
| 52 |
+
No feature extractor is baked into the graph. `CohereAsrFeatureExtractor` turned out to be the
|
| 53 |
+
standard NeMo log-mel front end — dither 1e-5, preemphasis 0.97, n_fft 512 / win 400 / hop 160,
|
| 54 |
+
symmetric Hann, 128 slaney mels, `log(x + 2**-24)`, per-feature normalisation — so onnx-asr's
|
| 55 |
+
built-in `nemo128` preprocessor already matches it, down to the frame-count formula.
|
| 56 |
+
|
| 57 |
+
## Files
|
| 58 |
+
|
| 59 |
+
| file | size |
|
| 60 |
+
|---|---|
|
| 61 |
+
| `encoder-model.onnx` + `.data` | 7.59 GB |
|
| 62 |
+
| `decoder-model.onnx` | 676 MB |
|
| 63 |
+
| `encoder-model.int8.onnx` + `.data` | 1.91 GB |
|
| 64 |
+
| `decoder-model.int8.onnx` | 170 MB |
|
| 65 |
+
|
| 66 |
+
fp32 total 8.3 GB, int8 total 2.1 GB.
|
| 67 |
+
|
| 68 |
+
## Accuracy
|
| 69 |
+
|
| 70 |
+
Four FLEURS clips (2 en, 2 pt), greedy decoding, against native `transformers` on the same clips.
|
| 71 |
+
|
| 72 |
+
| build | token-identical to native |
|
| 73 |
+
|---|---|
|
| 74 |
+
| fp32 | **4 / 4** |
|
| 75 |
+
| int8 | 2 / 4 |
|
| 76 |
+
|
| 77 |
+
fp32 is exact. int8 dynamic quantisation costs a little accuracy — observed drift is a spurious
|
| 78 |
+
comma and a mis-spelled rare proper noun. Session-swapping shows both graphs contribute (encoder
|
| 79 |
+
int8 alone: 3/4 drift; decoder int8 alone: 2/4 drift), so there is no single subgraph to exclude.
|
| 80 |
+
Use fp32 when accuracy matters and int8 when size matters.
|
| 81 |
+
|
| 82 |
+
Note: onnx-asr's built-in detokeniser drops the space before an opening bracket or quote
|
| 83 |
+
(`sugar(especially`). That is upstream onnx-asr behaviour shared with Canary, not an export
|
| 84 |
+
defect — the token ids are identical.
|
| 85 |
+
|
| 86 |
+
## Speed
|
| 87 |
+
|
| 88 |
+
AMD Ryzen 5 7600 (6 cores / 12 threads), CPU execution provider, `OMP_NUM_THREADS=6`, `nice -n 10`.
|
| 89 |
+
|
| 90 |
+
| clip | duration | fp32 RTF | int8 RTF |
|
| 91 |
+
|---|---|---|---|
|
| 92 |
+
| en_1 | 6.5 s | 0.178 | 0.186 |
|
| 93 |
+
| en_2 | 16.4 s | 0.355 | 0.186 |
|
| 94 |
+
| pt_1 | 11.8 s | 0.348 | 0.214 |
|
| 95 |
+
| pt_2 | 14.6 s | 0.301 | 0.186 |
|
| 96 |
+
| **mean** | | **0.30** | **0.19** |
|
| 97 |
+
|
| 98 |
+
## Scope
|
| 99 |
+
|
| 100 |
+
Single-clip transcription only. The source processor splits audio longer than 35 s at
|
| 101 |
+
low-energy boundaries and stitches the pieces back together; that chunking is not part of this
|
| 102 |
+
export. Feed clips under about 30 s, or segment them yourself.
|
| 103 |
+
|
| 104 |
+
## Attribution
|
| 105 |
+
|
| 106 |
+
Source model and weights: **Cohere Labs**, [CohereLabs/cohere-transcribe-03-2026](https://huggingface.co/CohereLabs/cohere-transcribe-03-2026), Apache-2.0.
|
| 107 |
+
This repository contains only an ONNX conversion; the license is inherited unchanged.
|
REPORT.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# cohere-transcribe-03-2026 -> ONNX export report
|
| 2 |
+
|
| 3 |
+
Date: 2026-08-03. Machine: `192.168.1.200` (AMD Ryzen 5 7600, 6C/12T, 124 GB RAM).
|
| 4 |
+
Staging: `/media/hdd16/onnx-asr-exports/cohere-transcribe-2b/`.
|
| 5 |
+
Venv: `/home/miro/cohere-export-venv` (python 3.12, transformers 5.14.1, torch 2.13.0+cpu,
|
| 6 |
+
onnx 1.22, onnxruntime 1.23, numpy pinned `<2.5` because numba/librosa reject 2.5).
|
| 7 |
+
|
| 8 |
+
## 1. Architecture found
|
| 9 |
+
|
| 10 |
+
Not a speech-LLM. `cohere_asr` is a plain attention encoder-decoder (AED), and specifically a
|
| 11 |
+
NeMo Canary derivative retrained by Cohere Labs.
|
| 12 |
+
|
| 13 |
+
| part | detail |
|
| 14 |
+
|---|---|
|
| 15 |
+
| encoder | `ParakeetEncoderConfig` (NeMo FastConformer). 48 layers, d_model 1280, 8 heads, FFN 5120, SiLU, conv kernel 9, subsampling factor 8, 128 mel bins. ~1.9 B params. |
|
| 16 |
+
| projection | one `nn.Linear(1280, 1024)` at `model.decoder.proj`, applied to encoder states before cross-attention |
|
| 17 |
+
| decoder | 8 layers, d_model 1024, FFN 4096, ReLU, pre-LN, learned `pos_emb` + `embedding_layernorm`, self-attn + cross-attn, untied `proj_out`, vocab 16384. ~0.17 B params |
|
| 18 |
+
| front end | `CohereAsrFeatureExtractor` — standard NeMo log-mel |
|
| 19 |
+
| tokenizer | SentencePiece, 16384 tokens |
|
| 20 |
+
| languages | ar de el en es fr it ja ko nl pl pt vi zh |
|
| 21 |
+
|
| 22 |
+
Evidence of the Canary lineage:
|
| 23 |
+
|
| 24 |
+
- `config.json` is a verbatim NeMo `EncDecMultiTaskModel` config (`preprocessor`, `encoder`,
|
| 25 |
+
`transf_decoder`, `head`, `prompt_format`, `prompt_defaults`).
|
| 26 |
+
- The special-token id block is identical to `istupakov/canary-1b-v2-onnx/vocab.txt`:
|
| 27 |
+
0 `<unk>`, 1 `<|nospeech|>`, 2 `<pad>`, 3 `<|endoftext|>`, 4 `<|startoftranscript|>`,
|
| 28 |
+
5 `<|pnc|>`, 6 `<|nopnc|>`, 7 `<|startofcontext|>`, 8 `<|itn|>`, 9 `<|noitn|>`,
|
| 29 |
+
10 `<|timestamp|>`, 11 `<|notimestamp|>`, 12 `<|diarize|>`, 13 `<|nodiarize|>`.
|
| 30 |
+
- Vocab size 16384, same as Canary.
|
| 31 |
+
- `processing_cohere_asr.get_decoder_prompt_ids("en")` returns
|
| 32 |
+
`[13764, 7, 4, 16, 62, 62, 5, 9, 11, 13]`, where 13764 is `_`. That is token-for-token
|
| 33 |
+
`NemoConformerAED._transcribe_input` in onnx-asr.
|
| 34 |
+
|
| 35 |
+
## 2. Runtime changes
|
| 36 |
+
|
| 37 |
+
**None.** `onnx-asr` `main` (both our fork and upstream) already registers `nemo-conformer-aed`
|
| 38 |
+
and the `nemo128` preprocessor. No branch was created and no repo file was touched.
|
| 39 |
+
|
| 40 |
+
The feature extractor did not need baking into the graph. `CohereAsrFeatureExtractor` matches
|
| 41 |
+
`NemoPreprocessorNumpy` / `nemo128.onnx` on every constant that matters:
|
| 42 |
+
|
| 43 |
+
| | Cohere FE | onnx-asr nemo |
|
| 44 |
+
|---|---|---|
|
| 45 |
+
| preemphasis | 0.97, padding masked | 0.97, padding masked |
|
| 46 |
+
| n_fft / win / hop | 512 / 400 / 160 | 512 / 400 / 160 |
|
| 47 |
+
| window | `torch.hann_window(400, periodic=False)` | `np.hanning(400)` (same symmetric window) |
|
| 48 |
+
| centering | `center=True`, `pad_mode="constant"` | explicit zero pad of `n_fft//2` |
|
| 49 |
+
| mels | librosa slaney, 128, fmin 0, fmax 8000 | `melscale_fbanks(..., "slaney", "slaney")`, 128 |
|
| 50 |
+
| log guard | `2**-24` | `2**-24` |
|
| 51 |
+
| normalisation | per-feature, `n-1` variance, `+1e-5` | per-feature, `n-1` variance, `+1e-5` |
|
| 52 |
+
| frame count | `(L + 2*(n_fft//2) - n_fft) // hop` | `L // hop` (algebraically identical) |
|
| 53 |
+
|
| 54 |
+
Only difference: Cohere applies a seeded dither of 1e-5 that onnx-asr omits. Empirically it
|
| 55 |
+
changes nothing — fp32 output is token-identical on every clip tested.
|
| 56 |
+
|
| 57 |
+
## 3. Graph contract
|
| 58 |
+
|
| 59 |
+
Matches `istupakov/canary-1b-v2-onnx` exactly, so the stock decode loop drives it unmodified.
|
| 60 |
+
|
| 61 |
+
```
|
| 62 |
+
encoder-model.onnx
|
| 63 |
+
in : audio_signal [batch, 128, seq_len] f32
|
| 64 |
+
length [batch] i64
|
| 65 |
+
out: encoder_embeddings [batch, encoded_len, 1024] f32
|
| 66 |
+
encoder_mask [batch, encoded_len] i64
|
| 67 |
+
|
| 68 |
+
decoder-model.onnx
|
| 69 |
+
in : input_ids [batch, input_len] i64
|
| 70 |
+
encoder_embeddings [batch, encoded_len, 1024] f32
|
| 71 |
+
encoder_mask [batch, encoded_len] i64
|
| 72 |
+
decoder_mems [9, batch, mems_len, 1024] f32
|
| 73 |
+
out: logits [batch, input_len, 16384] f32, log-softmax
|
| 74 |
+
decoder_hidden_states [9, batch, mems_len + input_len, 1024] f32
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
Two export decisions:
|
| 78 |
+
|
| 79 |
+
1. `model.decoder.proj` (1280 -> 1024) is folded into the encoder wrapper's output. The contract
|
| 80 |
+
fixes the memory width at 1024; Cohere's encoder is 1280 wide. Folding is the only way to keep
|
| 81 |
+
the decoder graph unchanged.
|
| 82 |
+
2. HF's `EncoderDecoderCache` is re-expressed as NeMo `decoder_mems`: element *i* holds the
|
| 83 |
+
pre-layernorm hidden states entering layer *i*, element 0 is the embedding output, and there
|
| 84 |
+
are `num_layers + 1 = 9` of them (Canary has 10 because it has 9 layers; the runtime reads the
|
| 85 |
+
count from the graph, so this is fine). Because LayerNorm is per-position,
|
| 86 |
+
`LN(concat(past, new)) == concat(LN(past), LN(new))`, so caching pre-LN states is exact.
|
| 87 |
+
|
| 88 |
+
Cross-attention K/V are recomputed from `encoder_embeddings` each step, as in the Canary export.
|
| 89 |
+
|
| 90 |
+
`config.json` shipped alongside is just `{"model_type": "nemo-conformer-aed", "features_size": 128}`.
|
| 91 |
+
`vocab.txt` is written in onnx-asr's `"<token> <id>"` form with raw SentencePiece `_`; the loader
|
| 92 |
+
maps `_` to a space, which is what makes `self._tokens[" "]` resolve to 13764.
|
| 93 |
+
|
| 94 |
+
## 4. Parity
|
| 95 |
+
|
| 96 |
+
Clips: 4 FLEURS clips copied from the qwen3-asr export (`en_1`, `en_2`, `pt_1`, `pt_2`).
|
| 97 |
+
Both English and Portuguese are in the model's 14 supported languages.
|
| 98 |
+
|
| 99 |
+
**Stage 1 — torch wrappers vs native `model.generate`** (proves the mems rewrite before ONNX
|
| 100 |
+
enters the picture): 4 / 4 character-exact.
|
| 101 |
+
|
| 102 |
+
**Stage 2 — ONNX fp32 through stock onnx-asr vs native, compared at the token-id level:**
|
| 103 |
+
|
| 104 |
+
| clip | tokens | identical |
|
| 105 |
+
|---|---|---|
|
| 106 |
+
| en_1 | 18 | yes |
|
| 107 |
+
| en_2 | 69 | yes |
|
| 108 |
+
| pt_1 | 41 | yes |
|
| 109 |
+
| pt_2 | 54 | yes |
|
| 110 |
+
|
| 111 |
+
**4 / 4 token-identical.** Target met.
|
| 112 |
+
|
| 113 |
+
The rendered strings differ from native in one respect only: onnx-asr's detokeniser regex
|
| 114 |
+
`\A\s|\s\B|(\s)\b` drops a space before an opening bracket or quote, giving `sugar(especially`
|
| 115 |
+
and `como"squimbans"`. Token ids are identical, so this is upstream onnx-asr behaviour shared
|
| 116 |
+
with Canary, not an export defect.
|
| 117 |
+
|
| 118 |
+
**Stage 3 — int8:** 2 / 4 token-identical. Drift seen:
|
| 119 |
+
|
| 120 |
+
- `en_1`: a spurious comma (`miles away, you are`)
|
| 121 |
+
- `pt_2`: `"squimbans"` -> `"squimãs"`
|
| 122 |
+
|
| 123 |
+
Session-swap isolation:
|
| 124 |
+
|
| 125 |
+
| build | clips differing from ONNX fp32 |
|
| 126 |
+
|---|---|
|
| 127 |
+
| encoder int8 + decoder fp32 | 3 / 4 |
|
| 128 |
+
| encoder fp32 + decoder int8 | 2 / 4 |
|
| 129 |
+
| both int8 | 2 / 4 (errors partially cancel) |
|
| 130 |
+
|
| 131 |
+
Both graphs contribute; there is no single offending subgraph to exclude from quantisation (and
|
| 132 |
+
no in-graph feature extractor here, since the FE stayed external). int8 is shipped with the
|
| 133 |
+
accuracy caveat documented rather than suppressed.
|
| 134 |
+
|
| 135 |
+
## 5. Speed
|
| 136 |
+
|
| 137 |
+
AMD Ryzen 5 7600 (6C/12T), CPUExecutionProvider, `OMP_NUM_THREADS=6`, `nice -n 10`, one warm-up
|
| 138 |
+
pass discarded.
|
| 139 |
+
|
| 140 |
+
| clip | duration | fp32 RTF | int8 RTF |
|
| 141 |
+
|---|---|---|---|
|
| 142 |
+
| en_1 | 6.54 s | 0.178 | 0.186 |
|
| 143 |
+
| en_2 | 16.38 s | 0.355 | 0.186 |
|
| 144 |
+
| pt_1 | 11.82 s | 0.348 | 0.214 |
|
| 145 |
+
| pt_2 | 14.58 s | 0.301 | 0.186 |
|
| 146 |
+
| mean | | 0.30 | 0.19 |
|
| 147 |
+
|
| 148 |
+
int8 is roughly 1.6x faster on the longer clips. On the shortest clip the two are within noise.
|
| 149 |
+
|
| 150 |
+
## 6. Sizes
|
| 151 |
+
|
| 152 |
+
| artifact | bytes |
|
| 153 |
+
|---|---|
|
| 154 |
+
| `encoder-model.onnx` | 1 794 752 |
|
| 155 |
+
| `encoder-model.onnx.data` | 7 586 112 512 |
|
| 156 |
+
| `decoder-model.onnx` | 676 100 265 |
|
| 157 |
+
| `encoder-model.int8.onnx` | 3 239 179 |
|
| 158 |
+
| `encoder-model.int8.onnx.data` | 1 902 071 040 |
|
| 159 |
+
| `decoder-model.int8.onnx` | 169 764 577 |
|
| 160 |
+
| `vocab.txt` | 207 437 |
|
| 161 |
+
|
| 162 |
+
fp32 8.26 GB, int8 2.08 GB.
|
| 163 |
+
|
| 164 |
+
## 7. Deviations and known limits
|
| 165 |
+
|
| 166 |
+
- **Long audio is out of scope.** `CohereAsrFeatureExtractor` splits anything over 35 s at
|
| 167 |
+
low-energy boundaries (5 s search window) and `CohereAsrProcessor.decode` restitches the
|
| 168 |
+
pieces. onnx-asr has no equivalent hook, so this export handles single clips only. Documented
|
| 169 |
+
in the model card.
|
| 170 |
+
- **int8 is not exact** — see section 4. fp32 is the accuracy build.
|
| 171 |
+
- **Detokeniser spacing** around opening brackets/quotes, inherited from onnx-asr.
|
| 172 |
+
- **Beam search not exported.** The source `config.json` asks for `beam_size: 1`, i.e. greedy, so
|
| 173 |
+
the onnx-asr greedy loop is faithful to the shipped decoding config.
|
| 174 |
+
- **Upstream packaging bug spotted in passing:** the `onnx-asr` 0.12.0 wheel on PyPI is not
|
| 175 |
+
importable. Its `loader.py` does `from onnx_asr.models.speech_llm import SpeechLlm` and
|
| 176 |
+
`from onnx_asr.models.wav2vec2 import Wav2Vec2Ctc`, but neither module is in the wheel's
|
| 177 |
+
RECORD. Testing here was done against our fork's `main` instead. Worth reporting upstream.
|
| 178 |
+
- **HF token vs HF_HOME:** with `HF_HOME=/media/hdd16/amalia-hf-cache` the token at
|
| 179 |
+
`~/.cache/huggingface/token` is not found. Remote shells need
|
| 180 |
+
`export HF_TOKEN=$(cat ~/.cache/huggingface/token)` as well.
|
| 181 |
+
- The source repo is **gated** (`gated: "auto"`). A human had to accept the terms as `Jarbas`
|
| 182 |
+
before anything could be downloaded.
|
| 183 |
+
|
| 184 |
+
## 8. Scripts
|
| 185 |
+
|
| 186 |
+
Kept in `/home/miro/` on `.200`:
|
| 187 |
+
|
| 188 |
+
- `export_cohere_asr.py` — the two graph wrappers and the export driver
|
| 189 |
+
- `verify_torch.py` — stage-1 torch equivalence
|
| 190 |
+
- `verify_onnx_cohere.py` — text + RTF through stock onnx-asr
|
| 191 |
+
- `tokencmp.py` — token-id parity, native vs ONNX
|
| 192 |
+
- `mixcmp.py` — session-swap isolation
|
| 193 |
+
- `consolidate.py` — collapse the encoder's loose external tensors into `encoder-model.onnx.data`
|
| 194 |
+
- `quantize.py` — dynamic int8
|
| 195 |
+
|
| 196 |
+
## 9. Published
|
| 197 |
+
|
| 198 |
+
`OpenVoiceOS/cohere-transcribe-2b-onnx`, Apache-2.0, attribution to Cohere Labs.
|
| 199 |
+
Added to collection `OpenVoiceOS/stt-asr-onnx-699321e8732462509c642fbe`.
|
config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "nemo-conformer-aed",
|
| 3 |
+
"features_size": 128
|
| 4 |
+
}
|
decoder-model.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:27f798f1df6aa7c64cdf9a79b1151a3745b8aac0a9da4e42186e073358733618
|
| 3 |
+
size 169764577
|
decoder-model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be826a79ec81c90217b3742de9f915aa9f77dea808b5705814c6cf1da510402f
|
| 3 |
+
size 676100265
|
encoder-model.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c679e2423ede014219ad0ce555d863a9e3cd36fc08ce9f1fb761958a9417de8a
|
| 3 |
+
size 3239179
|
encoder-model.int8.onnx.data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:13da58e80b5989b0e3e39a02b0b216c62a7d61677660122cbff81d95dbc8c26b
|
| 3 |
+
size 1902071040
|
encoder-model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:26aafa10446f753498667c20089acf8679c8526dbf3beb2d6793d2b016af7e39
|
| 3 |
+
size 1794752
|
encoder-model.onnx.data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b5cde4b754acb8071c286804b8cb1e48d193bdd99d61073b200b39e3107d3a6e
|
| 3 |
+
size 7586112512
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|