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

MemoryFormer: 通过移除全连接层来减少Transformer计算

MemoryFormer: Minimize Transformer Computation by Removing Fully-Connected Layers

State Key Lab of General AI, School of Intelligence Science and Technology, Peking University(人工智能国家重点实验室,智能科学与技术学院,北京大学);Huawei Noah’s Ark Lab(华为诺亚实验室);Huawei HiSilicon(华为海思)

Ning Ding, Yehui Tang, Haochen Qin, Zhenli Zhou, Chao Xu, Lin Li, Kai Han, Heng Liao, Yunhe Wang

AI总结:

MemoryFormer通过移除全连接层,利用内存查找表和哈希算法替代线性投影,显著降低Transformer计算复杂度并提升效率。

摘要:

为了降低大型语言模型的计算复杂度,人们已努力提高Transformer模型的效率,例如线性注意力和闪存注意力。然而,为了追求更高的性能,模型大小和相应的计算复杂度一直在增加。在本工作中,我们提出了一种新的Transformer架构,即MemoryFormer,从新的角度显著降低了计算复杂度(FLOPs)。我们几乎消除了Transformer模型的所有计算,除了多头注意力操作所需的必要计算。这得益于利用替代方法进行特征变换,以替代全连接层的线性投影。具体来说,我们首先构建一组存储大量离散向量的内存查找表,以替代线性投影中使用的权重矩阵。然后,我们使用哈希算法根据输入嵌入动态检索相关的一组向量。检索到的向量组合将形成输出嵌入,这提供了全连接层矩阵乘法操作结果的估计。与进行矩阵乘法相比,从内存中检索数据块是一项更便宜的操作,需要很少的计算。我们从头开始训练MemoryFormer,并在各种基准上进行广泛实验,以证明所提出模型的有效性。

英文摘要:

In order to reduce the computational complexity of large language models, great efforts have been made to to improve the efficiency of transformer models such as linear attention and flash-attention. However, the model size and corresponding computational complexity are constantly scaled up in pursuit of higher performance. In this work, we present MemoryFormer, a novel transformer architecture which significantly reduces the computational complexity (FLOPs) from a new perspective. We eliminate nearly all the computations of the transformer model except for the necessary computation required by the multi-head attention operation. This is made possible by utilizing an alternative method for feature transformation to replace the linear projection of fully-connected layers. Specifically, we first construct a group of in-memory lookup tables that store a large amount of discrete vectors to replace the weight matrix used in linear projection. We then use a hash algorithm to retrieve a correlated subset of vectors dynamically based on the input embedding. The retrieved vectors combined together will form the output embedding, which provides an estimation of the result of matrix multiplication operation in a fully-connected layer. Compared to conducting matrix multiplication, retrieving data blocks from memory is a much cheaper operation which requires little computations. We train MemoryFormer from scratch and conduct extensive experiments on various benchmarks to demonstrate the effectiveness of the proposed model.

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

↑