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.
翻译:通过输入序列长度的变压器结构,标准发酵和训练,以输入序列长度为基调。对于各种应用,特别是网页翻译、问答等应用来说,这非常之大。因此,最近开发了几种方法,通过使用内核强制实施不同关注结构,例如聚度、低级别、近距离关注等,加快关注的计算。在这项工作中,我们将关注的计算视为最近的邻居检索,并使用基于决策树的等级导航,将每个查询标记的检索成本从线性长度线性到近对数性。根据这种等级导航,我们设计了树形前,可以使用两个高效关注层 -- -- TF- 注意和TC- 注意层等两个高效关注层之一 -- -- TF- 注意和 T- 注意- 计算。TF- 注意以细微的调调色调方式使关注得到关注,而TC- 注意是一个粗微的注意层,也确保梯度是“强烈的”。为了优化这种具有挑战性的离层,我们建议一种双层的培训方法。在标准 NLP 基准基准上进行广泛的实验,特别是对于长期的精度结构的精确度结构,同时,我们可以使用更精确的L- 。