Abstract
Transformer architecture has enabled recent progress in speech enhancement. Since Transformers are position-agnostic, positional encoding (PE) is the de facto standard component used to enable Transformers to distinguish the order of elements in a sequence. However, it remains unclear how positional encoding exactly impacts speech enhancement based on Transformer architectures. In this paper, we perform a comprehensive empirical study evaluating five positional encoding methods—Sinusoidal and learned absolute position embedding (APE), T5-RPE, KERPLE, as well as the Transformer without positional encoding (No-Pos)—across both causal and noncausal configurations. Our findings establish that positional encoding is not quite helpful for models in a causal configuration, indicating that causal attention may implicitly incorporate position information. In a noncausal configuration, however, models significantly benefit from positional encoding, with relative position embeddings (RPE) outperforming APEs.
Introduction
While Transformers have revolutionized speech processing by capturing long-range dependencies through self-attention, the mechanism is inherently "permutation-invariant." It treats a sequence like a bag of frames, ignoring temporal order unless positional information is explicitly injected. In the speech enhancement community, a lingering debate persists: is positional encoding actually necessary? Some argue that the inherent structure of a spectrogram provides enough implicit position information. This study provides a systematic empirical evaluation to settle this debate, comparing five encoding strategies across both causal (real-time) and noncausal (offline) Transformer configurations.
Methodology
The study evaluates a 4-layer Transformer architecture using two common training targets: Spectral Mapping (predicting the magnitude spectrum) and Spectral Masking (using a phase-sensitive mask). The architecture integrates positional information either at the input level (APE) or within the self-attention mechanism (RPE).
Five scenarios were compared:
- No-Pos: No positional information provided.
- Sinusoidal APE: Fixed sine/cosine functions.
- Learned APE: Trainable absolute position embeddings.
- T5-RPE: Relative encoding using log-binning for frame distances.
- KERPLE: Modeling relative distances via conditionally positive definite kernels.
Experiments were conducted using the LibriSpeech corpus (100 hours) for clean speech, mixed with a diverse array of noise datasets (MUSAN, RSG-10, etc.). Evaluation was performed on unseen noise sources at SNRs ranging from -5 dB to 15 dB.
The Role of Causality
A striking finding of this research is that the impact of PE is highly dependent on the model's causality.
- Causal Models: In real-time configurations, PE is largely redundant. This is because a causal mask—which prevents a frame from seeing future frames—is not permutation-invariant. A model at time step $t$ can effectively "count" its position based on the available context, meaning the mask itself acts as an implicit positional signal.
- Noncausal Models: Conversely, offline models that look at the entire sequence simultaneously are lost without PE. Without explicit order information, the model cannot distinguish the beginning of an utterance from the end, leading to significantly higher losses.
Key Results
In noncausal setups, adding PE provided a massive performance boost. For instance, at -5 dB SNR, moving from No-Pos to T5-RPE improved the PESQ from 1.78 to 2.05. Across all metrics (PESQ, ESTOI, CSIG, CBAK, and COVL), Relative Position Encodings (RPE) like T5-RPE and KERPLE consistently outperformed Absolute methods.
As shown in the loss curves, the "No-Pos" baseline exhibits the highest error, while RPE methods achieve the lowest training and validation losses, proving to be more robust than the standard sinusoidal approach.
Conclusion
This study demonstrates that while PE is essential for noncausal Transformers in speech enhancement, it is largely unnecessary for causal models due to the implicit temporal cues provided by causal masking. For practitioners, the results suggest that Relative Position Encoding should be the preferred choice for offline systems. Future work may extend these findings to multi-channel scenarios or explore newer methods like Rotary Positional Embeddings (RoPE).
Summary updated