Instructions to use touati-kamel/whisper-algerian-darja-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use touati-kamel/whisper-algerian-darja-small with PEFT:
Task type is invalid.
- Transformers
How to use touati-kamel/whisper-algerian-darja-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="touati-kamel/whisper-algerian-darja-small")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("touati-kamel/whisper-algerian-darja-small", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Configuration Parsing Warning:In adapter_config.json: "peft.task_type" must be a string
- Whisper Algerian Arabic (Darja / الدارجة الجزائرية) — Small & Medium ASR Suite
Whisper Algerian Arabic (Darja / الدارجة الجزائرية) — Small & Medium ASR Suite
Overview
This repository contains the evaluation benchmarks, inference code, and interactive Streamlit comparison application for fine-tuned Automatic Speech Recognition (ASR) models for Algerian Arabic (Darja / الدارجة الجزائرية):
touati-kamel/whisper-algerian-darja-medium(SOTA — 833M Parameters, 69.2M LoRA)touati-kamel/whisper-algerian-darja-small(Lightweight — 267M Parameters, 25.9M LoRA)
Both models were adapted from OpenAI Whisper via 4-bit quantized Low-Rank Adaptation (QLoRA) across a 3-phase sequential streaming curriculum covering conversational podcasts, spontaneous expressive storytelling, and cultural narratives from the OddAdmix Algerian speech collection.
Comprehensive Benchmark & Performance Matrix
The models were evaluated iteratively across three distinct Algerian dialect audio domains using Word Error Rate (WER %) and Cross-Entropy Loss with standardized Arabic text normalization:
| Domain / Benchmark Split | Dataset Identifier | Whisper Small (267M) WER | Whisper Medium (833M) WER | Relative Error Reduction |
|---|---|---|---|---|
| Loubna Expressive Stories | oddadmix/arabic-audio-collection-algerian-loubna-stories |
14.87% | 0.34% | -97.7% |
| Kahwa Conversational Podcast | oddadmix/arabic-audio-collection-algerian-kahwa-postcast |
34.85% | 0.68% | -98.0% |
| Rawi Cultural Storytelling | oddadmix/arabic-audio-collection-algerian-rawi |
27.54% | 0.95% | -96.5% |
| Final Evaluation Loss | — | 0.2548 | 0.00612 | -97.6% |
Model Architecture Specifications
| Specification | Whisper Small (openai/whisper-small) |
Whisper Medium (openai/whisper-medium) |
|---|---|---|
| Total Model Weights | 267,687,168 | 833,063,936 |
| Trainable LoRA Weights | 25,952,256 (9.70%) | 69,206,016 (8.31%) |
| Transformer Layers | 12 Encoder / 12 Decoder | 24 Encoder / 24 Decoder |
| Attention Heads | 12 heads | 16 heads |
| LoRA Target Modules | q_proj, k_proj, v_proj, out_proj, fc1, fc2 |
q_proj, k_proj, v_proj, out_proj, fc1, fc2 |
| LoRA Hyperparameters | $r=64, \alpha=128, \text{dropout}=0.05$ | $r=64, \alpha=128, \text{dropout}=0.05$ |
| Quantization | 4-bit NormalFloat4 (NF4) | 4-bit NormalFloat4 (NF4) |
| Effective Batch Size | 32 (8 per device × 4 grad accum) | 32 (4 per device × 8 grad accum) |
| Cumulative Optimization Steps | 15,829 steps | 31,661 steps |
Sequential Curriculum Learning Methodology
┌────────────────────────────────────────────────────────┐
│ OpenAI Whisper (Small / Medium) │
│ (4-bit NF4 Quantization Base) │
└──────────────────────────┬─────────────────────────────┘
│
┌─────────────┴─────────────┐
│ LoRA Adapters (r=64) │
│ Target: q, k, v, out, │
│ fc1, fc2 │
└─────────────┬─────────────┘
│
┌────────────────────┴────────────────────┐
│ Sequential Curriculum Learning │
├─────────────────────────────────────────┤
│ Phase 1: Kahwa Podcast (Conversational) │
│ • Small: 4,942 steps | Med: 9,886 steps│
│ ▼ │
│ Phase 2: Loubna Stories (Expressive) │
│ • Small: 10,324 steps| Med: 20,650 step│
│ ▼ │
│ Phase 3: Rawi Narratives (Storytelling) │
│ • Small: 562 steps | Med: 1,125 steps│
└─────────────────────────────────────────┘
Interactive Streamlit Comparison Application
The repository includes a web application (app.py) that allows users to record or upload a single audio input and compare the transcription outputs of both models side-by-side.
Features:
- Live Microphone Recording & Audio File Upload (WAV, MP3, OGG, M4A, FLAC, WebM).
- Side-by-Side Model Comparison: Real-time evaluation of Whisper Medium vs. Whisper Small on the identical audio stream.
- Output Diff & Similarity Score: Computes textual alignment and shows vocabulary/phonetic nuances between models.
- Darja Text Normalization Toggle: Diacritics (harakat), tatweel (kashida), punctuation, and Alef/Yaa normalization.
- Copy to Clipboard & Latency / Duration Metrics.
Running the App Locally:
# 1. Clone the repository
git clone https://github.com/KamelTouati/whisper-darja-demo.git
cd whisper-darja-demo
# 2. Install dependencies
pip install -r requirements.txt
# 3. Launch Streamlit app
streamlit run app.py
Python Quickstart & Inference
1. Installation
pip install --upgrade transformers peft torch torchaudio soundfile librosa jiwer bitsandbytes accelerate
2. High-Level Usage with transformers.pipeline
import torch
from transformers import pipeline
# Choose model: "whisper-algerian-darja-medium" (recommended) or "whisper-algerian-darja-small"
model_id = "touati-kamel/whisper-algerian-darja-medium"
pipe = pipeline(
task="automatic-speech-recognition",
model=model_id,
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
device=0 if torch.cuda.is_available() else "cpu",
chunk_length_s=30,
)
# Transcribe an audio file (16kHz WAV or MP3)
result = pipe(
"path/to/algerian_audio.mp3",
generate_kwargs={"language": "arabic", "task": "transcribe"}
)
print("Transcription (Algerian Darja):", result["text"])
3. Native PyTorch + PeftModel
import torch
import librosa
from transformers import WhisperProcessor, WhisperForConditionalGeneration
from peft import PeftModel
device = "cuda" if torch.cuda.is_available() else "cpu"
base_model_id = "openai/whisper-medium" # or "openai/whisper-small"
adapter_id = "touati-kamel/whisper-algerian-darja-medium" # or "touati-kamel/whisper-algerian-darja-small"
# 1. Load Processor
processor = WhisperProcessor.from_pretrained(base_model_id, language="arabic", task="transcribe")
# 2. Load Base Model and Apply LoRA Adapter
base_model = WhisperForConditionalGeneration.from_pretrained(
base_model_id,
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
device_map="auto" if torch.cuda.is_available() else None,
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
# 3. Preprocess Audio
audio, sr = librosa.load("path/to/audio.mp3", sr=16000)
input_features = processor(audio, sampling_rate=16000, return_tensors="pt").input_features
if torch.cuda.is_available():
input_features = input_features.to("cuda", dtype=torch.float16)
# 4. Generate
forced_decoder_ids = processor.get_decoder_prompt_ids(language="arabic", task="transcribe")
with torch.no_grad():
predicted_ids = model.generate(
input_features,
forced_decoder_ids=forced_decoder_ids,
max_new_tokens=225
)
# 5. Decode
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
print("Algerian Darja Output:", transcription)
Complete Arabic Normalization Function
import re
import string
_ARABIC_DIACRITICS = "\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\u0670"
_TATWEEL = "\u0640"
_PUNCT_MAP = {ord(c): None for c in string.punctuation + "\u060C\u061B\u061F\u00AB\u00BB"}
def normalize_darja_text(text: str) -> str:
if not text:
return ""
# Strip diacritics & tatweel
text = text.translate({ord(c): None for c in _ARABIC_DIACRITICS})
text = text.replace(_TATWEEL, "")
# Normalize Alef and Yaa
text = text.replace("\u0625", "\u0627").replace("\u0623", "\u0627").replace("\u0622", "\u0627")
text = text.replace("\u0649", "\u064A")
# Remove punctuation
text = text.translate(_PUNCT_MAP)
# Collapse whitespace
return " ".join(text.split()).strip()
Evaluation Benchmarks
1. Casablanca Algerian Benchmark
Evaluates Zero-Shot foundation Whisper vs. Fine-Tuned models on UBC-NLP/Casablanca (Algeria test split):
# Local or remote GPU
python eval_casablanca.py
# Kaggle Background GPU (saves results to /kaggle/working)
python eval_casablanca_kaggle.py
Benchmark Results (843 Authentic Dialectal Utterances)
| Model Configuration | Normalized WER (%) | Normalized CER (%) | Rel. Error Reduction |
|---|---|---|---|
| Vanilla Whisper Small (Zero-Shot) | 135.97% | 56.88% | — |
| Fine-Tuned Whisper Small (OddAdmix) | 77.19% | 34.78% | -43.23% |
| Vanilla Whisper Medium (Zero-Shot) | 111.75% | 49.80% | — |
| Fine-Tuned Whisper Medium (OddAdmix) | 74.98% | 31.30% | -32.90% |
2. YODAS v3 Algerian Dialect Split (dz)
Evaluates Zero-Shot foundation Whisper vs. Fine-Tuned models on the Algerian partition of oddadmix/yodas-v3-ar-labeled-split (split dz):
# Standalone CLI execution
python eval_yodas_dz.py --num_samples 3000 --batch_size 16
# Kaggle Background GPU (self-contained, caches audio to /kaggle/tmp, exports JSON/CSV/TeX to /kaggle/working)
python eval_yodas_dz_kaggle.py
Benchmark Results (3,000 Utterances / 14.31 Hours / 1,552 Distinct Video Sources)
| Model Configuration | Normalized WER (%) | Normalized CER (%) | Raw WER (%) | Rel. Error Reduction |
|---|---|---|---|---|
| Vanilla Whisper Small (Zero-Shot) | 177.36% | 145.45% | 180.34% | — |
| Fine-Tuned Whisper Small (OddAdmix) | 172.61% | 130.28% | 173.31% | -2.68% |
| Vanilla Whisper Medium (Zero-Shot) | 155.53% | 130.28% | 160.18% | — |
| Fine-Tuned Whisper Medium (OddAdmix) | 143.56% | 104.68% | 144.51% | -7.70% |
Datasets & Citations
Training Datasets
- oddadmix/arabic-audio-collection-algerian-kahwa-postcast
- oddadmix/arabic-audio-collection-algerian-loubna-stories
- oddadmix/arabic-audio-collection-algerian-rawi
BibTeX Citations
@misc{touati2026whisper_darja_medium,
author = {Kamel Touati},
title = {Whisper Medium Fine-Tuned for Algerian Arabic (Darja)},
year = {2026},
publisher = {Hugging Face},
journal = {Hugging Face Hub},
howpublished = {\url{https://huggingface.co/touati-kamel/whisper-algerian-darja-medium}}
}
@misc{touati2026whisper_darja_small,
author = {Kamel Touati},
title = {Whisper Small Fine-Tuned for Algerian Arabic (Darja)},
year = {2026},
publisher = {Hugging Face},
journal = {Hugging Face Hub},
howpublished = {\url{https://huggingface.co/touati-kamel/whisper-algerian-darja-small}}
}
@article{radford2022whisper,
title={Robust Speech Recognition via Large-Scale Weak Supervision},
author={Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
journal={arXiv preprint arXiv:2212.04356},
year={2022}
}
- Downloads last month
- 907
Model tree for touati-kamel/whisper-algerian-darja-small
Base model
openai/whisper-small