Sliceformer:在判别任务中让多头注意力像排序一样简单
Sliceformer: Make Multi-head Attention as Simple as Sorting in Discriminative Tasks
AI总结:
本文提出 Sliceformer,用简单的切片-排序操作替代 Transformer 的多头注意力,在多个判别任务上以更低内存和更快速度取得可比或更优性能,并降低模式崩溃风险。
摘要:
作为最流行的神经网络模块之一,Transformer 在许多基础深度学习模型中扮演着核心角色,例如计算机视觉中的 ViT 以及自然语言处理中的 BERT 和 GPT。Transformer 的有效性通常归因于其多头注意力(MHA)机制。在本研究中,我们讨论了 MHA 的局限性,包括其“查询-键-值”架构导致的高计算复杂度,以及其 softmax 操作引起的数值问题。考虑到上述问题以及注意力层的最新发展趋势,我们提出了一种高效且有效的 Transformer 替代方案,称为 Sliceformer。我们的 Sliceformer 用一种极其简单的“切片-排序”操作取代了经典的 MHA 机制,即将输入线性投影到潜在空间,并沿不同的特征维度(或等价地称为通道)对它们进行排序。对于每个特征维度,排序操作隐式地生成一个具有稀疏、满秩和双重随机结构的隐式注意力图。我们考虑了切片-排序操作的不同实现方式,并分析了它们对 Sliceformer 的影响。我们在 Long-Range Arena 基准、图像分类、文本分类和分子性质预测中测试了 Sliceformer,展示了其在计算复杂度方面的优势以及在判别任务中的普遍有效性。与 Transformer 及其变体相比,我们的 Sliceformer 以更低的内存成本和更快的速度取得了可比或更好的性能。此外,实验结果表明,应用我们的 Sliceformer 可以在表示数据时从经验上抑制模式崩溃的风险。代码可在 \url{https://github.com/SDS-Lab/sliceformer} 获取。
英文摘要:
As one of the most popular neural network modules, Transformer plays a central role in many fundamental deep learning models, e.g., the ViT in computer vision and the BERT and GPT in natural language processing. The effectiveness of the Transformer is often attributed to its multi-head attention (MHA) mechanism. In this study, we discuss the limitations of MHA, including the high computational complexity due to its ``query-key-value'' architecture and the numerical issue caused by its softmax operation. Considering the above problems and the recent development tendency of the attention layer, we propose an effective and efficient surrogate of the Transformer, called Sliceformer. Our Sliceformer replaces the classic MHA mechanism with an extremely simple ``slicing-sorting'' operation, i.e., projecting inputs linearly to a latent space and sorting them along different feature dimensions (or equivalently, called channels). For each feature dimension, the sorting operation implicitly generates an implicit attention map with sparse, full-rank, and doubly-stochastic structures. We consider different implementations of the slicing-sorting operation and analyze their impacts on the Sliceformer. We test the Sliceformer in the Long-Range Arena benchmark, image classification, text classification, and molecular property prediction, demonstrating its advantage in computational complexity and universal effectiveness in discriminative tasks. Our Sliceformer achieves comparable or better performance with lower memory cost and faster speed than the Transformer and its variants. Moreover, the experimental results reveal that applying our Sliceformer can empirically suppress the risk of mode collapse when representing data. The code is available at \url{https://github.com/SDS-Lab/sliceformer}.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。