双向块自注意序列建模算法
Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Modeling
摘要:
递归神经网络(RNN)、卷积神经网络(CNN)和自注意力网络(SAN)通常用于产生上下文感知表示。RNN可以捕获长距离依赖,但难以并行化,并且时间效率不高。CNN专注于局部依赖性,但在某些任务上表现不佳。SAN可以通过高度并行化的计算对这两种依赖关系进行建模,但内存需求会随着序列长度的增长而快速增长。在本文中,我们提出了一个模型,称为“双向块自注意网络(Bi-BloSAN)”,用于RNN/CNN自由序列编码。它需要的内存和RNN一样少,但具有SAN的所有优点。Bi-BloSAN将整个序列拆分为块,并将块内SAN应用于每个块以建模本地上下文,然后将块间SAN应用于所有块的输出以捕获长距离依赖性。因此,每个SAN只需要处理很短的序列,并且只需要少量的内存。此外,我们使用特征级注意力来处理同一个词周围的上下文的变化,并使用前向/后向掩码来编码时间顺序信息。在不同NLP任务的九个基准数据集上,Bi-BloSAN实现或提高了最先进的准确性,并显示出比现有RNN/CNN/SAN更好的效率-内存权衡。
英文摘要:
Recurrent neural networks (RNN), convolutional neural networks (CNN) and self-attention networks (SAN) are commonly used to produce context-aware representations. RNN can capture long-range dependency but is hard to parallelize and not time-efficient. CNN focuses on local dependency but does not perform well on some tasks. SAN can model both such dependencies via highly parallelizable computation, but memory requirement grows rapidly in line with sequence length. In this paper, we propose a model, called "bi-directional block self-attention network (Bi-BloSAN)", for RNN/CNN-free sequence encoding. It requires as little memory as RNN but with all the merits of SAN. Bi-BloSAN splits the entire sequence into blocks, and applies an intra-block SAN to each block for modeling local context, then applies an inter-block SAN to the outputs for all blocks to capture long-range dependency. Thus, each SAN only needs to process a short sequence, and only a small amount of memory is required. Additionally, we use feature-level attention to handle the variation of contexts around the same word, and use forward/backward masks to encode temporal order information. On nine benchmark datasets for different NLP tasks, Bi-BloSAN achieves or improves upon state-of-the-art accuracy, and shows better efficiency-memory trade-off than existing RNN/CNN/SAN.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。