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

超越缩放定律:用联想记忆理解Transformer性能

Beyond Scaling Laws: Understanding Transformer Performance with Associative Memory

Central Research Institute, 2012 Laboratories(2012实验室中央研究院);Huawei Technologies Co., Ltd.(华为技术有限公司)

Xueyan Niu, Bo Bai, Lei Deng, Wei Han

AI总结:

针对Transformer规模增大未必提升性能且与训练样本记忆相关的问题,提出基于Hopfield网络的联想记忆理论框架,解释注意力机制并构建全局能量函数,揭示模型与数据集规模的依赖关系及损失下界。

摘要:

增大Transformer的规模并不总能提升性能,这一现象无法用经验缩放定律解释。此外,模型性能的提升与其对训练样本的记忆密切相关。我们提出一个理论框架,阐明基于Transformer的语言模型预训练过程中的记忆机制。我们用Hopfield网络将Transformer的行为建模为联想记忆,使每个Transformer块有效执行近似最近邻搜索。具体而言,现代连续Hopfield网络中的能量函数可解释注意力机制,我们用基于距离的能量函数对其近似。通过观察softmax函数对应能量中LogSumExp函数的梯度,并采用MM(majorization-minimization)技术,我们构建了一个捕捉分层架构的全局能量函数。我们证明模型达到最优性能时,模型规模与数据集规模存在依赖关系,并表明可实现的交叉熵损失有下界。

英文摘要:

Increasing the size of a Transformer does not always lead to enhanced performance. This phenomenon cannot be explained by the empirical scaling laws. Furthermore, the model's enhanced performance is closely associated with its memorization of the training samples. We present a theoretical framework that sheds light on the memorization during pre-training of transformer-based language models. We model the behavior of Transformers with associative memories using Hopfield networks, such that each transformer block effectively conducts an approximate nearest-neighbor search. In particular, the energy function in modern continuous Hopfield networks serves as an explanation for the attention mechanism, which we approximate with a distance-based energy function. By observing that the softmax function corresponds to the gradient of the LogSumExp function in the energy, and employing the majorization-minimization technique, we construct a global energy function designed to capture the layered architecture. We demonstrate a dependency between the model size and the dataset size for the model to achieve optimal performance, and we show that the achievable cross-entropy loss is bounded from below.

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

↑