arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.18668cs.CLcs.LG
收藏

简单的线性注意力语言模型平衡了召回率与吞吐量的权衡

Simple linear attention language models balance the recall-throughput tradeoff

Stanford University(斯坦福大学);University at Buffalo(布法罗大学);Purdue University(普渡大学)

Simran Arora, Sabri Eyuboglu, Michael Zhang, Aman Timalsina, Silas Alberti, Dylan Zinsley, James Zou, Atri Rudra, Christopher Ré

AI总结:

本研究提出 BASED 架构,结合线性注意力与滑动窗口注意力,通过调节状态大小平衡召回率与内存权衡,在召回密集型任务上超越 Mamba 等,并开发 IO-aware 算法实现比 FlashAttention-2 高 24 倍的吞吐量。

摘要:

最近的工作表明,基于注意力的语言模型在召回率(即生成内容基于上下文中先前出现过的token的能力)方面表现优异。然而,注意力模型在推理时的效率受到 KV-cache 巨大内存消耗的瓶颈限制。在本研究中,我们探讨了是否能在不损害召回率的前提下提升语言模型效率(例如通过减少内存消耗)。通过将实验和理论应用于一系列广泛的架构,我们确定了模型状态大小与召回能力之间的关键权衡。我们表明,注意力的有效替代方案(如 H3、Mamba、RWKV)虽然维持了固定大小的循环状态,但在召回任务上表现不佳。我们提出了 BASED,一种结合了线性注意力和滑动窗口注意力的简单架构。通过调整 BASED 的窗口大小和线性注意力特征维度,我们可以调节状态大小,并遍历召回率-内存权衡曲线的帕累托前沿,一端恢复注意力的完整质量,另一端达到注意力替代方案的小状态大小。我们训练了参数量高达 1.3b 的语言模型,并表明 BASED 在困惑度上与最强的次二次模型(如 Mamba)相当,且在真实世界中的召回密集型任务上以 6.22 个准确率点超越它们。线性注意力的实现通常不如优化的标准注意力实现高效。为使 BASED 具竞争力,我们开发了 IO-aware 算法,在使用 1.3b 参数模型生成 1024 个 token 时,语言生成的吞吐量比 FlashAttention-2 高出 24 倍。本工作的代码提供于:https://github.com/HazyResearch/based。

英文摘要:

Recent work has shown that attention-based language models excel at recall, the ability to ground generations in tokens previously seen in context. However, the efficiency of attention-based models is bottle-necked during inference by the KV-cache's aggressive memory consumption. In this work, we explore whether we can improve language model efficiency (e.g. by reducing memory consumption) without compromising on recall. By applying experiments and theory to a broad set of architectures, we identify a key tradeoff between a model's state size and recall ability. We show that efficient alternatives to attention (e.g. H3, Mamba, RWKV) maintain a fixed-size recurrent state, but struggle at recall. We propose BASED a simple architecture combining linear and sliding window attention. By varying BASED window size and linear attention feature dimension, we can dial the state size and traverse the pareto frontier of the recall-memory tradeoff curve, recovering the full quality of attention on one end and the small state size of attention-alternatives on the other. We train language models up to 1.3b parameters and show that BASED matches the strongest sub-quadratic models (e.g. Mamba) in perplexity and outperforms them on real-world recall-intensive tasks by 6.22 accuracy points. Implementations of linear attention are often less efficient than optimized standard attention implementations. To make BASED competitive, we develop IO-aware algorithms that enable 24x higher throughput on language generation than FlashAttention-2, when generating 1024 tokens using 1.3b parameter models. Code for this work is provided at: https://github.com/HazyResearch/based.

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

↑