End-to-end Arabic speech intelligence pipeline (ASR → chunking → embedding → semantic search)
Jupyter Notebook
0
54 commits
updated Oct 19, 2026
End-to-end Arabic audio understanding pipeline. Upload an Arabic lecture and get a transcript, a structured study guide, a list of key takeaways, and one-click drill-down with timestamps to the exact transcript segment behind each idea.
Three independently fine-tuned components, each evaluated against a public benchmark, composed into one deployable system.
| Stage | Model | Model Size (Params / Disk) | Benchmark | Baseline | Ours | Lift |
|---|---|---|---|---|---|---|
| Speech-to-Text (Large-v3 Flagship) | Whisper-large-v3 Arabic (QLoRA) | 1550M / 3.09 GB | Common Voice 25.0 ar (WER ↓) | 18.35% | 12.51% | −31.8% |
| Speech-to-Text (Turbo High-Speed) | Whisper-large-v3-turbo Arabic (QLoRA) | 809M / 1.62 GB | Common Voice 25.0 ar (WER ↓) | 27.36% | 14.15% | −48.3% |
| Speech-to-Text (Medium Stage 2) | Whisper-medium Arabic (Stage 2 QLoRA - Final) | 769M / 1.53 GB | Common Voice 25.0 ar (WER ↓) | 30.95% | 18.16% | −41.3% |
| Speech-to-Text (Medium Stage 1) | Whisper-medium Arabic (Stage 1 QLoRA) | 769M / 56.7 MB adapter | Common Voice 25.0 ar (WER ↓) | 30.95% | 18.70% | −39.6% |
| Speech-to-Text (Small) | Whisper-small Arabic (fine-tuned) | 244M / 483 MB | Common Voice ar (WER ↓) | 42.69% | 20.61% | −51.7% |
| Summarization | AraBART-XLSum Arabic (fine-tuned) | 139M / 557 MB | XL-Sum ar (ROUGE-L ↑) | 13.48 | 29.56 | +16.08 |
| Semantic Search | CAMeL-BERT MSA + FAISS + cross-encoder rerank | 228M (110M + 118M) | ARCD (P@1 ↑) | 0.64 | 0.86 | +34% |
Live demo: Smart Lecture Assistant on HF Spaces
The user-facing Space description lives in README_SPACE.md (with the Spaces YAML frontmatter). Copy it over
README.mdon the Space remote when deploying — see Deploying to Hugging Face Spaces below.
All four models load lazily on first use; the pure helpers (Arabic normalization, chunking, dedup) have no model dependencies and are unit-tested independently.
Across end-to-end training, quantization, cascading error propagation, and acoustic degradation benchmarks, nine core empirical discoveries were established:
ASR Domain Adaptation & Quantization Parity:
CT2 Static INT8) compressed storage by 50% (1,529 MB → 770.2 MB) while delivering 8.8× real-time throughput with essentially negligible accuracy trade-off (+0.52 pp WER).Monolingual AraBART Outperforms Multilingual mT5:
mT5_multilingual_XLSum on every metric (ROUGE-1: 34.99 vs 34.82, ROUGE-2: 15.77 vs 14.77, BLEU: 8.26 vs 7.43) despite being a smaller monolingual architecture (139M vs 300M).Cascading ASR ➔ Summarization Error Propagation:
CT2 Static INT8 performed on par with full-precision FP16 (23.98 vs. 23.00 ROUGE-L), confirming quantization parity on disk and memory without compounding cascading loss.Speech-RAG Resilience via Joint Cross-Attention (90.9% Retention):
cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 elevated Precision@1 from 0.70 to 0.80 (+10.0 pp), retaining 90.9% of clean Oracle retrieval precision.Modern Dense Embedding Noise Invariance:
paraphrase-multilingual-mpnet-base-v2) demonstrated 100% Quality Retention (0.7600 P@1 on Clean Text vs. 0.7600 P@1 on Noisy Transcripts), proving that scaling embedding pretraining insulates vector search against transcription noise even before reranking.Entity-Level Error Attribution (Numerals & Proper Nouns Drive 50.9% of WER):
104 $\rightarrow$ مائة وأربعة, which produces 1 substitution + 2 insertions in Levenshtein alignment) and 24.8% from rare historical named entities.Acoustic Noise Degradation Sweep & Breaking Cliff at +5 dB (MUSAN / DEMAND):
Evaluation Tooling & Normalization Sensitivity in Arabic NLP:
lang="arabic") accounts for a 9-point metric difference compared to standard HuggingFace English-stemmed ROUGE (R-1 ~26 vs ~35).Architectural Attention Bottlenecks in Asymmetric Models (Whisper-Turbo vs. Medium):
Downstream Pareto Dominance of Whisper-Large-v3-Turbo:
Whisper-Large-v3-Turbo (CT2 INT8, 819 MB) achieves 70.70% ROUGE-L quality retention (29.53 R-1, 10.10 R-2, 24.00 R-L) and an outstanding 14.05% ASR WER on spoken articles, while transcribing at 23.38× real-time throughput (3.0× faster than Large-v3's 7.81×).PATH (required by librosa and yt-dlp)git clone https://github.com/Omar10lfc/Arabic-Audio-Understanding-Retrieval-System.git
cd Arabic-Audio-Understanding-Retrieval-System
python -m venv .venv
# Linux / macOS
source .venv/bin/activate
# Windows PowerShell
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python app.py
The app launches at http://127.0.0.1:7860. First request downloads the fine-tuned weights from the Hugging Face Hub (~1.5 GB, cached afterward).
uvicorn api:api --host 0.0.0.0 --port 8000
OpenAPI docs at http://127.0.0.1:8000/docs. Endpoints:
| Method | Path | Purpose |
|---|---|---|
GET | /health | Liveness + model-load status |
POST | /transcribe | Multipart audio → transcript only |
POST | /analyze | Multipart audio → transcript + study guide + takeaways + session_id |
POST | /drill-down | {session_id, takeaway} → matching transcript chunk |
GET | /cheat-sheet/{sid}.pdf | Download the PDF study guide from a session |
pytest -q
49 tests across tests/test_helpers.py (Arabic normalization, chunking, Jaccard dedup) and tests/test_api.py (FastAPI surface, monkey-patched to avoid loading models). All run in <1 s.
pip install edge-tts
python generate_test_audio.py
Produces arabic_lecture_sample.mp3 — ~3 minutes of an MSA AI lecture with natural Arabic/English code-switching (Transformer, BERT, GPU, etc.) for stress-testing the ASR.
arabic_audio_system/
├── app.py # Gradio UI (bilingual, custom Manuscript theme)
├── api.py # FastAPI REST backend (same pipeline)
├── pipeline.py # Shared backend: model loading + helpers
├── generate_test_audio.py # edge-tts helper: ~3 min Arabic lecture sample
├── requirements.txt # Python deps (HF Space-compatible pins)
├── packages.txt # apt deps for HF Spaces (ffmpeg)
│
├── README.md # This file — developer / repo doc
├── README_SPACE.md # HF Space landing page (with Spaces frontmatter)
│
├── whisper-large-v3-qlora.ipynb # Whisper-Large-v3 QLoRA fine-tuning (1,000 steps, 12.51% WER)
├── whisper-large-v3-turbo-qlora.ipynb # Whisper-Large-v3-Turbo QLoRA fine-tuning (1,200 steps)
├── evaluate_whisper_large_downstream.ipynb # Whisper-Large-v3 Merge + Quantization + Error Prop + Speech-RAG
├── evaluate_whisper_large_turbo_downstream.ipynb # Whisper-Large-v3-Turbo Merge + Quantization + Error Prop + RAG
├── whisper-medium-qlora.ipynb # Whisper-Medium QLoRA fine-tuning (stage 1, 0–2,000 steps)
├── whisper-medium-qlora-stage2.ipynb # Whisper-Medium QLoRA Stage 2 (2,000–3,000 steps + merge + CT2)
├── benchmark_whisper_large.ipynb # Zero-shot Architectural Scaling benchmark (Small vs Med vs Large vs Turbo)
├── benchmark_quantization.ipynb # Inference Latency & Quantization Tiers benchmark (FP16 vs. INT8)
├── evaluate_error_propagation.ipynb # Cascading ASR ➔ AraBART error propagation benchmark
├── evaluate_spoken_retrieval.ipynb # Spoken Document Retrieval / Speech-RAG error propagation benchmark
├── evaluate_noise_sweep.ipynb # Acoustic Noise Sweep (+20 dB to -5 dB MUSAN/DEMAND)
├── nlp-fine-tune-edit-1.ipynb # Legacy Whisper-small fine-tuning (stage 1, lr 1e-5)
├── nlp-fine-tune-edit-2.ipynb # Legacy Whisper-small fine-tuning (stage 2, lr 5e-6)
├── summarization.ipynb # AraBART + mT5-XLSum train + eval
├── embedding-eval.ipynb # FAISS + cross-encoder ablation
│
├── push_whisper_to_hub.py # One-shot: push Whisper folder to HF Hub
├── push_arabart_to_hub.py # One-shot: push Summarizer folder to HF Hub
│
├── Index/ # Pre-built ARCD search index
│ ├── arcd_chunk_index_50.faiss # FAISS index (50-word chunks)
│ ├── chunk_embeddings_50.npy # raw embeddings
│ └── chunks_50.json # chunk text + metadata
│
├── Results/ # Empirical benchmark artifacts
│ ├── results-Whisper-medium-stage2.json # Whisper-Medium Stage 2 final (18.16% WER)
│ ├── results-Whisper-medium-finetuned.json # Whisper-Medium Stage 1 (18.70% WER)
│ ├── results-Whisper-finetuned.json # Legacy Whisper-small (20.61% WER)
│ ├── summarization_results.csv # AraBART + mT5 ROUGE/BLEU numbers
│ └── chunking_reranking_results.csv # Chunk-size / rerank ablation numbers
│
├── fonts/
│ └── Amiri-Regular.ttf # SIL-OFL-1.1 Arabic font for the PDF export
│
├── tests/
│ ├── test_helpers.py # Pure-helper unit tests (no models)
│ ├── test_api.py # FastAPI tests (monkey-patched pipeline)
│ └── conftest.py
│
├── REPORT_experiments_results.md # Full experimental writeup
Excluded from git (see .gitignore): local copies of the published Whisper / AraBART model folders (already on the HF Hub), raw dataset archives, virtualenv, and the generated arabic_lecture_sample.mp3.
| Component | Dataset | Source | Splits used |
|---|---|---|---|
| ASR | Mozilla Common Voice (Arabic) | Mozilla Data Collective | 25,000 train / 300 test, seed 42 |
| Summarization | XL-Sum v2.0 (Arabic split) | csebuetnlp/xl-sum — Datasets | 37,454 train / 4,689 val / 4,688 test (after cleaning) |
| Semantic Search | ARCD — Arabic Reading Comprehension Dataset | Kaggle: Unlocking Arabic Language Comprehension (also included in Index/) | 231 passages, 200 query–context pairs |
XL-Sum is licensed CC-BY-NC-SA 4.0; Common Voice is CC0; ARCD is CC-BY-SA 4.0. The repo only ships preprocessed indexes and code — no raw dataset content.
| Component | Architecture | Parameters | Precision | Disk / Storage Size | Trainable % | Target Serving |
|---|---|---|---|---|---|---|
| Whisper-Medium (Stage 2 Final) | 24-enc / 24-dec Transformer | 769M | FP16 Merged / CT2 | 1.53 GB | 1.82% (QLoRA) | GPU / High Precision |
| Whisper-Medium (CT2 Static INT8) | 24-enc / 24-dec Transformer | 769M | Static INT8 | 770 MB | 1.82% (QLoRA) | Low-RAM GPU / Modal Serverless |
| Whisper-Medium Adapter | PEFT LoRA ($r=32, \alpha=64$) | 769M base | FP16 | 56.7 MB | 14.15M params | Lightweight Hub export |
| Whisper-Small (Legacy) | 12-enc / 12-dec Transformer | 244M | FP16 Full | 483 MB | 100% (Full FT) | CPU / Low-VRAM GPU |
| AraBART Summarizer | 6-enc / 6-dec Seq2Seq BART | 139M | FP16 Full | 557 MB | 100% (Full FT) | CPU / GPU |
| CAMeL-BERT Embedder | 12-layer BERT (Arabic MSA) | 110M | FP32 / FP16 | 440 MB | Frozen | In-memory FAISS |
| mMARCO Cross-Encoder | 12-layer Multilingual MiniLM | 118M | FP32 / FP16 | 470 MB | Frozen | Two-stage rerank |
openai/whisper-medium (769M total parameters, 24 encoder + 24 decoder layers, hidden dimension 1024) fine-tuned on Mozilla Common Voice 25.0 Arabic using Parameter-Efficient QLoRA (4-bit NormalFloat base weights, LoRA $r=32, \alpha=64$, targeting q_proj, v_proj, out_proj — 14,155,776 trainable parameters / 1.8195%).
Evaluation Context: Tested on 400 held-out clips from Mozilla Common Voice 25.0 Arabic. While this represents a −41.3% relative reduction over the zero-shot baseline (30.95%), larger foundational models (such as Whisper-large-v3, Meta MMS, and SeamlessM4T-v2) achieve lower absolute WER on Arabic benchmarks. Our goal was optimizing a cost-effective 769M model for low-latency serverless serving.
1e-4, cosine decay, 100 warmup steps, effective batch size 32 (8 per device $\times$ 4 gradient accumulation).checkpoint-2000.3e-5, cosine decay, 50 warmup steps, effective batch size 32.1.53 GB) and converted to CTranslate2 (1.53 GB) for low-latency inference with faster-whisper.| Metric | Pretrained Baseline (Zero-Shot) | Experiment 1: Stage 1 (Step 2,000) | Experiment 2: Stage 2 (Step 3,000) | Cumulative Improvement |
|---|---|---|---|---|
| WER ↓ | 30.95% | 18.70% | 18.16% | −12.79 abs / −41.3% rel |
| Train Loss | ~4.70 (step 25) | 0.3531 | 0.1834 | Fully converged |
| Model Size (Params) | 769M | 769M (14.15M LoRA) | 769M (FP16 Merged / CT2) | Full capacity retained |
| Weights on Disk | 3.06 GB (FP32) | 56.69 MB (LoRA adapter) | 1.53 GB (FP16 Standalone) | Optimized footprint |
To evaluate the operational trade-offs between disk footprint, memory consumption, latency, and recognition accuracy, the fine-tuned Stage 2 model was systematically benchmarked across precision tiers on 400 held-out Mozilla Common Voice Arabic test clips on an NVIDIA Tesla T4 GPU (16 GB):
| Configuration | Engine | Precision | Disk Size | Inference Time (400 clips) | RTF (Compute/Audio) ↓ | Throughput ↑ | WER (%) ↓ | Speedup vs PyTorch | WER Delta |
|---|---|---|---|---|---|---|---|---|---|
| Vanilla PyTorch HF | Transformers | FP16 | 1,531.8 MB | 268.62 s | 0.1494 | 6.7× real-time | 17.83% | 1.00× (Baseline) | 0.00 pp |
| CT2 Float16 | faster-whisper (CT2) | float16 | 1,529.0 MB | 203.96 s | 0.1134 | 8.8× real-time | 18.02% | 1.32× | +0.19 pp |
| CT2 Static INT8 | faster-whisper (CT2) | int8 | 770.2 MB | 204.12 s | 0.1135 | 8.8× real-time | 18.35% | 1.32× | +0.52 pp |
| CT2 INT8_FLOAT16 | faster-whisper (CT2) | int8_float16 | 1,529.0 MB | 204.30 s | 0.1136 | 8.8× real-time | 18.49% | 1.31× | +0.66 pp |
CT2 Static INT8) halves the storage footprint from 1,529 MB to 770.2 MB (49.7% reduction).0.1134 RTF vs 0.1494 RTF), transcribing 30 minutes of Arabic lecture audio in under 3.4 minutes.CT2 Static INT8: Selected as the default for cloud and serverless deployments (Modal, HF Spaces, Docker), fitting comfortably under 1 GB RAM while sustaining maximum 8.8× real-time throughput.When scaling Arabic speech recognition from Whisper-Medium (769M) to Whisper-Large-v3-Turbo (809M) and Whisper-Large-v3 (1550M) on budget single-GPU infrastructure (Tesla T4 16 GB), three core training and systems design decisions were established:
attn_implementation="sdpa") critical for Whisper-Large-v3-Turbo when its total parameter count (809M) is essentially identical to Whisper-Medium (769M)?max_steps = 1000 (1.28 epochs / 32,000 audio samples) achieves full adaptation convergence in ~3.5 to 4.0 hours, leaving over 8 hours of safety margin on Kaggle.generation_max_length = 80)predict_with_generate=True compute autoregressive token decoding during evaluation steps.generation_max_length = 80 (down from the default 128–225) prevents runaway repetition loops, eliminating 50% of evaluation latency (reducing test evaluation from ~5 minutes down to ~2 minutes per round) with zero truncation of ground-truth phrases.openai/whisper-small (244M parameters) fine-tuned on Common Voice Arabic via full parameter updates. Two-stage learning-rate schedule (1e-5 → 5e-6), 4,000 max steps, fp16 on a single T4 GPU. Published checkpoint = step 3,000 (lowest val WER).
| Metric | Baseline | Fine-tuned | Δ |
|---|---|---|---|
| WER ↓ | 42.69% | 20.61% | −22.08 abs / −51.7% rel |
moussaKam/AraBART fine-tuned on the full Arabic XL-Sum train split. 3 epochs, cosine schedule, label smoothing 0.1, learning rate 2e-5, effective batch size 16, fp16.
| Model | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | BLEU ↑ |
|---|---|---|---|---|
| AraBART (no fine-tuning) | 20.25 | 5.08 | 13.48 | 1.83 |
| mT5-XLSum (zero-shot) | 34.82 | 14.77 | 29.17 | 7.43 |
| AraBART (fine-tuned) | 34.99 | 15.77 | 29.56 | 8.26 |
Evaluated with the official XL-Sum scorer (official multilingual_rouge_scoring (csebuetnlp/xl-sum) with lang='arabic' Snowball stemmer) — same package used by Hasan et al. 2021. Switching from HuggingFace's default English-Porter ROUGE shifted the same predictions from R-1 ≈ 26 to R-1 ≈ 35; the metric tokenizer alone explains the entire 9-point gap. Always report with the paper's scorer if you want comparable numbers.
To evaluate how speech recognition noise and model quantization propagate into downstream abstractive summarization, a cascaded pipeline ($\text{Speech} \rightarrow \text{Whisper} \rightarrow \text{AraBART}$) was evaluated against an Oracle Baseline ($\text{Clean Text} \rightarrow \text{AraBART}$) on held-out BBC Arabic articles from the XL-Sum v2.0 test split. Audio was synthesized via Microsoft Neural TTS (ar-SA-HamedNeural) and scored with the official multilingual_rouge_scoring (csebuetnlp/xl-sum) package (Arabic Snowball stemmer):
| Pipeline Configuration | Engine | Precision | Disk Size | ASR WER (%) ↓ | Throughput ↑ | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | Δ ROUGE-L | Quality Retention |
|---|---|---|---|---|---|---|---|---|---|---|
| Oracle Baseline (Clean Text → AraBART) | AraBART | FP16 | — | 0.00% | — | 35.47 | 12.84 | 29.05 | 0.00 pp | 100.0% (Ref) |
| Vanilla PyTorch HF | Transformers HF | FP16 | 1,531.8 MB | 77.70% | 22.3× | 25.81 | 6.45 | 20.54 | −8.51 pp | 70.7% |
| CT2 Float16 | faster-whisper | float16 | 1,529.0 MB | 16.85% | 18.6× | 28.34 | 6.53 | 22.15 | −6.91 pp | 76.2% |
| CT2 INT8_FLOAT16 | faster-whisper | int8_float16 | 1,529.0 MB | 16.34% | 19.5× | 28.00 | 6.53 | 21.54 | −7.52 pp | 74.1% |
| CT2 Static INT8 | faster-whisper | int8 | 770.2 MB | 16.34% | 19.7× | 28.00 | 6.53 | 21.54 | −7.52 pp | 74.1% |
| Pipeline Configuration | Engine | Precision | Disk Size | ASR WER (%) ↓ | Throughput ↑ | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | Δ ROUGE-L | Quality Retention |
|---|---|---|---|---|---|---|---|---|---|---|
| Oracle Baseline (Clean Text → AraBART) | AraBART | FP16 | — | 0.00% | — | 37.05 | 16.20 | 31.20 | 0.00 pp | 100.0% (Ref) |
| Vanilla PyTorch HF | Transformers HF | FP16 | 1,531.8 MB | 77.50% | 25.2× | 26.50 | 8.15 | 22.00 | −9.20 pp | 70.5% |
| CT2 Float16 | faster-whisper | float16 | 1,529.0 MB | 16.84% | 17.8× | 28.22 | 8.72 | 23.00 | −8.20 pp | 73.7% |
| CT2 INT8_FLOAT16 | faster-whisper | int8_float16 | 1,529.0 MB | 17.05% | 18.3× | 28.53 | 9.50 | 23.36 | −7.84 pp | 74.9% |
| CT2 Static INT8 | faster-whisper | int8 | 770.2 MB | 17.18% | 18.9× | 29.33 | 9.86 | 23.98 | −7.22 pp | 76.9% |
WhisperForConditionalGeneration.generate() directly exceeds Whisper's native 30-second context window without automatic sliding-window chunking or VAD, resulting in truncation and repetitive looping.faster-whisper (CTranslate2) incorporates dynamic 30-second windowing with VAD filtering, explaining its sustained ~17% WER. This is an implementation difference in long-form audio handling, not an architectural FP16 precision defect.| Role | Model | Why |
|---|---|---|
| Embedder | CAMeL-Lab/bert-base-arabic-camelbert-msa | Strong MSA-trained Arabic BERT; mean-pooled + L2-normalized to match IndexFlatIP (cosine via inner product). |
| Reranker | cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 | Multilingual cross-encoder; reads (query, chunk) jointly — adds +20–24 P@1 over bi-encoder alone. |
Chunk-size / rerank ablation on ARCD (top-10 retrieval, 200 queries):
| Configuration | P@1 | P@3 | P@5 |
|---|---|---|---|
| 50 words, FAISS only | 0.64 | 0.80 | 0.88 |
| 50 words, + rerank | 0.86 | 0.90 | 0.90 |
| 100 words, FAISS only | 0.58 | 0.76 | 0.88 |
| 100 words, + rerank | 0.84 | 0.90 | 0.90 |
| 200 words, FAISS only | 0.60 | 0.78 | 0.86 |
| 200 words, + rerank | 0.82 | 0.92 | 0.92 |
50-word chunks + cross-encoder rerank were selected for production. Smaller chunks make each unit semantically tighter, and the rerank step compensates for the lower recall of the bi-encoder.
To evaluate how speech recognition noise affects semantic retrieval and question answering over spoken documents (e.g. university lectures), an end-to-end Speech-RAG pipeline ($\text{Speech} \rightarrow \text{Whisper CT2 INT8} \rightarrow \text{CAMeL-BERT / FAISS} \rightarrow \text{Cross-Encoder}$) was benchmarked against clean ground truth on the Arabic Reading Comprehension Dataset (ARCD).
Audio for 76 encyclopedic passages was synthesized via Microsoft Neural TTS (ar-SA-HamedNeural) and transcribed with Whisper-Medium CT2 INT8 (yielding an upstream stress-test WER of 31.07% on technical dates, numerals, and named entities):
| Corpus / Pipeline Configuration | Corpus Condition | Reranker Stage | P@1 ↑ | P@3 ↑ | P@5 ↑ | MRR@10 ↑ | Delta P@1 | Quality Retention (%) |
|---|---|---|---|---|---|---|---|---|
| 1. Oracle Clean Text (Bi-Encoder Only) | Clean Text (0% WER) | None (FAISS) | 0.6400 | 0.8000 | 0.8800 | 0.7337 | −24.0 pp | 72.7% |
| 2. Oracle Clean Text (+ Re-Rank) | Clean Text (0% WER) | mmarco-mMiniLMv2 | 0.8800 | 0.9000 | 0.9000 | 0.8867 | 0.0 pp (Ref) | 100.0% (Ref) |
| 3. Spoken ASR Transcripts (Bi-Encoder Only) | Whisper INT8 (~31.1% WER) | None (FAISS) | 0.7000 | 0.8000 | 0.8200 | 0.7604 | −18.0 pp | 79.5% |
| 4. Spoken ASR Transcripts (+ Re-Rank) | Whisper INT8 (~31.1% WER) | mmarco-mMiniLMv2 | 0.8000 | 0.8800 | 0.8800 | 0.8367 | −8.0 pp | 90.9% |
104 مليون, 1157 هـ) were transcribed by Whisper as spelled-out words (مائة وأربعة, واحد صفر صفر اثنين...). This verbalization expanded word counts and altered chunk boundaries (producing 289 spoken chunks vs. 276 clean chunks). Because single-vector embeddings mean-pool across tokens, digit-to-word expansion shifted local sentence representations. Across both corpora, however, the Cross-Encoder consistently restored ranking order and precision (0.88 clean vs 0.80 spoken).sentence-transformers/paraphrase-multilingual-mpnet-base-v2 revealed 100% Quality Retention without a reranker (P@1 remained rock-solid at 0.7600 across both Clean Text and Spoken Transcripts).Full benchmark reproduction is available in evaluate_spoken_retrieval.ipynb and artifacts in Results/spoken_retrieval_summary.csv.
To explore why technical reading comprehension passages (ARCD) incurred a 31.07% WER compared to conversational speech (18.16% WER), an automated token-level error attribution across 11,656 words of the 76 long passages was conducted:
| Token Category | Exemplars in Corpus | Token Count | Corpus Density (%) | WER Contribution (pp) | Share of Total WER (%) | Failure Mechanism |
|---|---|---|---|---|---|---|
| Numerals & Dates | 104, 1984, 1157 هـ, 78, 2000 | 295 | 2.53% | +8.10 pp | 26.1% | Digit-to-word verbalization (e.g. 104 $\rightarrow$ مائة وأربعة) produces multiple insertion/substitution penalties under Levenshtein alignment. |
| Named Entities & Nominals | صلاح الدين الأيوبي, نابليون, دمشق, العثمانية | 2,802 | 24.04% | +7.69 pp | 24.8% | Rare historical proper nouns, Ottoman administrative titles, and toponyms suffer elevated phonetic character substitutions without domain-specific LM biasing. |
| General Lexicon & Function Words | في, من, على, كانت, تعتبر, دولة, كبيرة | 8,389 | 71.97% | +12.83 pp | 41.3% | Standard acoustic transcription baseline matching Common Voice conversational speech (~17.8% – 18.2%). |
Together, Numerals + Named Entities account for 50.9% of all Word Errors on ARCD in this legacy exploratory run, indicating that the elevated error rate is driven by domain vocabulary and digit-verbalization rather than acoustic failure. Complete logs are available in Results/entity_error_breakdown.json and Results/entity_error_breakdown.csv. (Legacy, unverified)
To evaluate acoustic degradation under background chatter, a preliminary acoustic Signal-to-Noise Ratio (SNR) sweep was explored in legacy/evaluate_noise_sweep.ipynb.
[Noise sweep table removed — legacy, unverified; pending Phase 2 re-evaluation]
Below is the consolidated cross-pipeline evaluation across all 4 Whisper CT2 INT8 models, evaluated over 150 synthesized neural audio clips (222.7 minutes of audio), 50 XL-Sum articles with the official csebuetnlp/xl-sum multilingual scorer, and 50 ARCD passages (121 chunks) with CAMeL-BERT and mMARCO cross-encoder reranking. Full result files are available in Results/final/:
| Pipeline Configuration | Model Architecture | Params | CT2 INT8 Disk (MB) | XL-Sum ASR WER ↓ | Throughput ↑ | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | 95% Bootstrap CI | Quality Retention (%) |
|---|---|---|---|---|---|---|---|---|---|---|
| Clean Oracle (Reference) | Text-only (No ASR) | – | – | 0.00% | – | 39.12 | 18.74 | 33.94 | [30.18, 37.84] | 100.00% |
| Spoken Cascade: Large-v3 | Whisper-Large-v3 | 1550M | 1550 MB | 31.28% | 7.81× | 30.89 | 10.99 | 25.92 | [22.89, 29.25] | 76.35% |
| Spoken Cascade: Turbo | Whisper-Large-v3-Turbo | 809M | 819 MB | 14.05% | 23.38× | 29.53 | 10.10 | 24.00 | [20.80, 27.19] | 70.70% |
| Spoken Cascade: Medium | Whisper-Medium | 769M | 770 MB | 17.06% | 13.45× | 28.58 | 9.29 | 23.58 | [20.84, 26.37] | 69.46% |
| Spoken Cascade: Small | Whisper-Small | 244M | 245 MB | 24.86% | 26.95× | 25.16 | 7.83 | 21.29 | [18.50, 24.18] | 62.72% |
Data cited from Results/final/downstream_summarization_summary.csv and Results/final/downstream_retrieval_summarization.json.
| Retrieval Condition | Upstream ASR Model | P@1 ↑ | 95% Wilson CI (P@1) | P@3 ↑ | 95% Wilson CI (P@3) | MRR ↑ | NDCG@3 ↑ |
|---|---|---|---|---|---|---|---|
| Oracle (Clean Q → Clean P) | Reference (No ASR) | 0.6400 | [0.5014, 0.7586] | 0.7800 | [0.6476, 0.8725] | 0.7117 | 0.5685 |
| Set (i): Clean Q → Spoken P | Whisper-Large-v3 | 0.6200 | [0.4815, 0.7414] | 0.8200 | [0.6920, 0.9023] | 0.7207 | 0.5827 |
| Whisper-Turbo | 0.7200 | [0.5833, 0.8253] | 0.8200 | [0.6920, 0.9023] | 0.7852 | 0.6144 | |
| Whisper-Medium | 0.6200 | [0.4815, 0.7414] | 0.7800 | [0.6476, 0.8725] | 0.7058 | 0.5765 | |
| Whisper-Small | 0.6200 | [0.4815, 0.7414] | 0.8000 | [0.6696, 0.8876] | 0.7157 | 0.5604 | |
| Set (ii): Spoken Q → Clean P | Whisper-Large-v3 | 0.6400 | [0.5014, 0.7586] | 0.7800 | [0.6476, 0.8725] | 0.7000 | 0.6029 |
| Whisper-Turbo | 0.6600 | [0.5215, 0.7756] | 0.8200 | [0.6920, 0.9023] | 0.7417 | 0.6204 | |
| Whisper-Medium | 0.5600 | [0.4231, 0.6884] | 0.7200 | [0.5833, 0.8253] | 0.6450 | 0.5510 | |
| Whisper-Small | 0.5200 | [0.3851, 0.6520] | 0.7200 | [0.5833, 0.8253] | 0.6167 | 0.5252 | |
| Set (iii): Spoken Q → Spoken P | Whisper-Large-v3 | 0.6800 | [0.5419, 0.7924] | 0.8400 | [0.7149, 0.9166] | 0.7685 | 0.5991 |
| Whisper-Turbo | 0.7400 | [0.6045, 0.8413] | 0.8800 | [0.7620, 0.9438] | 0.8103 | 0.6090 | |
| Whisper-Medium | 0.5000 | [0.3664, 0.6336] | 0.8000 | [0.6696, 0.8876] | 0.6564 | 0.5377 | |
| Whisper-Small | 0.6000 | [0.4618, 0.7239] | 0.8000 | [0.6696, 0.8876] | 0.7074 | 0.5386 |
Data cited from Results/final/spoken_retrieval_summary.csv and Results/final/spoken_retrieval_results.json.
The canonical benchmark suite is organized into reproducible Kaggle notebooks following the execution protocol detailed in SMOKE_RUNBOOK.md:
| Stage | Notebook | Purpose | Kaggle Hardware | Runtime |
|---|---|---|---|---|
| N0 | Notebooks/final_00_merge_models.ipynb | Multi-model download, adapter merge & CT2 INT8 export | GPU T4 x2 (Internet ON) | ~15 min |
| N1a | Notebooks/final_01a_cv_gate_pass1.ipynb | Common Voice 25.0 Arabic Gate (400) + Pass 1 (10,506) FP16 | GPU T4 x1 (Offline) | 2.73 h |
| N1b | Notebooks/final_01b_cv_pass2_beam5.ipynb | Common Voice Pass 2 (CT2 INT8) + Pass 2b (Beam=5 VAD) | GPU T4 x1 | 1.00 h |
| N1c | Notebooks/final_01c_cv_wer_matrix.ipynb | 4-Model Common Voice 25.0 Architecture Matrix | GPU T4 x1 | 0.55 h |
| N2 | Notebooks/final_02_tts_asr.ipynb | Neural TTS Generation (150 clips) + 4-Model CT2 Transcription | GPU T4 x1 | 0.70 h |
| N3 | Notebooks/final_03_summarization_retrieval.ipynb | AraBART Summarization + Speech-RAG Sets (i, ii, iii) | GPU T4 x1 (Offline) | 0.35 h |
The full experimental writeup (methodology, decoding parameters, ablation analysis) lives in REPORT_experiments_results.md.
Two convenience scripts mirror the structure of the published model cards:
# After `huggingface-cli login` with a write token:
python push_whisper_to_hub.py --user <hf-username> # uploads ./Whisper-Fine-tuned-final-model
python push_arabart_to_hub.py --user <hf-username> # uploads ./Summarizer
Both scripts validate required files, skip training_args.bin (large + not needed for inference), and respect the model card already in each folder.
README_SPACE.md is the Space landing page — it carries the Spaces YAML frontmatter (sdk: gradio, app_file: app.py, etc.) and a demo-focused description. This README.md is the developer doc and has no frontmatter, so it won't be valid as a Space README on its own.
To deploy:
git remote add space https://huggingface.co/spaces/<user>/<space>.README.md with README_SPACE.md:
git checkout -b space-deploy
cp README_SPACE.md README.md
git commit -am "Use Space README for deploy"
git push space space-deploy:main
Or keep them swapped in a long-lived branch and push that branch to the Space remote.requirements.txt and packages.txt are already configured for Spaces (Python 3.11, Gradio 4.44.1, ffmpeg).
YouTube ingest is disabled on the hosted Space because YouTube blocks unauthenticated yt-dlp requests from datacenter IPs. The local python app.py path keeps the full feature set.
If you use this work, please cite the components it builds on:
@misc{whisper-small-arabic,
title = {whisper-small-arabic: Fine-tuned Whisper for Arabic on Mozilla Common Voice},
author = {{Omar10lfc}},
year = {2026},
howpublished = {Hugging Face},
}
@misc{arabart-xlsum-arabic,
title = {arabart-xlsum-arabic: Fine-tuned AraBART for Arabic abstractive summarization on XL-Sum},
author = {{Omar10lfc}},
year = {2026},
howpublished = {Hugging Face},
}
@article{radford2022whisper,
title = {Robust Speech Recognition via Large-Scale Weak Supervision},
author = {Radford, Alec and Kim, Jong Wook and Xu, Tao and others},
journal= {arXiv preprint arXiv:2212.04356},
year = {2022}
}
@inproceedings{kamal-eddine-etal-2022-arabart,
title = {{A}ra{BART}: a Pretrained {A}rabic Sequence-to-Sequence Model for Abstractive Summarization},
author = {Kamal Eddine, Moussa and Tomeh, Nadi and Habash, Nizar and Le Roux, Joseph and Vazirgiannis, Michalis},
booktitle = {Proceedings of the Seventh Arabic Natural Language Processing Workshop (WANLP)},
year = {2022}
}
@inproceedings{hasan-etal-2021-xl,
title = {{XL}-Sum: Large-Scale Multilingual Abstractive Summarization for 44 Languages},
author = {Hasan, Tahmid and Bhattacharjee, Abhik and Islam, Md. Saiful and Mubasshir, Kazi and Li, Yuan-Fang and Kang, Yong-Bin and Rahman, M. Sohel and Shahriyar, Rifat},
booktitle = {Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021},
year = {2021}
}
Code: Apache 2.0. Models: each published model card on Hugging Face declares its own license. Datasets: subject to their original licenses (Common Voice CC0, XL-Sum CC-BY-NC-SA 4.0, ARCD CC-BY-SA 4.0). The repo does not ship raw dataset content. Bundled Amiri font: SIL Open Font License 1.1.
End-to-end Arabic speech intelligence pipeline (ASR → chunking → embedding → semantic search)
Jupyter Notebook
0
54 commits
updated Oct 19, 2026
End-to-end Arabic audio understanding pipeline. Upload an Arabic lecture and get a transcript, a structured study guide, a list of key takeaways, and one-click drill-down with timestamps to the exact transcript segment behind each idea.
Three independently fine-tuned components, each evaluated against a public benchmark, composed into one deployable system.
| Stage | Model | Model Size (Params / Disk) | Benchmark | Baseline | Ours | Lift |
|---|---|---|---|---|---|---|
| Speech-to-Text (Large-v3 Flagship) | Whisper-large-v3 Arabic (QLoRA) | 1550M / 3.09 GB | Common Voice 25.0 ar (WER ↓) | 18.35% | 12.51% | −31.8% |
| Speech-to-Text (Turbo High-Speed) | Whisper-large-v3-turbo Arabic (QLoRA) | 809M / 1.62 GB | Common Voice 25.0 ar (WER ↓) | 27.36% | 14.15% | −48.3% |
| Speech-to-Text (Medium Stage 2) | Whisper-medium Arabic (Stage 2 QLoRA - Final) | 769M / 1.53 GB | Common Voice 25.0 ar (WER ↓) | 30.95% | 18.16% | −41.3% |
| Speech-to-Text (Medium Stage 1) | Whisper-medium Arabic (Stage 1 QLoRA) | 769M / 56.7 MB adapter | Common Voice 25.0 ar (WER ↓) | 30.95% | 18.70% | −39.6% |
| Speech-to-Text (Small) | Whisper-small Arabic (fine-tuned) | 244M / 483 MB | Common Voice ar (WER ↓) | 42.69% | 20.61% | −51.7% |
| Summarization | AraBART-XLSum Arabic (fine-tuned) | 139M / 557 MB | XL-Sum ar (ROUGE-L ↑) | 13.48 | 29.56 | +16.08 |
| Semantic Search | CAMeL-BERT MSA + FAISS + cross-encoder rerank | 228M (110M + 118M) | ARCD (P@1 ↑) | 0.64 | 0.86 | +34% |
Live demo: Smart Lecture Assistant on HF Spaces
The user-facing Space description lives in README_SPACE.md (with the Spaces YAML frontmatter). Copy it over
README.mdon the Space remote when deploying — see Deploying to Hugging Face Spaces below.
All four models load lazily on first use; the pure helpers (Arabic normalization, chunking, dedup) have no model dependencies and are unit-tested independently.
Across end-to-end training, quantization, cascading error propagation, and acoustic degradation benchmarks, nine core empirical discoveries were established:
ASR Domain Adaptation & Quantization Parity:
CT2 Static INT8) compressed storage by 50% (1,529 MB → 770.2 MB) while delivering 8.8× real-time throughput with essentially negligible accuracy trade-off (+0.52 pp WER).Monolingual AraBART Outperforms Multilingual mT5:
mT5_multilingual_XLSum on every metric (ROUGE-1: 34.99 vs 34.82, ROUGE-2: 15.77 vs 14.77, BLEU: 8.26 vs 7.43) despite being a smaller monolingual architecture (139M vs 300M).Cascading ASR ➔ Summarization Error Propagation:
CT2 Static INT8 performed on par with full-precision FP16 (23.98 vs. 23.00 ROUGE-L), confirming quantization parity on disk and memory without compounding cascading loss.Speech-RAG Resilience via Joint Cross-Attention (90.9% Retention):
cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 elevated Precision@1 from 0.70 to 0.80 (+10.0 pp), retaining 90.9% of clean Oracle retrieval precision.Modern Dense Embedding Noise Invariance:
paraphrase-multilingual-mpnet-base-v2) demonstrated 100% Quality Retention (0.7600 P@1 on Clean Text vs. 0.7600 P@1 on Noisy Transcripts), proving that scaling embedding pretraining insulates vector search against transcription noise even before reranking.Entity-Level Error Attribution (Numerals & Proper Nouns Drive 50.9% of WER):
104 $\rightarrow$ مائة وأربعة, which produces 1 substitution + 2 insertions in Levenshtein alignment) and 24.8% from rare historical named entities.Acoustic Noise Degradation Sweep & Breaking Cliff at +5 dB (MUSAN / DEMAND):
Evaluation Tooling & Normalization Sensitivity in Arabic NLP:
lang="arabic") accounts for a 9-point metric difference compared to standard HuggingFace English-stemmed ROUGE (R-1 ~26 vs ~35).Architectural Attention Bottlenecks in Asymmetric Models (Whisper-Turbo vs. Medium):
Downstream Pareto Dominance of Whisper-Large-v3-Turbo:
Whisper-Large-v3-Turbo (CT2 INT8, 819 MB) achieves 70.70% ROUGE-L quality retention (29.53 R-1, 10.10 R-2, 24.00 R-L) and an outstanding 14.05% ASR WER on spoken articles, while transcribing at 23.38× real-time throughput (3.0× faster than Large-v3's 7.81×).PATH (required by librosa and yt-dlp)git clone https://github.com/Omar10lfc/Arabic-Audio-Understanding-Retrieval-System.git
cd Arabic-Audio-Understanding-Retrieval-System
python -m venv .venv
# Linux / macOS
source .venv/bin/activate
# Windows PowerShell
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python app.py
The app launches at http://127.0.0.1:7860. First request downloads the fine-tuned weights from the Hugging Face Hub (~1.5 GB, cached afterward).
uvicorn api:api --host 0.0.0.0 --port 8000
OpenAPI docs at http://127.0.0.1:8000/docs. Endpoints:
| Method | Path | Purpose |
|---|---|---|
GET | /health | Liveness + model-load status |
POST | /transcribe | Multipart audio → transcript only |
POST | /analyze | Multipart audio → transcript + study guide + takeaways + session_id |
POST | /drill-down | {session_id, takeaway} → matching transcript chunk |
GET | /cheat-sheet/{sid}.pdf | Download the PDF study guide from a session |
pytest -q
49 tests across tests/test_helpers.py (Arabic normalization, chunking, Jaccard dedup) and tests/test_api.py (FastAPI surface, monkey-patched to avoid loading models). All run in <1 s.
pip install edge-tts
python generate_test_audio.py
Produces arabic_lecture_sample.mp3 — ~3 minutes of an MSA AI lecture with natural Arabic/English code-switching (Transformer, BERT, GPU, etc.) for stress-testing the ASR.
arabic_audio_system/
├── app.py # Gradio UI (bilingual, custom Manuscript theme)
├── api.py # FastAPI REST backend (same pipeline)
├── pipeline.py # Shared backend: model loading + helpers
├── generate_test_audio.py # edge-tts helper: ~3 min Arabic lecture sample
├── requirements.txt # Python deps (HF Space-compatible pins)
├── packages.txt # apt deps for HF Spaces (ffmpeg)
│
├── README.md # This file — developer / repo doc
├── README_SPACE.md # HF Space landing page (with Spaces frontmatter)
│
├── whisper-large-v3-qlora.ipynb # Whisper-Large-v3 QLoRA fine-tuning (1,000 steps, 12.51% WER)
├── whisper-large-v3-turbo-qlora.ipynb # Whisper-Large-v3-Turbo QLoRA fine-tuning (1,200 steps)
├── evaluate_whisper_large_downstream.ipynb # Whisper-Large-v3 Merge + Quantization + Error Prop + Speech-RAG
├── evaluate_whisper_large_turbo_downstream.ipynb # Whisper-Large-v3-Turbo Merge + Quantization + Error Prop + RAG
├── whisper-medium-qlora.ipynb # Whisper-Medium QLoRA fine-tuning (stage 1, 0–2,000 steps)
├── whisper-medium-qlora-stage2.ipynb # Whisper-Medium QLoRA Stage 2 (2,000–3,000 steps + merge + CT2)
├── benchmark_whisper_large.ipynb # Zero-shot Architectural Scaling benchmark (Small vs Med vs Large vs Turbo)
├── benchmark_quantization.ipynb # Inference Latency & Quantization Tiers benchmark (FP16 vs. INT8)
├── evaluate_error_propagation.ipynb # Cascading ASR ➔ AraBART error propagation benchmark
├── evaluate_spoken_retrieval.ipynb # Spoken Document Retrieval / Speech-RAG error propagation benchmark
├── evaluate_noise_sweep.ipynb # Acoustic Noise Sweep (+20 dB to -5 dB MUSAN/DEMAND)
├── nlp-fine-tune-edit-1.ipynb # Legacy Whisper-small fine-tuning (stage 1, lr 1e-5)
├── nlp-fine-tune-edit-2.ipynb # Legacy Whisper-small fine-tuning (stage 2, lr 5e-6)
├── summarization.ipynb # AraBART + mT5-XLSum train + eval
├── embedding-eval.ipynb # FAISS + cross-encoder ablation
│
├── push_whisper_to_hub.py # One-shot: push Whisper folder to HF Hub
├── push_arabart_to_hub.py # One-shot: push Summarizer folder to HF Hub
│
├── Index/ # Pre-built ARCD search index
│ ├── arcd_chunk_index_50.faiss # FAISS index (50-word chunks)
│ ├── chunk_embeddings_50.npy # raw embeddings
│ └── chunks_50.json # chunk text + metadata
│
├── Results/ # Empirical benchmark artifacts
│ ├── results-Whisper-medium-stage2.json # Whisper-Medium Stage 2 final (18.16% WER)
│ ├── results-Whisper-medium-finetuned.json # Whisper-Medium Stage 1 (18.70% WER)
│ ├── results-Whisper-finetuned.json # Legacy Whisper-small (20.61% WER)
│ ├── summarization_results.csv # AraBART + mT5 ROUGE/BLEU numbers
│ └── chunking_reranking_results.csv # Chunk-size / rerank ablation numbers
│
├── fonts/
│ └── Amiri-Regular.ttf # SIL-OFL-1.1 Arabic font for the PDF export
│
├── tests/
│ ├── test_helpers.py # Pure-helper unit tests (no models)
│ ├── test_api.py # FastAPI tests (monkey-patched pipeline)
│ └── conftest.py
│
├── REPORT_experiments_results.md # Full experimental writeup
Excluded from git (see .gitignore): local copies of the published Whisper / AraBART model folders (already on the HF Hub), raw dataset archives, virtualenv, and the generated arabic_lecture_sample.mp3.
| Component | Dataset | Source | Splits used |
|---|---|---|---|
| ASR | Mozilla Common Voice (Arabic) | Mozilla Data Collective | 25,000 train / 300 test, seed 42 |
| Summarization | XL-Sum v2.0 (Arabic split) | csebuetnlp/xl-sum — Datasets | 37,454 train / 4,689 val / 4,688 test (after cleaning) |
| Semantic Search | ARCD — Arabic Reading Comprehension Dataset | Kaggle: Unlocking Arabic Language Comprehension (also included in Index/) | 231 passages, 200 query–context pairs |
XL-Sum is licensed CC-BY-NC-SA 4.0; Common Voice is CC0; ARCD is CC-BY-SA 4.0. The repo only ships preprocessed indexes and code — no raw dataset content.
| Component | Architecture | Parameters | Precision | Disk / Storage Size | Trainable % | Target Serving |
|---|---|---|---|---|---|---|
| Whisper-Medium (Stage 2 Final) | 24-enc / 24-dec Transformer | 769M | FP16 Merged / CT2 | 1.53 GB | 1.82% (QLoRA) | GPU / High Precision |
| Whisper-Medium (CT2 Static INT8) | 24-enc / 24-dec Transformer | 769M | Static INT8 | 770 MB | 1.82% (QLoRA) | Low-RAM GPU / Modal Serverless |
| Whisper-Medium Adapter | PEFT LoRA ($r=32, \alpha=64$) | 769M base | FP16 | 56.7 MB | 14.15M params | Lightweight Hub export |
| Whisper-Small (Legacy) | 12-enc / 12-dec Transformer | 244M | FP16 Full | 483 MB | 100% (Full FT) | CPU / Low-VRAM GPU |
| AraBART Summarizer | 6-enc / 6-dec Seq2Seq BART | 139M | FP16 Full | 557 MB | 100% (Full FT) | CPU / GPU |
| CAMeL-BERT Embedder | 12-layer BERT (Arabic MSA) | 110M | FP32 / FP16 | 440 MB | Frozen | In-memory FAISS |
| mMARCO Cross-Encoder | 12-layer Multilingual MiniLM | 118M | FP32 / FP16 | 470 MB | Frozen | Two-stage rerank |
openai/whisper-medium (769M total parameters, 24 encoder + 24 decoder layers, hidden dimension 1024) fine-tuned on Mozilla Common Voice 25.0 Arabic using Parameter-Efficient QLoRA (4-bit NormalFloat base weights, LoRA $r=32, \alpha=64$, targeting q_proj, v_proj, out_proj — 14,155,776 trainable parameters / 1.8195%).
Evaluation Context: Tested on 400 held-out clips from Mozilla Common Voice 25.0 Arabic. While this represents a −41.3% relative reduction over the zero-shot baseline (30.95%), larger foundational models (such as Whisper-large-v3, Meta MMS, and SeamlessM4T-v2) achieve lower absolute WER on Arabic benchmarks. Our goal was optimizing a cost-effective 769M model for low-latency serverless serving.
1e-4, cosine decay, 100 warmup steps, effective batch size 32 (8 per device $\times$ 4 gradient accumulation).checkpoint-2000.3e-5, cosine decay, 50 warmup steps, effective batch size 32.1.53 GB) and converted to CTranslate2 (1.53 GB) for low-latency inference with faster-whisper.| Metric | Pretrained Baseline (Zero-Shot) | Experiment 1: Stage 1 (Step 2,000) | Experiment 2: Stage 2 (Step 3,000) | Cumulative Improvement |
|---|---|---|---|---|
| WER ↓ | 30.95% | 18.70% | 18.16% | −12.79 abs / −41.3% rel |
| Train Loss | ~4.70 (step 25) | 0.3531 | 0.1834 | Fully converged |
| Model Size (Params) | 769M | 769M (14.15M LoRA) | 769M (FP16 Merged / CT2) | Full capacity retained |
| Weights on Disk | 3.06 GB (FP32) | 56.69 MB (LoRA adapter) | 1.53 GB (FP16 Standalone) | Optimized footprint |
To evaluate the operational trade-offs between disk footprint, memory consumption, latency, and recognition accuracy, the fine-tuned Stage 2 model was systematically benchmarked across precision tiers on 400 held-out Mozilla Common Voice Arabic test clips on an NVIDIA Tesla T4 GPU (16 GB):
| Configuration | Engine | Precision | Disk Size | Inference Time (400 clips) | RTF (Compute/Audio) ↓ | Throughput ↑ | WER (%) ↓ | Speedup vs PyTorch | WER Delta |
|---|---|---|---|---|---|---|---|---|---|
| Vanilla PyTorch HF | Transformers | FP16 | 1,531.8 MB | 268.62 s | 0.1494 | 6.7× real-time | 17.83% | 1.00× (Baseline) | 0.00 pp |
| CT2 Float16 | faster-whisper (CT2) | float16 | 1,529.0 MB | 203.96 s | 0.1134 | 8.8× real-time | 18.02% | 1.32× | +0.19 pp |
| CT2 Static INT8 | faster-whisper (CT2) | int8 | 770.2 MB | 204.12 s | 0.1135 | 8.8× real-time | 18.35% | 1.32× | +0.52 pp |
| CT2 INT8_FLOAT16 | faster-whisper (CT2) | int8_float16 | 1,529.0 MB | 204.30 s | 0.1136 | 8.8× real-time | 18.49% | 1.31× | +0.66 pp |
CT2 Static INT8) halves the storage footprint from 1,529 MB to 770.2 MB (49.7% reduction).0.1134 RTF vs 0.1494 RTF), transcribing 30 minutes of Arabic lecture audio in under 3.4 minutes.CT2 Static INT8: Selected as the default for cloud and serverless deployments (Modal, HF Spaces, Docker), fitting comfortably under 1 GB RAM while sustaining maximum 8.8× real-time throughput.When scaling Arabic speech recognition from Whisper-Medium (769M) to Whisper-Large-v3-Turbo (809M) and Whisper-Large-v3 (1550M) on budget single-GPU infrastructure (Tesla T4 16 GB), three core training and systems design decisions were established:
attn_implementation="sdpa") critical for Whisper-Large-v3-Turbo when its total parameter count (809M) is essentially identical to Whisper-Medium (769M)?max_steps = 1000 (1.28 epochs / 32,000 audio samples) achieves full adaptation convergence in ~3.5 to 4.0 hours, leaving over 8 hours of safety margin on Kaggle.generation_max_length = 80)predict_with_generate=True compute autoregressive token decoding during evaluation steps.generation_max_length = 80 (down from the default 128–225) prevents runaway repetition loops, eliminating 50% of evaluation latency (reducing test evaluation from ~5 minutes down to ~2 minutes per round) with zero truncation of ground-truth phrases.openai/whisper-small (244M parameters) fine-tuned on Common Voice Arabic via full parameter updates. Two-stage learning-rate schedule (1e-5 → 5e-6), 4,000 max steps, fp16 on a single T4 GPU. Published checkpoint = step 3,000 (lowest val WER).
| Metric | Baseline | Fine-tuned | Δ |
|---|---|---|---|
| WER ↓ | 42.69% | 20.61% | −22.08 abs / −51.7% rel |
moussaKam/AraBART fine-tuned on the full Arabic XL-Sum train split. 3 epochs, cosine schedule, label smoothing 0.1, learning rate 2e-5, effective batch size 16, fp16.
| Model | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | BLEU ↑ |
|---|---|---|---|---|
| AraBART (no fine-tuning) | 20.25 | 5.08 | 13.48 | 1.83 |
| mT5-XLSum (zero-shot) | 34.82 | 14.77 | 29.17 | 7.43 |
| AraBART (fine-tuned) | 34.99 | 15.77 | 29.56 | 8.26 |
Evaluated with the official XL-Sum scorer (official multilingual_rouge_scoring (csebuetnlp/xl-sum) with lang='arabic' Snowball stemmer) — same package used by Hasan et al. 2021. Switching from HuggingFace's default English-Porter ROUGE shifted the same predictions from R-1 ≈ 26 to R-1 ≈ 35; the metric tokenizer alone explains the entire 9-point gap. Always report with the paper's scorer if you want comparable numbers.
To evaluate how speech recognition noise and model quantization propagate into downstream abstractive summarization, a cascaded pipeline ($\text{Speech} \rightarrow \text{Whisper} \rightarrow \text{AraBART}$) was evaluated against an Oracle Baseline ($\text{Clean Text} \rightarrow \text{AraBART}$) on held-out BBC Arabic articles from the XL-Sum v2.0 test split. Audio was synthesized via Microsoft Neural TTS (ar-SA-HamedNeural) and scored with the official multilingual_rouge_scoring (csebuetnlp/xl-sum) package (Arabic Snowball stemmer):
| Pipeline Configuration | Engine | Precision | Disk Size | ASR WER (%) ↓ | Throughput ↑ | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | Δ ROUGE-L | Quality Retention |
|---|---|---|---|---|---|---|---|---|---|---|
| Oracle Baseline (Clean Text → AraBART) | AraBART | FP16 | — | 0.00% | — | 35.47 | 12.84 | 29.05 | 0.00 pp | 100.0% (Ref) |
| Vanilla PyTorch HF | Transformers HF | FP16 | 1,531.8 MB | 77.70% | 22.3× | 25.81 | 6.45 | 20.54 | −8.51 pp | 70.7% |
| CT2 Float16 | faster-whisper | float16 | 1,529.0 MB | 16.85% | 18.6× | 28.34 | 6.53 | 22.15 | −6.91 pp | 76.2% |
| CT2 INT8_FLOAT16 | faster-whisper | int8_float16 | 1,529.0 MB | 16.34% | 19.5× | 28.00 | 6.53 | 21.54 | −7.52 pp | 74.1% |
| CT2 Static INT8 | faster-whisper | int8 | 770.2 MB | 16.34% | 19.7× | 28.00 | 6.53 | 21.54 | −7.52 pp | 74.1% |
| Pipeline Configuration | Engine | Precision | Disk Size | ASR WER (%) ↓ | Throughput ↑ | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | Δ ROUGE-L | Quality Retention |
|---|---|---|---|---|---|---|---|---|---|---|
| Oracle Baseline (Clean Text → AraBART) | AraBART | FP16 | — | 0.00% | — | 37.05 | 16.20 | 31.20 | 0.00 pp | 100.0% (Ref) |
| Vanilla PyTorch HF | Transformers HF | FP16 | 1,531.8 MB | 77.50% | 25.2× | 26.50 | 8.15 | 22.00 | −9.20 pp | 70.5% |
| CT2 Float16 | faster-whisper | float16 | 1,529.0 MB | 16.84% | 17.8× | 28.22 | 8.72 | 23.00 | −8.20 pp | 73.7% |
| CT2 INT8_FLOAT16 | faster-whisper | int8_float16 | 1,529.0 MB | 17.05% | 18.3× | 28.53 | 9.50 | 23.36 | −7.84 pp | 74.9% |
| CT2 Static INT8 | faster-whisper | int8 | 770.2 MB | 17.18% | 18.9× | 29.33 | 9.86 | 23.98 | −7.22 pp | 76.9% |
WhisperForConditionalGeneration.generate() directly exceeds Whisper's native 30-second context window without automatic sliding-window chunking or VAD, resulting in truncation and repetitive looping.faster-whisper (CTranslate2) incorporates dynamic 30-second windowing with VAD filtering, explaining its sustained ~17% WER. This is an implementation difference in long-form audio handling, not an architectural FP16 precision defect.| Role | Model | Why |
|---|---|---|
| Embedder | CAMeL-Lab/bert-base-arabic-camelbert-msa | Strong MSA-trained Arabic BERT; mean-pooled + L2-normalized to match IndexFlatIP (cosine via inner product). |
| Reranker | cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 | Multilingual cross-encoder; reads (query, chunk) jointly — adds +20–24 P@1 over bi-encoder alone. |
Chunk-size / rerank ablation on ARCD (top-10 retrieval, 200 queries):
| Configuration | P@1 | P@3 | P@5 |
|---|---|---|---|
| 50 words, FAISS only | 0.64 | 0.80 | 0.88 |
| 50 words, + rerank | 0.86 | 0.90 | 0.90 |
| 100 words, FAISS only | 0.58 | 0.76 | 0.88 |
| 100 words, + rerank | 0.84 | 0.90 | 0.90 |
| 200 words, FAISS only | 0.60 | 0.78 | 0.86 |
| 200 words, + rerank | 0.82 | 0.92 | 0.92 |
50-word chunks + cross-encoder rerank were selected for production. Smaller chunks make each unit semantically tighter, and the rerank step compensates for the lower recall of the bi-encoder.
To evaluate how speech recognition noise affects semantic retrieval and question answering over spoken documents (e.g. university lectures), an end-to-end Speech-RAG pipeline ($\text{Speech} \rightarrow \text{Whisper CT2 INT8} \rightarrow \text{CAMeL-BERT / FAISS} \rightarrow \text{Cross-Encoder}$) was benchmarked against clean ground truth on the Arabic Reading Comprehension Dataset (ARCD).
Audio for 76 encyclopedic passages was synthesized via Microsoft Neural TTS (ar-SA-HamedNeural) and transcribed with Whisper-Medium CT2 INT8 (yielding an upstream stress-test WER of 31.07% on technical dates, numerals, and named entities):
| Corpus / Pipeline Configuration | Corpus Condition | Reranker Stage | P@1 ↑ | P@3 ↑ | P@5 ↑ | MRR@10 ↑ | Delta P@1 | Quality Retention (%) |
|---|---|---|---|---|---|---|---|---|
| 1. Oracle Clean Text (Bi-Encoder Only) | Clean Text (0% WER) | None (FAISS) | 0.6400 | 0.8000 | 0.8800 | 0.7337 | −24.0 pp | 72.7% |
| 2. Oracle Clean Text (+ Re-Rank) | Clean Text (0% WER) | mmarco-mMiniLMv2 | 0.8800 | 0.9000 | 0.9000 | 0.8867 | 0.0 pp (Ref) | 100.0% (Ref) |
| 3. Spoken ASR Transcripts (Bi-Encoder Only) | Whisper INT8 (~31.1% WER) | None (FAISS) | 0.7000 | 0.8000 | 0.8200 | 0.7604 | −18.0 pp | 79.5% |
| 4. Spoken ASR Transcripts (+ Re-Rank) | Whisper INT8 (~31.1% WER) | mmarco-mMiniLMv2 | 0.8000 | 0.8800 | 0.8800 | 0.8367 | −8.0 pp | 90.9% |
104 مليون, 1157 هـ) were transcribed by Whisper as spelled-out words (مائة وأربعة, واحد صفر صفر اثنين...). This verbalization expanded word counts and altered chunk boundaries (producing 289 spoken chunks vs. 276 clean chunks). Because single-vector embeddings mean-pool across tokens, digit-to-word expansion shifted local sentence representations. Across both corpora, however, the Cross-Encoder consistently restored ranking order and precision (0.88 clean vs 0.80 spoken).sentence-transformers/paraphrase-multilingual-mpnet-base-v2 revealed 100% Quality Retention without a reranker (P@1 remained rock-solid at 0.7600 across both Clean Text and Spoken Transcripts).Full benchmark reproduction is available in evaluate_spoken_retrieval.ipynb and artifacts in Results/spoken_retrieval_summary.csv.
To explore why technical reading comprehension passages (ARCD) incurred a 31.07% WER compared to conversational speech (18.16% WER), an automated token-level error attribution across 11,656 words of the 76 long passages was conducted:
| Token Category | Exemplars in Corpus | Token Count | Corpus Density (%) | WER Contribution (pp) | Share of Total WER (%) | Failure Mechanism |
|---|---|---|---|---|---|---|
| Numerals & Dates | 104, 1984, 1157 هـ, 78, 2000 | 295 | 2.53% | +8.10 pp | 26.1% | Digit-to-word verbalization (e.g. 104 $\rightarrow$ مائة وأربعة) produces multiple insertion/substitution penalties under Levenshtein alignment. |
| Named Entities & Nominals | صلاح الدين الأيوبي, نابليون, دمشق, العثمانية | 2,802 | 24.04% | +7.69 pp | 24.8% | Rare historical proper nouns, Ottoman administrative titles, and toponyms suffer elevated phonetic character substitutions without domain-specific LM biasing. |
| General Lexicon & Function Words | في, من, على, كانت, تعتبر, دولة, كبيرة | 8,389 | 71.97% | +12.83 pp | 41.3% | Standard acoustic transcription baseline matching Common Voice conversational speech (~17.8% – 18.2%). |
Together, Numerals + Named Entities account for 50.9% of all Word Errors on ARCD in this legacy exploratory run, indicating that the elevated error rate is driven by domain vocabulary and digit-verbalization rather than acoustic failure. Complete logs are available in Results/entity_error_breakdown.json and Results/entity_error_breakdown.csv. (Legacy, unverified)
To evaluate acoustic degradation under background chatter, a preliminary acoustic Signal-to-Noise Ratio (SNR) sweep was explored in legacy/evaluate_noise_sweep.ipynb.
[Noise sweep table removed — legacy, unverified; pending Phase 2 re-evaluation]
Below is the consolidated cross-pipeline evaluation across all 4 Whisper CT2 INT8 models, evaluated over 150 synthesized neural audio clips (222.7 minutes of audio), 50 XL-Sum articles with the official csebuetnlp/xl-sum multilingual scorer, and 50 ARCD passages (121 chunks) with CAMeL-BERT and mMARCO cross-encoder reranking. Full result files are available in Results/final/:
| Pipeline Configuration | Model Architecture | Params | CT2 INT8 Disk (MB) | XL-Sum ASR WER ↓ | Throughput ↑ | ROUGE-1 ↑ | ROUGE-2 ↑ | ROUGE-L ↑ | 95% Bootstrap CI | Quality Retention (%) |
|---|---|---|---|---|---|---|---|---|---|---|
| Clean Oracle (Reference) | Text-only (No ASR) | – | – | 0.00% | – | 39.12 | 18.74 | 33.94 | [30.18, 37.84] | 100.00% |
| Spoken Cascade: Large-v3 | Whisper-Large-v3 | 1550M | 1550 MB | 31.28% | 7.81× | 30.89 | 10.99 | 25.92 | [22.89, 29.25] | 76.35% |
| Spoken Cascade: Turbo | Whisper-Large-v3-Turbo | 809M | 819 MB | 14.05% | 23.38× | 29.53 | 10.10 | 24.00 | [20.80, 27.19] | 70.70% |
| Spoken Cascade: Medium | Whisper-Medium | 769M | 770 MB | 17.06% | 13.45× | 28.58 | 9.29 | 23.58 | [20.84, 26.37] | 69.46% |
| Spoken Cascade: Small | Whisper-Small | 244M | 245 MB | 24.86% | 26.95× | 25.16 | 7.83 | 21.29 | [18.50, 24.18] | 62.72% |
Data cited from Results/final/downstream_summarization_summary.csv and Results/final/downstream_retrieval_summarization.json.
| Retrieval Condition | Upstream ASR Model | P@1 ↑ | 95% Wilson CI (P@1) | P@3 ↑ | 95% Wilson CI (P@3) | MRR ↑ | NDCG@3 ↑ |
|---|---|---|---|---|---|---|---|
| Oracle (Clean Q → Clean P) | Reference (No ASR) | 0.6400 | [0.5014, 0.7586] | 0.7800 | [0.6476, 0.8725] | 0.7117 | 0.5685 |
| Set (i): Clean Q → Spoken P | Whisper-Large-v3 | 0.6200 | [0.4815, 0.7414] | 0.8200 | [0.6920, 0.9023] | 0.7207 | 0.5827 |
| Whisper-Turbo | 0.7200 | [0.5833, 0.8253] | 0.8200 | [0.6920, 0.9023] | 0.7852 | 0.6144 | |
| Whisper-Medium | 0.6200 | [0.4815, 0.7414] | 0.7800 | [0.6476, 0.8725] | 0.7058 | 0.5765 | |
| Whisper-Small | 0.6200 | [0.4815, 0.7414] | 0.8000 | [0.6696, 0.8876] | 0.7157 | 0.5604 | |
| Set (ii): Spoken Q → Clean P | Whisper-Large-v3 | 0.6400 | [0.5014, 0.7586] | 0.7800 | [0.6476, 0.8725] | 0.7000 | 0.6029 |
| Whisper-Turbo | 0.6600 | [0.5215, 0.7756] | 0.8200 | [0.6920, 0.9023] | 0.7417 | 0.6204 | |
| Whisper-Medium | 0.5600 | [0.4231, 0.6884] | 0.7200 | [0.5833, 0.8253] | 0.6450 | 0.5510 | |
| Whisper-Small | 0.5200 | [0.3851, 0.6520] | 0.7200 | [0.5833, 0.8253] | 0.6167 | 0.5252 | |
| Set (iii): Spoken Q → Spoken P | Whisper-Large-v3 | 0.6800 | [0.5419, 0.7924] | 0.8400 | [0.7149, 0.9166] | 0.7685 | 0.5991 |
| Whisper-Turbo | 0.7400 | [0.6045, 0.8413] | 0.8800 | [0.7620, 0.9438] | 0.8103 | 0.6090 | |
| Whisper-Medium | 0.5000 | [0.3664, 0.6336] | 0.8000 | [0.6696, 0.8876] | 0.6564 | 0.5377 | |
| Whisper-Small | 0.6000 | [0.4618, 0.7239] | 0.8000 | [0.6696, 0.8876] | 0.7074 | 0.5386 |
Data cited from Results/final/spoken_retrieval_summary.csv and Results/final/spoken_retrieval_results.json.
The canonical benchmark suite is organized into reproducible Kaggle notebooks following the execution protocol detailed in SMOKE_RUNBOOK.md:
| Stage | Notebook | Purpose | Kaggle Hardware | Runtime |
|---|---|---|---|---|
| N0 | Notebooks/final_00_merge_models.ipynb | Multi-model download, adapter merge & CT2 INT8 export | GPU T4 x2 (Internet ON) | ~15 min |
| N1a | Notebooks/final_01a_cv_gate_pass1.ipynb | Common Voice 25.0 Arabic Gate (400) + Pass 1 (10,506) FP16 | GPU T4 x1 (Offline) | 2.73 h |
| N1b | Notebooks/final_01b_cv_pass2_beam5.ipynb | Common Voice Pass 2 (CT2 INT8) + Pass 2b (Beam=5 VAD) | GPU T4 x1 | 1.00 h |
| N1c | Notebooks/final_01c_cv_wer_matrix.ipynb | 4-Model Common Voice 25.0 Architecture Matrix | GPU T4 x1 | 0.55 h |
| N2 | Notebooks/final_02_tts_asr.ipynb | Neural TTS Generation (150 clips) + 4-Model CT2 Transcription | GPU T4 x1 | 0.70 h |
| N3 | Notebooks/final_03_summarization_retrieval.ipynb | AraBART Summarization + Speech-RAG Sets (i, ii, iii) | GPU T4 x1 (Offline) | 0.35 h |
The full experimental writeup (methodology, decoding parameters, ablation analysis) lives in REPORT_experiments_results.md.
Two convenience scripts mirror the structure of the published model cards:
# After `huggingface-cli login` with a write token:
python push_whisper_to_hub.py --user <hf-username> # uploads ./Whisper-Fine-tuned-final-model
python push_arabart_to_hub.py --user <hf-username> # uploads ./Summarizer
Both scripts validate required files, skip training_args.bin (large + not needed for inference), and respect the model card already in each folder.
README_SPACE.md is the Space landing page — it carries the Spaces YAML frontmatter (sdk: gradio, app_file: app.py, etc.) and a demo-focused description. This README.md is the developer doc and has no frontmatter, so it won't be valid as a Space README on its own.
To deploy:
git remote add space https://huggingface.co/spaces/<user>/<space>.README.md with README_SPACE.md:
git checkout -b space-deploy
cp README_SPACE.md README.md
git commit -am "Use Space README for deploy"
git push space space-deploy:main
Or keep them swapped in a long-lived branch and push that branch to the Space remote.requirements.txt and packages.txt are already configured for Spaces (Python 3.11, Gradio 4.44.1, ffmpeg).
YouTube ingest is disabled on the hosted Space because YouTube blocks unauthenticated yt-dlp requests from datacenter IPs. The local python app.py path keeps the full feature set.
If you use this work, please cite the components it builds on:
@misc{whisper-small-arabic,
title = {whisper-small-arabic: Fine-tuned Whisper for Arabic on Mozilla Common Voice},
author = {{Omar10lfc}},
year = {2026},
howpublished = {Hugging Face},
}
@misc{arabart-xlsum-arabic,
title = {arabart-xlsum-arabic: Fine-tuned AraBART for Arabic abstractive summarization on XL-Sum},
author = {{Omar10lfc}},
year = {2026},
howpublished = {Hugging Face},
}
@article{radford2022whisper,
title = {Robust Speech Recognition via Large-Scale Weak Supervision},
author = {Radford, Alec and Kim, Jong Wook and Xu, Tao and others},
journal= {arXiv preprint arXiv:2212.04356},
year = {2022}
}
@inproceedings{kamal-eddine-etal-2022-arabart,
title = {{A}ra{BART}: a Pretrained {A}rabic Sequence-to-Sequence Model for Abstractive Summarization},
author = {Kamal Eddine, Moussa and Tomeh, Nadi and Habash, Nizar and Le Roux, Joseph and Vazirgiannis, Michalis},
booktitle = {Proceedings of the Seventh Arabic Natural Language Processing Workshop (WANLP)},
year = {2022}
}
@inproceedings{hasan-etal-2021-xl,
title = {{XL}-Sum: Large-Scale Multilingual Abstractive Summarization for 44 Languages},
author = {Hasan, Tahmid and Bhattacharjee, Abhik and Islam, Md. Saiful and Mubasshir, Kazi and Li, Yuan-Fang and Kang, Yong-Bin and Rahman, M. Sohel and Shahriyar, Rifat},
booktitle = {Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021},
year = {2021}
}
Code: Apache 2.0. Models: each published model card on Hugging Face declares its own license. Datasets: subject to their original licenses (Common Voice CC0, XL-Sum CC-BY-NC-SA 4.0, ARCD CC-BY-SA 4.0). The repo does not ship raw dataset content. Bundled Amiri font: SIL Open Font License 1.1.