Dual Triangle Attention: Effective Bidirectional Attention Without Positional Embeddings
Not on the map. Why?
Abstract (arXiv)
Bidirectional transformers are the foundation of many sequence modeling tasks across natural, biological, and chemical language domains, but they are permutation-invariant without explicit positional embeddings. In contrast, unidirectional attention inherently encodes positional information through its triangular mask, enabling models to operate without positional embeddings altogether. Here, we introduce Dual Triangle Attention, a novel bidirectional attention mechanism that separates the query-key subspace of each attention head into two complementary triangular masks: one that attends to past-and-self positions and one that attends to future-and-self positions. This design provides bidirectional context while maintaining the causal mask's implicit positional inductive bias in both directions. Using PyTorch's flex_attention, Dual Triangle Attention is implemented as a single compiled kernel call with no additional parameters beyond standard multi-head attention. We evaluated Dual Triangle Attention across three settings: (1) a synthetic argmax position probe, (2) masked language modeling (MLM) on natural language, and (3) MLM on protein sequences. In the argmax task, both Dual Triangle Attention and causal attention learn positional information without explicit positional embeddings, whereas standard bidirectional attention cannot. In the MLM experiments, Dual Triangle Attention with Rotary Positional Embeddings (RoPE) achieved the best context extension performance and strong performance across the board. These findings suggest that Dual Triangle Attention is a viable attention mechanism for bidirectional transformers, with or without positional embeddings.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 28 of its 53 references that are in the map. First posted on arXiv 9 Apr 2026.
Builds on
28 of 53 references.
References · 28
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
- 2015U-Net: Convolutional Networks for Biomedical Image Segmentationcited by 19,713
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
- 2016Layer Normalizationcited by 5,669
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
- 2023Mistral 7Bcited by 3,164
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,918
- 2020DeBERTa: Decoding-enhanced BERT with Disentangled Attentioncited by 2,181
- 2017Mixed Precision Trainingcited by 1,156
- 2018Self-Attention with Relative Position Representationscited by 1,120
16 more
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
- 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 601
- 2024Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inferencecited by 554
- 2022All are Worth Words: A ViT Backbone for Diffusion Modelscited by 502
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 327
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
- 2024Flex Attention: A Programming Model for Generating Optimized Attention Kernelscited by 185
- 2022Transformer Language Models without Positional Encodings Still Learn Positional Informationcited by 150
- 2022A Length-Extrapolatable Transformercited by 127
- 2024Round and Round We Go! What makes Rotary Positional Encodings useful?cited by 115
- 2021Position Information in Transformers: An Overviewcited by 103
- 2024Diffusion Language Models Are Versatile Protein Learnerscited by 98
- 2024Contextual Position Encoding: Learning to Count What's Importantcited by 54
- 2024Length Generalization of Causal Transformers without Position Encodingcited by 47
- 2025Rope to Nope and Back Again: A New Hybrid Attention Strategycited by 47
- 2025Extending the Context of Pretrained LLMs by Dropping Their Positional Embeddingscited by 26
Built on by
Not cited yet.