Rlamas commited on
Commit
41dc96f
·
verified ·
1 Parent(s): a7729b5

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +193 -0
README.md ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - ar
5
+ - en
6
+ pipeline_tag: automatic-speech-recognition
7
+ library_name: transformers
8
+ tags:
9
+ - audio
10
+ - speech-recognition
11
+ - transcription
12
+ - arabic
13
+ - asr
14
+ - arabic-asr
15
+ - arabic-dialect
16
+ - jordanian-arabic
17
+ - cohere_asr
18
+ base_model:
19
+ - CohereLabs/cohere-transcribe-arabic-07-2026
20
+ ---
21
+
22
+ # Cohere Jordanian Dialect
23
+
24
+ **Cohere Jordanian Dialect is a full fine-tune of [`CohereLabs/cohere-transcribe-arabic-07-2026`](https://huggingface.co/CohereLabs/cohere-transcribe-arabic-07-2026), specialized for Jordanian dialectal Arabic speech-to-text transcription.** It is a 2B-parameter Conformer encoder / Transformer decoder ASR model, fine-tuned end-to-end to substantially improve accuracy on Jordanian dialect audio over the base checkpoint.
25
+
26
+ This repository is self-contained — it includes the fine-tuned weights plus all processor/tokenizer files needed to run it directly, with no dependency on the base repo at load time.
27
+
28
+ | Name | **Cohere-Jordanian-Dialect** |
29
+ | --- | --- |
30
+ | Base model | [CohereLabs/cohere-transcribe-arabic-07-2026](https://huggingface.co/CohereLabs/cohere-transcribe-arabic-07-2026) |
31
+ | Architecture | Conformer encoder + Transformer decoder |
32
+ | Fine-tuning method | Full fine-tune |
33
+ | Input | Audio waveform → log-Mel spectrogram, auto-resampled to 16kHz, stereo averaged to mono |
34
+ | Output | Transcribed text, no digits at all |
35
+ | Languages | Arabic (Jordanian dialect focus), English |
36
+ | License | Apache 2.0 |
37
+
38
+ ## Quick Start
39
+
40
+ ```bash
41
+ pip install "transformers==5.13.0" torch huggingface_hub soundfile librosa sentencepiece protobuf accelerate
42
+ ```
43
+
44
+ > **Note:** `transformers` must be pinned to **5.13.0** — later (5.15.0+) and earlier versions are not supported.
45
+
46
+ You'll also need a Hugging Face access token (read access) and to have accepted the terms on the [base model page](https://huggingface.co/CohereLabs/cohere-transcribe-arabic-07-2026) before downloading, since the fine-tune derives from that gated repo.
47
+
48
+ ```python
49
+ from huggingface_hub import login
50
+ login() # paste your HF token (needs read access)
51
+
52
+ from transformers import AutoProcessor, CohereAsrForConditionalGeneration
53
+ from transformers.audio_utils import load_audio
54
+
55
+ MODEL_ID = "Rlamas/Cohere-Jordanian-Dialect"
56
+
57
+ processor = AutoProcessor.from_pretrained(MODEL_ID)
58
+ model = CohereAsrForConditionalGeneration.from_pretrained(MODEL_ID, device_map="auto")
59
+
60
+ # Transcribe Jordanian Arabic audio
61
+ audio_file = "your_audio.wav"
62
+ audio = load_audio(audio_file, sampling_rate=16000)
63
+
64
+ inputs = processor(audio, sampling_rate=16000, return_tensors="pt", language="ar")
65
+ inputs.to(model.device, dtype=model.dtype)
66
+
67
+ outputs = model.generate(**inputs, max_new_tokens=256)
68
+ text = processor.decode(outputs, skip_special_tokens=True)
69
+ print(text)
70
+ ```
71
+
72
+ ## Architecture
73
+
74
+ The model is composed of four main stages, plus an 8-bit optimizer used during fine-tuning:
75
+
76
+ 1. **Audio feature extractor** — converts raw audio into normalized mel-spectrogram features.
77
+ 2. **Audio encoder** — a Conformer stack that processes mel-spectrogram features through multiple attention layers to extract acoustic patterns, compressing the sequence length for faster, more efficient downstream processing.
78
+ 3. **Prompt injector** — specifies language, punctuation/capitalization, and inverse text normalization, controlling output style and task mode.
79
+ 4. **Text decoder** — a lightweight Transformer decoder that translates the extracted audio features directly into Arabic text tokens.
80
+ 5. **8-bit optimizer** (training only) — quantizes optimizer states from 32-bit to 8-bit via `bitsandbytes`, reducing GPU memory needs during fine-tuning.
81
+
82
+ ## Training
83
+
84
+ ### Learning rate sweep
85
+
86
+ A sweep was run over `[5e-6, 1e-5, 2e-5, 5e-5]`, three epochs each, ranked by best CER:
87
+
88
+ | LR | Base CER | Best CER | Best Epoch | Beat Baseline | Val Loss |
89
+ | --- | --- | --- | --- | --- | --- |
90
+ | 5e-5 | 0.156 | **0.0879** | 2.0 | ✅ | 0.2163 |
91
+ | 2e-5 | 0.156 | 0.1204 | 2.0 | ✅ | 0.3259 |
92
+ | 1e-5 | 0.156 | 0.1447 | 2.0 | ✅ | 0.6875 |
93
+ | 5e-6 | 0.156 | 0.1532 | 2.0 | ✅ | 0.8834 |
94
+
95
+ **Winner:** `lr=5e-5`, best CER 0.0879 / WER 0.2266 at epoch 2.
96
+
97
+ ### Final training run
98
+
99
+ The winning learning rate (5e-5) was used for a longer run — 5 epochs was insufficient for the model to stabilize, so training was extended to 8 epochs.
100
+
101
+ **Hardware**
102
+ - GPU: NVIDIA L40S ($2.62/hr)
103
+ - CPU: 2 cores
104
+ - RAM: 16 GB
105
+
106
+ **Hyperparameters**
107
+ - Learning rate: 5e-5
108
+ - Batch size / gradient accumulation: batch size 8, 16 accumulation steps (effective batch size 128)
109
+ - Optimizer: `adamw_bnb_8bit`
110
+ - Precision: BFloat16
111
+ - Epochs / warmup: 8 epochs, warmup rate 0.05
112
+ - Weight decay: 0.01
113
+ - Gradient checkpointing: enabled
114
+
115
+ **Training time:** 1 hour 28 minutes.
116
+
117
+ ## Results
118
+
119
+ Evaluated on held-out test data using CER/WER from the `jiwer` library.
120
+
121
+ | Metric | Baseline (base model) | Full fine-tune (this model) |
122
+ | --- | --- | --- |
123
+ | CER | 0.156 | **0.0783** |
124
+ | WER | 0.350 | **0.1899** |
125
+
126
+ Full fine-tuning delivered a clear accuracy gain on Jordanian dialect audio over the baseline.
127
+
128
+ ## Inference Speed
129
+
130
+ Measured on 10 random records using 1 CPU core, 4GB RAM, and an NVIDIA T4 GPU:
131
+
132
+ - **Mean RTF:** 0.2156
133
+ - **Median RTF:** 0.1812
134
+
135
+ This model does not currently support streaming inference.
136
+
137
+ ## Production Deployment
138
+
139
+ As with the base model, [Cohere's model card](https://huggingface.co/CohereLabs/cohere-transcribe-arabic-07-2026) recommends serving via vLLM for production, which exposes an OpenAI-compatible `/v1/audio/transcriptions` HTTP endpoint — usable with any client built against the OpenAI Whisper transcription API.
140
+
141
+ ## The Test Data
142
+ The test data comes from a different category/sector than the training data. It contains different speakers and covers different topics, so the results could be better if the model were evaluated on data from the same domain.
143
+
144
+ Keep this in mind when looking at the limitations
145
+
146
+ ## Limitations & Failure Modes
147
+
148
+ **Over-generation & repetition loops.** On long clips, or clips with extended pauses/background noise, the decoder can enter token repetition loops — a known failure mode for autoregressive sequence-to-sequence ASR models.
149
+
150
+ Reference was an audio full of static
151
+
152
+ Hypothesis: هاد بدك تدق لا أنا بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدق على الخلطة بدك تدقق على الخلطة بدك تدقق
153
+
154
+ **Single-word audio.** Short, single-word clips are prone to misrecognition:
155
+
156
+ | Reference | Hypothesis |
157
+ | --- | --- |
158
+ | الاعرج | شو العارف |
159
+ | باسم | اه اسمع |
160
+ | مرحبا | بنمرح بعض |
161
+ | نعم | لا |
162
+
163
+ **Code-switching / full-English audio.** The model can mistranslate or transliterate English audio instead of transcribing it directly:
164
+
165
+ | Reference | Hypothesis |
166
+ | --- | --- |
167
+ | for english press two or enter the extension n… | فور انجلش اضغط 2 أو أنتر الأكستنشن نمبر الآن |
168
+ | الcross road | الكروس رود |
169
+
170
+ ## When to Use This Model
171
+
172
+ **Good fit:** offline, batch transcription of long-form Jordanian dialect Arabic audio, where high accuracy (7.8% CER / 18.9% WER) on custom domain data is required and low training overhead matters — this model fully fine-tunes in under 1.5 hours on a single L40S GPU using 8-bit optimization.
173
+
174
+ **Poor fit:** real-time conversational streaming, ultra-low-latency applications, or use cases needing word-level timestamps. Its non-streaming autoregressive decoder makes production serving slower and more expensive to scale than streaming CTC or FastConformer alternatives (e.g. Nemotron).
175
+
176
+ ## Future Work
177
+
178
+ To further reduce CER/WER, additional training data targeted specifically at the failure modes above (repetition loops on long/noisy audio, single-word utterances, and code-switched/English audio) is recommended.
179
+
180
+ ## Citation
181
+
182
+ This model is a fine-tune of Cohere Transcribe Arabic. Please cite the base model:
183
+
184
+ ```bibtex
185
+ @misc{shaun_cassini_2026,
186
+ author = { Shaun Cassini and Sebastian Vincent and Xiaolu Lu and Julian Mack and Dhruti Joshi and Pierre Richemond },
187
+ title = { cohere-transcribe-arabic-07-2026 (Revision 0a8193c) },
188
+ year = 2026,
189
+ url = { https://huggingface.co/CohereLabs/cohere-transcribe-arabic-07-2026 },
190
+ doi = { 10.57967/hf/9549 },
191
+ publisher = { Hugging Face }
192
+ }
193
+ ```