Lune

ICML2024Top-tier venue

StableMask: Refining Causal Masking in Decoder-only Transformer

Qingyu Yin, Xuzheng He, Xiang Zhuang, Yu Zhao, Jianhua Yao, Xiaoyu Shen, Qiang Zhang

Abstract

The decoder-only Transformer architecture with causal masking and relative position encoding (RPE) has become the de facto choice in language modeling. Despite its exceptional performance across various tasks, we have identified two limitations: First, it requires all attention scores to be non-zero and sum up to 1, even if the current embedding has sufficient self-contained information. This compels the model to assign disproportional excessive attention to specific tokens. Second, RPE-based Transformers are not universal approximators due to their limited capacity at encoding absolute positional information, which limits their application in position-critical tasks. In this work, we propose StableMask: a parameter-free method to address both limitations by refining the causal mask. It introduces pseudo-attention values to balance attention distributions and encodes absolute positional information via a progressively decreasing mask ratio. StableMask's effectiveness is validated both theoretically and empirically, showing significant enhancements in language models with parameter sizes ranging from 71M to 1.4B across diverse datasets and encoding methods. We further show that it naturally supports (1) efficient extrapolation without special tricks such as StreamingLLM and (2) easy integration with existing attention optimization techniques.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

8 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Efficient Streaming Language Models with Attention Sinks cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
  • Efficient Streaming Language Models with Attention Sinks cites FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Efficient Streaming Language Models with Attention Sinks cites Vision Transformers Need Registers
  • Efficient Streaming Language Models with Attention Sinks cites Language Models are Few-Shot Learners
  • Aligning What Vision-Language Models See and Perceive with Adaptive Information Flow cites Rethinking Causal Mask Attention for Vision-Language Inference
  • Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation cites Language Models are Few-Shot Learners
  • FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness cites Language Models are Few-Shot Learners
  • ModRWKV: Transformer Multimodality in Linear Time cites FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Rethinking Causal Mask Attention for Vision-Language Inference cites Efficient Streaming Language Models with Attention Sinks
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers8

  1. Rethinking Causal Mask Attention for Vision-Language InferenceXiaohuan Pei, Tao Huang, Yanxiang Ma, Chang XuICLR 2026 · 7 citations
  2. MiSS: Revisiting the Trade-off in LoRA with an Efficient Shard-Sharing StructureJiale Kang, Qingyu YinICLR 2026 · 3 citations
  3. Aligning What Vision-Language Models See and Perceive with Adaptive Information FlowChengxin Liu, Wonseok Choi, Chenshuang Zhang, Tae-Hyun OhCVPR 2026 · 2 citations
  4. Rethinking Key-Frame-Based Micro-Expression Recognition: a Robust and Accurate Framework Against Key-Frame ErrorsZheyuan Zhang, Weihao Tang, Hong ChenICCV 2025 · 2 citations
  5. ModRWKV: Transformer Multimodality in Linear TimeJiale Kang, Ziyin Yue, Qingyu Yin, Rui Jiang et al.EMNLP 2025

Builds on17

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra et al.NeurIPS 2022 · 5,493 citations
  3. Efficient Streaming Language Models with Attention SinksGuangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han et al.ICLR 2024 · 1,714 citations
  4. Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 citations
  5. Vision Transformers Need RegistersTimothée Darcet, Maxime Oquab, Julien Mairal, Piotr BojanowskiICLR 2024 · 769 citations

Related papers

  1. SWAN: An Efficient and Scalable Approach for Long-Context Language ModelingKrishna C. Puvvada, Faisal Ladhak, Santiago Akle Serano, Cheng-Ping Hsieh et al.EMNLP 2025
  2. A Length-Extrapolatable TransformerYutao Sun, Li Dong, Barun Patra, Shuming Ma et al.ACL 2023 · 45 citations
  3. Transformer Language Models without Positional Encodings Still Learn Positional InformationAdi Haviv, Ori Ram, Ofir Press, Peter Izsak et al.EMNLP Findings 2022 · 61 citations
  4. Context-aware Biases for Length ExtrapolationAli Veisi, Hamidreza Amirzadeh, Amir MansourianEMNLP 2025 · 2 citations
  5. Functional Interpolation for Relative Positions improves Long Context TransformersShanda Li, Chong You, Guru Guruganesh, Joshua Ainslie et al.ICLR 2024 · 66 citations
Dusk over the sea between two cliffs drawn in fine vertical lines