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

Treeformer:用于高效注意力计算的密集梯度树

Treeformer: Dense Gradient Trees for Efficient Attention Computation

Google Research(谷歌研究院)

Lovish Madaan, Srinadh Bhojanapalli, Himanshu Jain, Prateek Jain

摘要:

基于Transformer架构的标准推理和训练与输入序列长度成二次方。这是令人望而却步的各种应用程序,特别是在网页翻译,查询回答等,因此,最近已经开发了几种方法来加速注意力计算,通过执行不同的注意力结构,如稀疏,低秩,近似注意使用内核。在这项工作中,我们将注意力计算视为最近邻检索,并使用基于决策树的分层导航,以减少每个查询令牌的检索成本从线性序列长度接近对数。基于这种层次导航,我们设计了Treeformer,它可以使用两个有效的注意力层之一-TF-注意力和TC-注意力。TF-Attention以细粒度的方式计算注意力,而TC-Attention是一个粗略的注意力层,它也确保梯度是“密集的”。为了优化这种具有挑战性的离散层,我们提出了一种两级自举训练方法。通过对标准NLP基准测试进行广泛的实验,特别是对于长序列,我们证明了我们的Treeformer架构几乎可以与基线Transformer一样准确,同时在注意力层中使用30倍更少的FLOP。与Linformer相比,在注意力层中使用类似的FLOP时,准确率可以高出12%。

英文摘要:

Standard inference and training with transformer based architectures scale quadratically with input sequence length. This is prohibitively large for a variety of applications especially in web-page translation, query-answering etc. Consequently, several approaches have been developed recently to speedup attention computation by enforcing different attention structures such as sparsity, low-rank, approximating attention using kernels. In this work, we view attention computation as that of nearest neighbor retrieval, and use decision tree based hierarchical navigation to reduce the retrieval cost per query token from linear in sequence length to nearly logarithmic. Based on such hierarchical navigation, we design Treeformer which can use one of two efficient attention layers -- TF-Attention and TC-Attention. TF-Attention computes the attention in a fine-grained style, while TC-Attention is a coarse attention layer which also ensures that the gradients are "dense". To optimize such challenging discrete layers, we propose a two-level bootstrapped training method. Using extensive experiments on standard NLP benchmarks, especially for long-sequences, we demonstrate that our Treeformer architecture can be almost as accurate as baseline Transformer while using 30x lesser FLOPs in the attention layer. Compared to Linformer, the accuracy can be as much as 12% higher while using similar FLOPs in the attention layer.

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

↑