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

仅注意力 Transformer 与用注意力头实现 MLP

Attention-Only Transformers and Implementing MLPs with Attention Heads

Robert Huben, Valerie Morris

AI总结:

本文证明只要激活函数属于受限类(含SiLU及ReLU和GeLU近似),内部维度为1的掩码注意力头即可实现MLP神经元,从而将标准Transformer转换为仅注意力Transformer,并证明注意力头能分别执行MLP组件及编码任意掩码模式。

摘要:

Transformer架构广泛用于机器学习模型,由两个交替的子层组成:注意力头和MLP。我们证明,只要MLP的激活函数属于包含SiLU及ReLU和GeLU近似值的受限类,一个MLP神经元即可由内部维度为1的掩码注意力头实现。这使得人们能够以大幅增加注意力头数量为代价,将MLP与注意力Transformer转换为仅注意力Transformer。我们还证明,注意力头可以分别执行MLP的组件(线性变换和激活函数)。最后,我们证明,注意力头可以在其权重矩阵中编码任意掩码模式,且误差可以任意小。

英文摘要:

The transformer architecture is widely used in machine learning models and consists of two alternating sublayers: attention heads and MLPs. We prove that an MLP neuron can be implemented by a masked attention head with internal dimension 1 so long as the MLP's activation function comes from a restricted class including SiLU and close approximations of ReLU and GeLU. This allows one to convert an MLP-and-attention transformer into an attention-only transformer at the cost of greatly increasing the number of attention heads. We also prove that attention heads can perform the components of an MLP (linear transformations and activation functions) separately. Finally, we prove that attention heads can encode arbitrary masking patterns in their weight matrices to within arbitrarily small error.

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

↑