Transformer has achieved great success in NLP. However, the quadratic complexity of the self-attention mechanism in Transformer makes it inefficient in handling long sequences. Many existing works explore to accelerate Transformers by computing sparse self-attention instead of a dense one, which usually attends to tokens at certain positions or randomly selected tokens. However, manually selected or random tokens may be uninformative for context modeling. In this paper, we propose Smart Bird, which is an efficient and effective Transformer with learnable sparse attention. In Smart Bird, we first compute a sketched attention matrix with a single-head low-dimensional Transformer, which aims to find potential important interactions between tokens. We then sample token pairs based on their probability scores derived from the sketched attention matrix to generate different sparse attention index matrices for different attention heads. Finally, we select token embeddings according to the index matrices to form the input of sparse attention networks. Extensive experiments on six benchmark datasets for different tasks validate the efficiency and effectiveness of Smart Bird in text modeling.
翻译:变异器在 NLP 中取得了巨大成功。 然而, 变异器中自我注意机制的四重复杂性使得它在处理长序列时效率低下。 许多现有作品探索通过计算少许自我注意而不是密集的加速变异器, 通常在某些位置或随机选择的符号上会参与。 然而, 手工选择或随机的符号可能对于环境建模来说是不具有信息规范的。 在本文中, 我们提议智能鸟是一个高效和高效的变异器, 具有可学习的微小注意力。 在智能鸟中, 我们首先用一个单头低度低维变异器来计算一个素描的注意矩阵, 目的是寻找代号之间潜在的重要互动关系。 我们然后根据从素描的注意矩阵中得出的概率分数来抽样代号配对, 以产生不同的分散注意指数矩阵显示不同的注意头。 最后, 我们根据指数矩阵选择代号嵌入微弱关注网络的投入。 在六个基准数据集上进行的广泛实验, 以证实智能鸟在文本建模中的效率和效力。