Abstract
Self-attention mechanisms are highly effective for capturing long-range dependencies but suffer from performance degradation and memory constraints when applied to very long sequences. This paper introduces Gaussian kernelized self-attention, a shift-invariant reformulation of the attention mechanism. By incorporating a "frame indexing" technique, the proposed model generalizes effectively from short training segments to long-form audio. Experimental results on Connectionist Temporal Classification (CTC) based speech recognition demonstrate a significant reduction in Word Error Rate (WER) on long sequences—from 24.0% to 6.0%—outperforming standard self-attention and relative positional encoding while maintaining superior memory efficiency.
Introduction
Self-attention (SA) is the core component of Transformer architectures, excelling at capturing dependencies across speech signals. However, it faces two primary challenges with long sequences. First, length mismatch: models trained on short segments (e.g., 5–10 seconds) often fail when transcribing long recordings (e.g., 20-minute lectures) because they encounter absolute positions never seen during training. Second, computational complexity: standard SA has $O(L^2)$ complexity. While Relative Positional Encoding (RPE) mitigates the length mismatch, it can be prohibitively memory-intensive, sometimes requiring hundreds of gigabytes for very long sequences.
This research proposes a self-attention mechanism that is inherently shift-invariant, ensuring that the relationship between two frames is treated consistently regardless of their absolute position in a recording.
Methodology
The authors propose a two-step transformation to achieve shift-invariance in self-attention:
- Shared-QK Attention: The model utilizes identical weight matrices for Query ($W^{(Q)}$) and Key ($W^{(K)}$), which mathematically equates to a normalized kernel function.
- Gaussian Kernelization: Standard attention energy terms, which depend on absolute feature characteristics, are replaced with a Gaussian kernel. This kernel depends solely on the difference between features ($X_i - X_j$), rendering the mechanism shift-invariant.
- Frame Indexing: To maintain temporal awareness, raw frame indices ($i$) are appended to the input features ($X_i$). Due to the shift-invariant nature of the kernel, the model naturally learns to attend to the relative distance between frames ($i - j$) rather than absolute positions.
Experimental Evaluation
The method was evaluated on two major benchmarks:
- Corpus of Spontaneous Japanese (CSJ): Featuring a "long eval" set with an average sequence length of ~772 seconds.
- TED-LIUM 3: An English dataset of TED talks, with an average sequence length of ~1,004 seconds and individual talks reaching nearly 30 minutes.
Results and Discussion
The proposed Gaussian kernelized SA achieved massive accuracy gains. On the CSJ long evaluation set, it slashed the WER from 24.0% (standard SA) to 6.0%.
Key insights from the results include:
- Robustness to Length: As illustrated in the performance metrics, the proposed method maintains a nearly flat error rate as sequence length increases, unlike standard SA and RPE which show performance degradation.
- Visual Evidence: Attention heatmaps reveal that standard SA "disperses" its focus in long sequences, looking across the entire sequence without clarity. In contrast, the Gaussian kernelized version remains tightly focused on the relevant local acoustic context (the diagonal).
- Memory Efficiency: By avoiding the large intermediate tensors required by RPE, the proposed method remains practical for standard hardware even when processing extremely long audio files.
Conclusion
Gaussian kernelized self-attention with frame indexing provides a robust solution for long-sequence speech recognition. While currently limited to self-attention (where Query and Key matrices are shared), it offers a path toward more efficient and generalizable Transformer models. Future work will explore making the scaling factor ($\alpha$) learnable and extending the technique to RNN-T and full encoder-decoder Transformer architectures.
Summary updated