arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2406.02542cs.LG
收藏

Loki:用于高效稀疏注意力的低秩键

Loki: Low-rank Keys for Efficient Sparse Attention

University of Maryland(马里兰大学)

Prajwal Singhania, Siddharth Singh, Shwai He, Soheil Feizi, Abhinav Bhatele

AI总结:

本文提出Loki稀疏注意力方法,利用键向量低秩特性在低维空间计算注意力分数以选择KV缓存中的令牌,从而降低数据移动和计算成本,加速LLM推理并保持模型性能。

摘要:

大型语言模型(LLM)的推理在计算和内存成本方面可能非常昂贵,尤其是在使用长序列长度时。特别是,LLM推理中使用的自注意力机制对这些成本贡献显著,这引发了人们对近似自注意力计算以降低此类成本的兴趣。在这项工作中,我们提出通过关注注意力块中计算的键向量的维度来近似自注意力。我们的分析揭示,键向量位于一个显著更低维的空间中,这一发现在多个数据集和模型中保持一致。利用这一观察,我们提出了Loki,一种新颖的稀疏注意力方法,它基于在低维空间中计算的注意力分数对KV缓存中的令牌进行排名和选择。我们的评估表明,由于减少了数据移动(加载/存储)和计算成本,Loki能够加速注意力计算,同时比其它流行的近似方法更好地保持模型的有效性。

英文摘要:

Inference on large language models (LLMs) can be expensive in terms of the compute and memory costs involved, especially when long sequence lengths are used. In particular, the self-attention mechanism used in LLM inference contributes significantly to these costs, which has sparked an interest in approximating the self-attention computation to reduce such costs. In this work, we propose to approximate self-attention by focusing on the dimensionality of key vectors computed in the attention block. Our analysis reveals that key vectors lie in a significantly lower-dimensional space, consistently across several datasets and models. Exploiting this observation, we propose Loki, a novel sparse attention method that ranks and selects tokens in the KV-cache based on attention scores computed in low-dimensional space. Our evaluations show that Loki is able to speed up the attention computation due to reduced data movement (load/store) and compute costs while maintaining the efficacy of the models better than other popular approximation methods.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑