Positional encoding in transformers is commonly implemented through positional embeddings, attention masks, or bias terms, but formal connections between these mechanisms remain limited. We study attention with positional bias through the lens of locality-sensitive hashing (LSH), focusing on Attention with Linear Biases (ALiBi). We show that the ALiBi bias matrix is the expectation of contiguous block-diagonal binary masks induced by a ``positional LSH'' scheme. The empirical mean of masks sampled from this scheme yields spectral norm and max-norm approximation guarantees with bounded block sizes with high probability. This structural theorem implies an efficient approximation algorithm for ALiBi-biased attention: with high probability over the sampled masks, the approximate attention output is accurate simultaneously for all query-key-value inputs and can be computed in near-linear time in the context length, reducing long-context ALiBi to a collection of randomized short-context regular (positionally unbiased) attention operations. Conceptually, this connects positional bias, masks, and positional embeddings in a single formal framework and suggests an approach to efficient ALiBi-biased attention. Experiments on large language models validate our theoretical findings.
Deconstructing Positional Information: From Attention Logits to Training Biases
Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所);School of Cyber Security, University of Chinese Academy of Sciences(中国科学院大学网络安全学院);Antai College of Economics and Management, Shanghai Jiao Tong University(上海交通大学安泰经济管理学院)
HSE University(俄罗斯国立高等经济大学);Lomonosov Moscow State University(莫斯科国立大学);Harbin Institute of Technology(哈尔滨工业大学);ISP RAS(俄罗斯科学院系统编程研究所);RANEPA(俄罗斯总统国民经济与公共管理学院);ITMO University(圣彼得堡国立信息技术机械与光学大学);Skoltech(斯科尔科沃科学技术研究院)
Division of Mathematical Sciences, School of Physical and Mathematical Sciences, Nanyang Technological University(南洋理工大学物理与数学科学学院数学科学部);School of Computing, University of Kent(肯特大学计算机学院);Department of Computer Science and Technology, University of Cambridge(剑桥大学计算机科学与技术系)
Gradformer: Graph Transformer with Exponential Decay
School of Computer Science, Wuhan University(武汉大学计算机学院);JD Explore Academy, JD.com(京东探索研究院);School of Computing and Information Systems, The University of Melbourne(墨尔本大学计算与信息系统学院);School of Information and Communication Technology, Griffith University(格里菲斯大学信息与通信技术学院)