A Novel Loss Function and Training Strategy for Noise-Robust Keyword Spotting

Iván López-Espejo, Zheng-Hua Tan, Jesper JensenIEEE/ACM Trans. ASLP 2021

Keyword Spotting (KWS) is the technology behind ubiquitous "always-on" listeners like "Hey Siri" and "Alexa." While these systems perform reliably in quiet environments, their accuracy often degrades significantly in real-world conditions such as busy cafes, windy streets, or noisy vehicles. Researchers from Aalborg University address this challenge by proposing a two-stage training strategy and a novel loss function designed to enhance model resilience to background noise without increasing computational overhead or model size.

The Challenge of Noise Robustness

The primary obstacle in KWS is maintaining performance under "unseen" noise conditions—sounds the model did not encounter during training. Traditional models are often trained end-to-end using cross-entropy loss. While effective for classification, this approach does not necessarily encourage the model to learn internal representations that are robust to acoustic interference.

Existing solutions often involve adding speech enhancement "front-ends" to clean audio signals. However, these additions increase model complexity and latency, making them unsuitable for low-power, resource-constrained devices like smartwatches or hearing aids. The researchers sought to bake robustness directly into the model's feature representation through an optimized training process.

Proposed Methodology: Two-Stage Training

The authors decouple the training process into two distinct phases to prioritize the quality of the learned audio features.

The two-stage neural network architecture for keyword spotting.
  1. Stage 1: Training the Embedding Extractor: The bulk of the network is first trained to function as an "embedding extractor." Instead of immediate classification, the goal is to map audio inputs into a high-dimensional space where different keywords are clearly separated.
  2. Stage 2: Training the Linear Classifier: Once a robust embedding space is established, the extractor's weights are frozen. A simple linear layer is then trained on top of these embeddings to perform the final classification.

The $(C_{N,2} + 1)$-pair Loss

The core innovation lies in the introduction of the $(C_{N,2} + 1)$-pair loss used during Stage 1. This loss function is an evolution of triplet and $N$-pair losses.

Comparison of various loss functions, highlighting the proposed (CN,2 + 1)-pair loss (e).

Standard triplet loss focuses on pushing a single "negative" example away from an "anchor." In contrast, the proposed loss function forces all negative examples within a training batch to be maximally distant from one another, while simultaneously pulling "positive" examples (the same keyword under different noise conditions) closer together. This "all-pairs" negative distancing creates highly isolated and distinct clusters for each word class, significantly reducing intra-class variation and maximizing inter-class separation.

Experimental Setup and Datasets

The methodology was validated using two major benchmarks:

  • Google Speech Commands Dataset (GSCD): A standard set of 35 keywords. The researchers synthesized a noisy version by mixing the original audio with sounds from the NOISEX-92 and CHiME-3 databases.
  • Hey Snapdragon Keyword Dataset (HSKD): A specialized dataset used to evaluate generalization across different keywords and smaller model architectures.

To ensure a rigorous evaluation of noise robustness, the researchers partitioned the noise types into "seen" (used during training) and "unseen" (reserved for testing) categories.

Key Results and Insights

The proposed training strategy yielded significant performance gains:

  • 12% Relative Improvement: On the GSCD, the model achieved a 12% relative improvement in accuracy under unseen noise conditions compared to standard end-to-end training.
  • Zero Inference Cost: Because the complexity is confined to the training phase, the final deployed model remains identical in size and speed to a standard baseline.
  • Efficiency and Convergence: Despite the more complex loss formulation, the models reached peak performance in fewer training epochs than those using $N$-pair or triplet loss.
  • High Performance with Fewer Parameters: The "Baseline + New Strategy" model achieved 97.18% accuracy on the original GSCD with only 238k parameters, outperforming much larger architectures like Attention-RNNs (743k parameters).

Conclusion and Future Directions

The study demonstrates that focusing on the structure of the embedding space is a powerful way to achieve noise robustness in KWS. By enforcing distance between all negative classes, the model learns a more resilient representation of speech. Future research may explore the sensitivity of the loss function's balancing hyperparameter ($\lambda$) and the method's effectiveness against other types of audio distortion, such as room reverberation.

Summary updated

BibTeX
@article{lopezespejo2021novel,
  author = {Iván López-Espejo and Zheng-Hua Tan and Jesper Jensen},
  title = {{A Novel Loss Function and Training Strategy for Noise-Robust Keyword Spotting}},
  journal = {IEEE ACM Trans. Audio Speech Lang. Process.},
  year = {2021},
  doi = {10.1109/taslp.2021.3092567},
}
Figure