Attention mechanisms, particularly softmax attention, have been instrumental in the success of transformer-based models such as GPT. However, the quadratic memory complexity of softmax attention with respect to sequence length poses significant challenges for processing longer sequences. We introduce Cottention, a novel attention mechanism that replaces the softmax operation with cosine similarity. By leveraging the properties of cosine similarity and rearranging the attention equation, Cottention achieves native linear memory complexity with respect to sequence length, making it inherently more memory-efficient than softmax attention. We demonstrate that Cottention can be reformulated as a recurrent neural network (RNN) with a finite hidden state, allowing for constant memory usage during inference. We evaluate Cottention on both the bidirectional BERT and causal GPT tasks, demonstrating comparable performance to softmax attention while significantly reducing memory requirements. To ensure efficient computation, we develop a custom CUDA kernel for Cottention. Our results show that Cottention is a promising alternative to softmax attention, enabling the processing of longer sequences without sacrificing performance, due to its native linear memory complexity and ability to maintain a constant memory footprint during inference.
Discrete Cosine Transform Based Decorrelated Attention for Vision Transformers
Machine and Hybrid Intelligence Lab, Northwestern University(机器与混合智能实验室,西北大学);Department of Electrical and Computer Engineering, University of Illinois Chicago(电气与计算机工程系,伊利诺伊大学香槟分校)
Universal Dynamics of Warmup Stable Decay: understanding WSD beyond Transformers
MPI-IS Tübingen, Germany, ETH Zürich, Switzerland and Politecnico di Torino, Italy(马克斯·普朗克研究所(MPI-IS)图宾根,德国,瑞士苏黎世联邦理工学院(ETH Zürich)和意大利托里诺理工大学(Politecnico di Torino));ETH Zürich, Switzerland(瑞士苏黎世联邦理工学院(ETH Zürich));MPI-IS, ELLIS Institute Tübingen, Tübingen AI Center, Germany(马克斯·普朗克研究所(MPI-IS)图宾根,德国,图宾根人工智能中心(Tübingen AI Center))
AtMan: Understanding Transformer Predictions Through Memory Efficient Attention Manipulation
Aleph Alpha(阿列夫阿尔法);Technical University Darmstadt(达姆施塔特工业大学);Hessian Center for Artificial Intelligence (hessian.AI)(黑森州人工智能中心);German Center for Artificial Intelligence (DFKI)(德国人工智能研究中心);LAION
Understanding Gated Neurons in Transformers from Their Input-Output Functionality
Center for Information and Language Processing (CIS), LMU Munich, and Munich Center for Machine Learning (MCML), Germany(信息与语言处理中心(CIS)、慕尼黑大学(LMU Munich)及慕尼黑机器学习中心(MCML))
Large Language Models Inference Engines based on Spiking Neural Networks
Mathematics and Computer Science Division Argonne National Laboratory(阿贡国家实验室数学与计算机科学部);Computer Science and Mathematics Division Oak Ridge National Laboratory(橡树岭国家实验室计算机科学与数学部)