We present an approximate attention mechanism named HyperAttention to address the computational challenges posed by the growing complexity of long contexts used in Large Language Models (LLMs). Recent work suggests that in the worst-case scenario, quadratic time is necessary unless the entries of the attention matrix are bounded or the matrix has low stable rank. We introduce two parameters which measure: (1) the max column norm in the normalized attention matrix, and (2) the ratio of row norms in the unnormalized attention matrix after detecting and removing large entries. We use these fine-grained parameters to capture the hardness of the problem. Despite previous lower bounds, we are able to achieve a linear time sampling algorithm even when the matrix has unbounded entries or a large stable rank, provided the above parameters are small. HyperAttention features a modular design that easily accommodates integration of other fast low-level implementations, particularly FlashAttention. Empirically, employing Locality Sensitive Hashing (LSH) to identify large entries, HyperAttention outperforms existing methods, giving significant speed improvements compared to state-of-the-art solutions like FlashAttention. We validate the empirical performance of HyperAttention on a variety of different long-context length datasets. For example, HyperAttention makes the inference time of ChatGLM2 50\% faster on 32k context length while perplexity increases from 5.6 to 6.3. On larger context length, e.g., 131k, with causal masking, HyperAttention offers 5-fold speedup on a single attention layer.
Efficient Attention via Pre-Scoring: Prioritizing Informative Keys in Transformers
Carnegie Mellon University, Pittsburgh, USA;University of Southern California, Los Angeles, CA, USA;University of California, San Diego, Department of Mathematics, La Jolla, CA, USA;University of California, Davis, Applied Mathematics \& Statistics, Davis, CA, USA;Carnegie Mellon University, Pittsburgh, PA, USA
QSAN: A Near-term Achievable Quantum Self-Attention Network
Northwestern Polytechnical University(西北工业大学);Key Laboratory of Intelligent Interaction and Applications (Northwestern Polytechnical University), Ministry of Industry and Information Technology(工业和信息化部智能交互与应用重点实验室(西北工业大学))
Near-Oracle KV Selection via Pre-hoc Sparsity for Long-Context Inference
University College London(伦敦大学学院);Shenzhen Institutes of Advanced Technology, Chinese Academy of Sciences (CAS)(深圳先进技术研究院,中国科学院);Chinese University of Hong Kong(香港中文大学);College of Computing & Data Science, Nanyang Technological University(computing 与数据科学学院,南洋理工大学)
Stochastic Clock Attention for Aligning Continuous and Ordered Sequences
Department of Physics Education, Seoul National University, Seoul 08826, Korea(物理教育系,首尔国立大学);Center for Theoretical Physics and Artificial Intelligence Institute, Seoul National University, Seoul 08826, Korea(理论物理与人工智能研究所,首尔国立大学);Artificial Intelligence Institute, Seoul National University, Seoul 08826, Korea(人工智能研究所,首尔国立大学);School of Computational Sciences, Korea Institute for Advanced Study, Seoul 02455, Korea(计算科学学院,韩国高级研究院)
Courant Institute of Mathematical Sciences, New York University(纽约大学柯朗数学科学研究所);Center for Data Science, New York University(纽约大学数据科学中心);Flatiron Institute(弗拉蒂隆研究所)
FMMformer: Efficient and Flexible Transformer via Decomposed Near-field and Far-field Attention
University of California, Los Angeles(加利福尼亚大学洛杉矶分校);University of Utah(犹他大学);University of California, Irvine(加利福尼亚大学欧文分校)
我们提出FMMformers,一类高效和灵活的Transformers的灵感来自著名的快速多极子方法(FMM)加速相互作用的粒子模拟。FMM将粒子间的相互作用分解为近场和远场分量,分别进行直接计算和粗粒度计算。类似地,FMMformer将注意力分解为近场注意力和远场注意力,通过带状矩阵对近场注意力进行建模,通过低秩矩阵对远场注意力进行建模。计算FMMformer的注意矩阵需要相对于序列长度的计算时间和存储器占用的线性复杂度。相比之下,标准Transformers遭受二次复杂性。我们分析并验证了FMMformer在Long Range Arena和语言建模基准测试中相对于标准Transformer的优势。FMMformer甚至可以在精度方面远远超过标准Transformer。例如,FMMformer在五个长距离竞技场任务上实现$60.74\%$的平均分类准确度,这显著优于标准Transformer的$58.70\%$的平均准确度。
SeerAttention-R: Sparse Attention Adaptation for Long Reasoning
Microsoft Research(微软研究院);The University of Hong Kong(香港大学);Huazhong University of Science and Technology(华中科技大学);Peking University(北京大学);Tsinghua University(清华大学)
Departement Mathematik und Statistik, University of Bern(伯尔尼大学数学与统计学系);Department of Mathematics, Massachusetts Institute of Technology(麻省理工学院数学系);Department of Electrical Engineering and Computer Science, Massachusetts Institute of Technology(麻省理工学院电气工程与计算机科学系)