arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2210.15541cs.LGcs.AI
收藏

Transformers满足随机块模型:关注数据自适应稀疏性和成本

Transformers meet Stochastic Block Models: Attention with Data-Adaptive Sparsity and Cost

LG AI Research(LG人工智能研究院);KAIST(韩国科学技术院);University of Illinois Chicago(伊利诺伊大学芝加哥分校)

Sungjun Cho, Seonwoo Min, Jinwoo Kim, Moontae Lee, Honglak Lee, Seunghoon Hong

摘要:

为了克服自我注意的二次成本,最近的工作提出了各种稀疏注意模块,其中大部分属于两组之一:1)手工制作的模式下的稀疏注意和2)完全注意,然后是softmax的稀疏变体,如$α$ -entmax。不幸的是,第一组缺乏对数据的适应性,而第二组仍然需要二次训练成本。在这项工作中,我们提出了SBM-变压器,一个模型,解决了这两个问题,赋予每个注意头与一个混合成员随机块模型(SBM)。然后,每个注意头数据自适应地采样二分图,其邻接被用作每个输入的注意掩码。在反向传播过程中,直通估计器用于使梯度超出离散采样步骤,并基于预测损失调整采样边缘的概率。因此,前向和后向成本与边的数量成线性关系,每个注意力头也可以基于输入灵活地选择边的数量。通过评估图的分布,我们从理论上证明了SBM-Transformer是期望中任意序列到序列函数的通用逼近器。LRA和GLUE基准下的实证评估表明,我们的模型优于以前的有效的变种,以及充分注意到原来的Transformer。我们的实现可以在https://github.com/sc782/SBM-Transformer中找到。

英文摘要:

To overcome the quadratic cost of self-attention, recent works have proposed various sparse attention modules, most of which fall under one of two groups: 1) sparse attention under a hand-crafted patterns and 2) full attention followed by a sparse variant of softmax such as $α$-entmax. Unfortunately, the first group lacks adaptability to data while the second still requires quadratic cost in training. In this work, we propose SBM-Transformer, a model that resolves both problems by endowing each attention head with a mixed-membership Stochastic Block Model (SBM). Then, each attention head data-adaptively samples a bipartite graph, the adjacency of which is used as an attention mask for each input. During backpropagation, a straight-through estimator is used to flow gradients beyond the discrete sampling step and adjust the probabilities of sampled edges based on the predictive loss. The forward and backward cost are thus linear to the number of edges, which each attention head can also choose flexibly based on the input. By assessing the distribution of graphs, we theoretically show that SBM-Transformer is a universal approximator for arbitrary sequence-to-sequence functions in expectation. Empirical evaluations under the LRA and GLUE benchmarks demonstrate that our model outperforms previous efficient variants as well as the original Transformer with full attention. Our implementation can be found in https://github.com/sc782/SBM-Transformer .

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

↑