[Paper Review] Tiny Transformers for Environmental Sound Classification at the Edge
This paper proposes a highly efficient, BERT-based Transformer model for environmental sound classification on edge devices, using Mel spectrograms and self-supervised pretraining. Trained on the Office Sounds dataset, the model achieves state-of-the-art accuracy with just 6,642 parameters—99.85% smaller than a comparable CNN—while enabling real-time inference on mobile and microcontroller platforms.
With the growth of the Internet of Things and the rise of Big Data, data processing and machine learning applications are being moved to cheap and low size, weight, and power (SWaP) devices at the edge, often in the form of mobile phones, embedded systems, or microcontrollers. The field of Cyber-Physical Measurements and Signature Intelligence (MASINT) makes use of these devices to analyze and exploit data in ways not otherwise possible, which results in increased data quality, increased security, and decreased bandwidth. However, methods to train and deploy models at the edge are limited, and models with sufficient accuracy are often too large for the edge device. Therefore, there is a clear need for techniques to create efficient AI/ML at the edge. This work presents training techniques for audio models in the field of environmental sound classification at the edge. Specifically, we design and train Transformers to classify office sounds in audio clips. Results show that a BERT-based Transformer, trained on Mel spectrograms, can outperform a CNN using 99.85% fewer parameters. To achieve this result, we first tested several audio feature extraction techniques designed for Transformers, using ESC-50 for evaluation, along with various augmentations. Our final model outperforms the state-of-the-art MFCC-based CNN on the office sounds dataset, using just over 6,000 parameters -- small enough to run on a microcontroller.
Motivation & Objective
- Address the challenge of deploying accurate, efficient machine learning models for environmental sound classification (ESC) on low-power, edge devices with limited size, weight, and power (SWaP).
- Overcome the limitations of existing CNNs and Transformers in ESC by designing a compact, parameter-efficient model suitable for microcontrollers and mobile devices.
- Demonstrate that small, fine-tuned Transformers can outperform larger CNNs on a specific ESC dataset (Office Sounds) despite poor performance on standard benchmarks like ESC-50.
- Enable on-device inference and potential on-device retraining by minimizing model size and computational cost.
Proposed method
- Pretrain a BERT-based Transformer on Mel spectrograms of audio clips using self-attention mechanisms and masked prediction objectives.
- Fine-tune the pre-trained model on the Office Sounds dataset using standard cross-entropy loss for multi-class classification.
- Use data augmentation techniques such as time shifting, noise injection, and frequency masking to improve robustness and generalization.
- Apply dynamic quantization to reduce model size and inference latency, enabling deployment on edge devices like the Samsung Galaxy S9.
- Evaluate performance using standard metrics such as validation accuracy and inference latency on both mobile and microcontroller platforms.
- Compare model performance and efficiency against a state-of-the-art MFCC-based CNN, using parameter count, FLOPs, and inference time as key efficiency metrics.
Experimental results
Research questions
- RQ1Can a small, efficient Transformer model achieve superior accuracy compared to a much larger CNN for environmental sound classification on edge devices?
- RQ2How does model size and parameter count affect inference speed and energy efficiency on mobile and microcontroller platforms?
- RQ3Why do Transformers outperform CNNs on the Office Sounds dataset despite underperforming on the larger, more diverse ESC-50 dataset?
- RQ4To what extent can quantization and model compression techniques reduce latency and memory footprint without sacrificing accuracy?
- RQ5Is on-device retraining feasible for such tiny models, given their minimal computational cost per forward pass?
Key findings
- The proposed 6,642-parameter Transformer outperformed a 4.47 million-parameter CNN on the Office Sounds dataset by more than 2% in validation accuracy.
- The model achieved a 99.85% reduction in parameters compared to the CNN while maintaining higher accuracy, demonstrating significant efficiency gains.
- Inference latency on a Samsung Galaxy S9 was reduced to 7ms for the smallest model, 88% faster than the CNN and 93% faster than a 1-million-parameter Transformer.
- Dynamic quantization reduced inference latency by 21%, suggesting further optimization potential with static quantization.
- The model achieved 95.2% accuracy on 5-second audio clips, with performance dropping significantly when reduced to 1-second inputs, indicating a trade-off between speed and accuracy.
- The model's success on Office Sounds—where each class had 200+ samples—suggests that larger, balanced datasets may be critical for Transformer generalization in ESC.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.