fihria commited on
Commit
fbdfd7c
·
verified ·
1 Parent(s): 9678c86

Address round-2 review (self-contained manual loop, max_new_tokens=64, CUDA/vLLM/footprint notes)

Browse files
Files changed (1) hide show
  1. README.md +24 -10
README.md CHANGED
@@ -28,7 +28,7 @@ unified protocol, the family is built for robust, real-world transcription:
28
  optimized for local linguistic structures.
29
  - **Tiered performance profile:**
30
  - **0.6B:** optimized for lightweight edge deployment and real-time execution on standard
31
- laptop CPUs.
32
  - **1.7B:** engineered as the high-accuracy ceiling and setting up a new SOTA for
33
  open-weight Darija ASR models.
34
 
@@ -106,18 +106,23 @@ machines, use the [GGUF build](https://huggingface.co/fihriaLab/fihrIA-ASR-1.7B-
106
 
107
  ```bash
108
  pip install qwen-asr==0.0.6
109
- # or, with the vLLM backend:
110
  # pip install "qwen-asr[vllm]==0.0.6"
111
  ```
112
 
113
- `qwen-asr==0.0.6` pulls the default PyPI PyTorch CUDA build along with several hundred MB of
114
- dependencies (`gradio`, `flask`, `pydub`, etc.), and pins `transformers==4.57.6`. That version of
115
- `transformers` does not include the `qwen3_asr` architecture — `qwen-asr` registers it on import,
116
- so load the model through `qwen_asr` rather than bare `transformers`.
 
 
 
 
117
 
118
  ## Quick start
119
 
120
- First fetch the bundled sample clip (or point `audio` at your own WAV/MP3/FLAC file):
 
121
 
122
  ```bash
123
  hf download fihriaLab/fihrIA-ASR-1.7B sample.wav --local-dir .
@@ -135,7 +140,7 @@ model = Qwen3ASRModel.from_pretrained(
135
  device_map="cuda:0",
136
  # attn_implementation="flash_attention_2",
137
  max_inference_batch_size=32,
138
- max_new_tokens=512,
139
  )
140
 
141
  res = model.transcribe(
@@ -156,6 +161,9 @@ print(text) # التلفون ديالي طاح وتهرس ليه l'écran (exa
156
  > - **Forcing Darija:** Always use `language=None` for Darija. `qwen-asr==0.0.6`'s built-in
157
  > `SUPPORTED_LANGUAGES` list predates Darija, so passing `language="Darija"` raises `ValueError`
158
  > (forcing other listed languages such as `"Arabic"` works and populates `res.language`).
 
 
 
159
 
160
  `audio` accepts a local path, a URL, a base64 data URL, a `(np.ndarray, sample_rate)` tuple, or
161
  a list of any of these. Audio should be 16 kHz mono; other rates are resampled.
@@ -181,13 +189,19 @@ than `\S+` — otherwise the first Arabic word is swallowed into the language fi
181
 
182
  ## Manual `transformers` loop
183
 
184
- For prompt control or batched decoding without `Qwen3ASRModel`:
185
 
186
  ```python
187
- import torch, soundfile as sf
188
  import qwen_asr # registers qwen3_asr
189
  from transformers import AutoProcessor, AutoModel
190
 
 
 
 
 
 
 
191
  mid = "fihriaLab/fihrIA-ASR-1.7B"
192
  processor = AutoProcessor.from_pretrained(mid)
193
  model = AutoModel.from_pretrained(mid, dtype=torch.bfloat16, device_map="cuda:0")
 
28
  optimized for local linguistic structures.
29
  - **Tiered performance profile:**
30
  - **0.6B:** optimized for lightweight edge deployment and real-time execution on standard
31
+ laptop CPUs (via the [GGUF build](https://huggingface.co/fihriaLab/fihrIA-ASR-0.6B-GGUF)).
32
  - **1.7B:** engineered as the high-accuracy ceiling and setting up a new SOTA for
33
  open-weight Darija ASR models.
34
 
 
106
 
107
  ```bash
108
  pip install qwen-asr==0.0.6
109
+ # or, in a separate virtualenv for the vLLM backend:
110
  # pip install "qwen-asr[vllm]==0.0.6"
111
  ```
112
 
113
+ Budget **~6 GB on disk** for the virtualenv: `qwen-asr==0.0.6` pulls the default PyPI PyTorch CUDA
114
+ build (CUDA 13.2 wheels + NVIDIA libraries; if your driver is on CUDA 12, install a matching
115
+ PyTorch wheel from [pytorch.org](https://pytorch.org/get-started/locally/) first) along with
116
+ `transformers==4.57.6` and UI/audio dependencies (`gradio`, `flask`, `pydub`, etc.). Note that
117
+ `qwen-asr[vllm]==0.0.6` pins `vllm==0.14.0` (which pulls `torch==2.9.x` / CUDA 12 libraries), so
118
+ use a fresh virtualenv per backend. Because `transformers==4.57.6` does not include the `qwen3_asr`
119
+ architecture, `qwen-asr` registers it on import — load the model through `qwen_asr` rather than
120
+ bare `transformers`.
121
 
122
  ## Quick start
123
 
124
+ First fetch the bundled sample clip (or point `audio` at your own WAV/MP3/FLAC file); the first
125
+ `from_pretrained()` call downloads ~3.82 GB of model weights:
126
 
127
  ```bash
128
  hf download fihriaLab/fihrIA-ASR-1.7B sample.wav --local-dir .
 
140
  device_map="cuda:0",
141
  # attn_implementation="flash_attention_2",
142
  max_inference_batch_size=32,
143
+ max_new_tokens=64, # ample for this 3 s clip; raise for longer audio (see EOS note below)
144
  )
145
 
146
  res = model.transcribe(
 
161
  > - **Forcing Darija:** Always use `language=None` for Darija. `qwen-asr==0.0.6`'s built-in
162
  > `SUPPORTED_LANGUAGES` list predates Darija, so passing `language="Darija"` raises `ValueError`
163
  > (forcing other listed languages such as `"Arabic"` works and populates `res.language`).
164
+ > - **`max_new_tokens` & EOS:** `transcribe()` decodes all `max_new_tokens` steps due to an
165
+ > upstream EOS-id mismatch (see [Known limitations](#known-limitations)), so keeping
166
+ > `max_new_tokens` tight for short clips avoids wasted decode steps.
167
 
168
  `audio` accepts a local path, a URL, a base64 data URL, a `(np.ndarray, sample_rate)` tuple, or
169
  a list of any of these. Audio should be 16 kHz mono; other rates are resampled.
 
189
 
190
  ## Manual `transformers` loop
191
 
192
+ For prompt control or batched decoding without `Qwen3ASRModel` (self-contained):
193
 
194
  ```python
195
+ import re, torch, soundfile as sf
196
  import qwen_asr # registers qwen3_asr
197
  from transformers import AutoProcessor, AutoModel
198
 
199
+ ASR_RE = re.compile(r"language\s+([A-Za-z]+)\s*(?:<asr_text>)?\s*(.*)", re.DOTALL)
200
+
201
+ def parse(raw: str) -> tuple[str | None, str]:
202
+ m = ASR_RE.search(raw.strip())
203
+ return (m.group(1), m.group(2).strip()) if m else (None, raw.strip())
204
+
205
  mid = "fihriaLab/fihrIA-ASR-1.7B"
206
  processor = AutoProcessor.from_pretrained(mid)
207
  model = AutoModel.from_pretrained(mid, dtype=torch.bfloat16, device_map="cuda:0")