arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2107.05768cs.LGcs.CLcs.CV
收藏

Combiner:稀疏计算代价的全注意力Transformer

Combiner: Full Attention Transformer with Sparse Computation Cost

Stanford University(斯坦福大学);Google Research(谷歌研究院);University of Alberta(阿尔伯塔大学)

Hongyu Ren, Hanjun Dai, Zihang Dai, Mengjiao Yang, Jure Leskovec, Dale Schuurmans, Bo Dai

摘要:

Transformers提供了一类对序列建模非常有效的表达架构。然而,Transformers的关键限制是它们的二次记忆和时间复杂度$\mathcal{O}(L^2)$相对于序列长度在注意层,这限制了应用在极长的序列。大多数现有的方法利用稀疏或低秩的假设在注意力矩阵,以降低成本,但牺牲表现力。相反,我们提出了组合器,它提供了充分的注意力能力,在每个注意力头,同时保持低的计算和内存的复杂性。其核心思想是将自我注意机制视为对每个位置嵌入的条件期望,并使用结构化因子分解来近似条件分布。每个位置都可以通过直接注意或间接注意抽象来关注所有其他位置,这些抽象也是对来自相应局部区域的嵌入的条件期望。我们发现,在现有的稀疏Transformers中使用的大多数稀疏注意模式能够激发充分注意的这种因式分解的设计,从而导致相同的次二次成本($\mathcal{O}(L\log(L))$或$\mathcal{O}(L\sqrt{L})$)。Combiner是现有Transformers中注意层的替代品,可以在通用框架中轻松实现。对自回归和双向序列任务的实验评估证明了这种方法的有效性,在几个图像和文本建模任务上产生了最先进的结果。

英文摘要:

Transformers provide a class of expressive architectures that are extremely effective for sequence modeling. However, the key limitation of transformers is their quadratic memory and time complexity $\mathcal{O}(L^2)$ with respect to the sequence length in attention layers, which restricts application in extremely long sequences. Most existing approaches leverage sparsity or low-rank assumptions in the attention matrix to reduce cost, but sacrifice expressiveness. Instead, we propose Combiner, which provides full attention capability in each attention head while maintaining low computation and memory complexity. The key idea is to treat the self-attention mechanism as a conditional expectation over embeddings at each location, and approximate the conditional distribution with a structured factorization. Each location can attend to all other locations, either via direct attention, or through indirect attention to abstractions, which are again conditional expectations of embeddings from corresponding local regions. We show that most sparse attention patterns used in existing sparse transformers are able to inspire the design of such factorization for full attention, resulting in the same sub-quadratic cost ($\mathcal{O}(L\log(L))$ or $\mathcal{O}(L\sqrt{L})$). Combiner is a drop-in replacement for attention layers in existing transformers and can be easily implemented in common frameworks. An experimental evaluation on both autoregressive and bidirectional sequence tasks demonstrates the effectiveness of this approach, yielding state-of-the-art results on several image and text modeling tasks.

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

↑