Add Positional Encoding in Conformer Implementation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 799
- Avg merge
- 58m
- Merged PRs (30d)
- 3
Description
Missing Relative Positional Encoding in Conformer Implementation
Issue Description
The current Conformer implementation in Torchaudio is missing the relative sinusoidal positional encoding scheme that is a key component of the original Conformer architecture as described in the paper "Conformer: Convolution-augmented Transformer for Speech Recognition".
Details
In the original paper, section 2.1 "Multi-Headed Self-Attention Module" specifically states:
"We employ multi-headed self-attention (MHSA) while integrating an important technique from Transformer-XL [20], the relative sinusoidal positional encoding scheme. The relative positional encoding allows the self-attention module to generalize better on different input length and the resulting encoder is more robust to the variance of the utterance length."
However, the current implementation in conformer.py uses standard PyTorch MultiheadAttention without implementing the relative positional encoding:
self.self_attn = torch.nn.MultiheadAttention(input_dim, num_attention_heads, dropout=dropout)
Reference Implementation
For reference, NVIDIA's NeMo library does properly implement the positional encoding in their Conformer implementation: https://github.com/NVIDIA/NeMo/blob/main/nemo/collections/asr/modules/conformer_encoder.py
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in conformer.py by reading the current torch.nn.MultiheadAttention setup and compare its behavior with the relative sinusoidal positional encoding described in section 2.1 of the Conformer paper. Use NVIDIA NeMo's conformer_encoder.py as the reference implementation. Done means the Conformer implementation includes the missing relative positional encoding scheme and preserves the intended attention behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100