This repo contains my solution to a model optimization assignment: compress and speed up a speech command classifier while keeping accuracy as high as possible.
The task is based on the Torchaudio SpeechCommands dataset and the M5 convolutional architecture for raw-waveform speech recognition.
Starting from a pretrained FP32 M5 model:
| Model | Accuracy | Inference Speed (CPU) | Size |
|---|---|---|---|
| FP32 baseline | 88.34 % | 1× | 1.48 MB |
| Final compressed (Intel NC QAT) | 85.40 % | ≈ 3.2× faster | 0.39 MB |
The final model is ~3.7× smaller and ~3.2× faster on CPU, with a 2.9 pp absolute drop in accuracy.
This project is meant to showcase my experience with model compression for deployment:
-
End-to-end PyTorch pipeline
- Raw-waveform speech classification with Torchaudio’s dataset (train/val/test splits, custom collate, padding, resampling).
- Reproducible training loop, LR schedulers, and checkpointing.
-
Multiple compression strategies
- Post-Training Quantization (PTQ): eager-mode, FX Graph Mode.
- Quantization-Aware Training (QAT): PyTorch + Intel Neural Compressor.
- Mixed precision & accuracy‑aware experiments.
-
Architecture & training explorations
- Teacher CNNs (M11, M18) for distillation feasibility.
- Layer-wise quantization sensitivity analysis.
- Activation‑range‑friendly architectures for QAT stability.
-
Evaluation & analysis
- CPU latency benchmarking.
- Per‑class accuracy and confusion matrix analysis.
- Structured channel pruning with fine‑tuning.
- Teacher-student distillation with improved teacher models.
- Layer‑wise mixed‑precision search for optimal trade‑offs.