Santosh-bold commited on
Commit
3d53559
·
verified ·
1 Parent(s): c11c129

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +81 -0
README.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - ASR
6
+ - SpeechLM
7
+ - MLX
8
+ - Audio
9
+ - Transcription
10
+ - Qwen
11
+ license: apache-2.0
12
+ ---
13
+
14
+ # NVIDIA Canary-SpeechLM (MLX Port)
15
+
16
+ This repository contains the pure MLX port of the NVIDIA Canary SpeechLM model (`canary-qwen-2.5b`).
17
+
18
+ By porting the model architecture to MLX (including Conformer block, relative attention layer, and projection layers), this version runs **100% locally on Apple Silicon with zero PyTorch dependencies at inference time**.
19
+
20
+ ## Features
21
+
22
+ - **No PyTorch at Inference:** Pure MLX implementation for optimal performance and memory on macOS.
23
+ - **Fast Transcription:** RTF of **0.067x** (runs **14.8x** faster than real-time on Apple Silicon).
24
+ - **High-Fidelity Alignment:** Intermediate outputs are validated to match PyTorch/NeMo reference feature maps within float16/float32 precision limits.
25
+
26
+ ## Performance Statistics
27
+
28
+ Measurements taken on Apple Silicon (M5 Pro):
29
+ - **Audio Duration:** 3.88s
30
+ - **Feature Extraction + Conformer Encoding:** 0.0506s
31
+ - **Prefill/Time-to-First-Token (TTFT):** 0.0247s (2551.55 tok/s)
32
+ - **Decode Loop Generation Speed:** **58.99 tok/s** (up to **80.71 tok/s** raw)
33
+ - **Real-Time Factor (RTF):** **0.0674x** (14.8x faster than real-time)
34
+
35
+ ---
36
+
37
+ ## Installation & Setup
38
+
39
+ 1. Clone this repository:
40
+ ```bash
41
+ git clone https://huggingface.co/speechllms/canary-speechlm-mlx
42
+ cd canary-speechlm-mlx
43
+ ```
44
+
45
+ 2. Install dependencies:
46
+ ```bash
47
+ pip install mlx mlx-lm librosa transformers soundfile
48
+ ```
49
+
50
+ 3. Ensure you have the base Qwen3-1.7B model downloaded (which contains the base tokenizer and weights):
51
+ ```bash
52
+ python -c "from huggingface_hub import snapshot_download; snapshot_download('Qwen/Qwen3-1.7B')"
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Quick Usage
58
+
59
+ Run transcription directly from a WAV file:
60
+
61
+ ```bash
62
+ python generate.py /path/to/audio.wav
63
+ ```
64
+
65
+ ### Record & Transcribe from Microphone
66
+ If you have `ffmpeg` installed on your Mac (`brew install ffmpeg`), you can run the interactive recording script:
67
+
68
+ ```bash
69
+ chmod +x record_and_transcribe.sh
70
+ ./record_and_transcribe.sh
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Technical Details
76
+
77
+ The port translates:
78
+ 1. `ConvSubsampling` 8x downsampling module.
79
+ 2. Conformer Block featuring depthwise 1D convolutions and relative multi-head self-attention.
80
+ 3. Transformer-XL dynamic Relative Positional Encoding (`RelPositionalEncoding`).
81
+ 4. LoRA adapter weight overlay on top of Qwen Causal LM.