CoolFace
Modelpublic

abidanoaman/urdu-asr-distilled-base-enhanced

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes11downloads
Model Card

Enhanced Distilled Urdu ASR - wav2vec2-base

State-of-the-art lightweight Urdu ASR model using advanced knowledge distillation techniques.

๐ŸŽฏ Model Overview

This model uses cutting-edge distillation techniques:

  • โ€”โœ… Feature-level distillation: Matches intermediate layer representations
  • โ€”โœ… Temperature scheduling: Adaptive softening of targets (4.0 โ†’ 1.5)
  • โ€”โœ… SpecAugment: Time/frequency masking for robustness
  • โ€”โœ… Multi-loss optimization: Logits + CTC + Features

Performance

  • โ€”โœ… Speed: 2.4x faster inference
  • โ€”โœ… Size: 3.3x smaller (94M vs 315M parameters)
  • โ€”โœ… Accuracy: Only 11.3% WER degradation

๐Ÿ“Š Detailed Results

Student Model (This Model)

  • โ€”WER: 49.40%
  • โ€”CER: 19.38%
  • โ€”Parameters: 94,417,083 (94M)
  • โ€”Inference Speed: 0.010s/batch

Teacher Model (Original)

  • โ€”WER: 38.06%
  • โ€”CER: 14.75%
  • โ€”Parameters: 315,499,195 (315M)
  • โ€”Inference Speed: 0.023s/batch

Improvements vs Standard Distillation

  • โ€”Better WER retention through feature matching
  • โ€”More robust via SpecAugment regularization
  • โ€”Smoother training via temperature scheduling

๐Ÿ”ฌ Technical Details

Distillation Architecture

Teacher (Large)          Student (Base)
     โ”‚                        โ”‚
     โ”œโ”€ Layer 0 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> Layer 0  (Feature Match)
     โ”œโ”€ Layer 6 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> Layer 3  (Feature Match)
     โ”œโ”€ Layer 12 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> Layer 6  (Feature Match)
     โ”œโ”€ Layer 18 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> Layer 9  (Feature Match)
     โ””โ”€ Layer 24 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> Layer 12 (Feature Match)
             โ”‚                    โ”‚
             โ””โ”€โ”€โ”€ Logits KL-Div โ”€โ”€โ”˜

Loss Function

L = ฮฑยทKL(S||T) + ฮฒยทCTC(S,y) + ฮณยทMSE(H_s,H_t)

Where:
  ฮฑ = 0.4 (logit distillation weight)
  ฮฒ = 0.4 (hard CTC weight)
  ฮณ = 0.2 (feature distillation weight)
  T = temperature (scheduled 4.0โ†’1.5)

SpecAugment Configuration

  • โ€”Time masking: 2 masks ร— 80 frames
  • โ€”Frequency masking: 2 masks ร— 27 bins

๐Ÿ’ป Usage

Basic Inference

python
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
import torch
import torchaudio

# Load model
processor = Wav2Vec2Processor.from_pretrained("abidanoaman/urdu-asr-distilled-base-enhanced")
model = Wav2Vec2ForCTC.from_pretrained("abidanoaman/urdu-asr-distilled-base-enhanced")

# Load audio
audio, sr = torchaudio.load("audio.wav")
if sr != 16000:
    resampler = torchaudio.transforms.Resample(sr, 16000)
    audio = resampler(audio)

# Transcribe
inputs = processor(audio.squeeze().numpy(), sampling_rate=16000, return_tensors="pt")
with torch.no_grad():
    logits = model(inputs.input_values).logits

pred_ids = torch.argmax(logits, dim=-1)
transcription = processor.decode(pred_ids[0])
print(transcription)

๐Ÿš€ Deployment

Perfect for production environments requiring:

  • โ€”โœ… Real-time transcription (< 0.01s latency)
  • โ€”โœ… Low memory footprint (94MB)
  • โ€”โœ… Edge deployment (Raspberry Pi, mobile)
  • โ€”โœ… Cost-efficient scaling

๐Ÿ“ˆ Training Details

Enhanced Techniques

  1. 1.Feature-level distillation: Match hidden representations across 5 layer pairs
  2. 2.Temperature scheduling: Linear decay from 4.0 to 1.5
  3. 3.SpecAugment: Robust to time/frequency variations

Hyperparameters

  • โ€”Epochs: 50
  • โ€”Learning rate: 3e-05
  • โ€”Batch size: 4
  • โ€”Loss weights: ฮฑ=0.4, ฮฒ=0.4, ฮณ=0.2

๐ŸŽฏ Benchmark Comparison

ModelTechniqueWERSizeSpeed
This ModelAll49.4%94M2.4x
Standard KDLogits only~51.4%94M2.4x
Teacher-38.1%315M1.0x

๐Ÿ“š Citation

bibtex
@misc{urdu-asr-enhanced-2024,
  author = {Abid Anoaman},
  title = {Enhanced Distilled Urdu ASR with Feature Matching and SpecAugment},
  year = {2024},
  publisher = {HuggingFace},
  url = {https://huggingface.co/abidanoaman/urdu-asr-distilled-base-enhanced}
}

๐Ÿ“„ License

Apache 2.0

๐Ÿ™ Acknowledgments

  • โ€”Teacher Model: abidanoaman/urdu-asr-complete-ablation
  • โ€”Base Architecture: facebook/wav2vec2-base
  • โ€”Techniques: Feature Distillation, Temperature Scheduling, SpecAugment