Skip to main content
QUICK REVIEW

[论文解读] Tensorized Self-Attention: Efficiently Modeling Pairwise and Global Dependencies Together

Tao Shen, Tianyi Zhou|arXiv (Cornell University)|May 2, 2018
Topic Modeling参考文献 54被引用 5
一句话总结

本文提出了一种新型注意力机制——多掩码张量化自注意力(MTSA),通过在张量化、多头框架中结合点积注意力与加性注意力,高效建模成对(token-to-token)和全局(source-to-token)依赖关系。MTSA在九个NLP基准测试中实现了最先进或具有竞争力的性能,同时保持了类似CNN的内存与计算效率,在模型大小不变的情况下,准确率优于标准自注意力和多头注意力机制。

ABSTRACT

Neural networks equipped with self-attention have parallelizable computation, light-weight structure, and the ability to capture both long-range and local dependencies. Further, their expressive power and performance can be boosted by using a vector to measure pairwise dependency, but this requires to expand the alignment matrix to a tensor, which results in memory and computation bottlenecks. In this paper, we propose a novel attention mechanism called "Multi-mask Tensorized Self-Attention" (MTSA), which is as fast and as memory-efficient as a CNN, but significantly outperforms previous CNN-/RNN-/attention-based models. MTSA 1) captures both pairwise (token2token) and global (source2token) dependencies by a novel compatibility function composed of dot-product and additive attentions, 2) uses a tensor to represent the feature-wise alignment scores for better expressive power but only requires parallelizable matrix multiplications, and 3) combines multi-head with multi-dimensional attentions, and applies a distinct positional mask to each head (subspace), so the memory and computation can be distributed to multiple heads, each with sequential information encoded independently. The experiments show that a CNN/RNN-free model based on MTSA achieves state-of-the-art or competitive performance on nine NLP benchmarks with compelling memory- and time-efficiency.

研究动机与目标

  • 解决建模全局依赖关系的多维自注意力机制效率低下且内存开销高的问题。
  • 结合token-to-token与source-to-token注意力的优势,实现更丰富的上下文建模,同时不牺牲计算效率。
  • 通过为每个头分配独立的位置掩码,将张量化注意力分布到多个头上,实现长序列的可扩展、可并行计算。
  • 在保持与CNN相当的低内存与时间复杂度的前提下,实现在NLP任务中的最先进性能。

提出的方法

  • MTSA采用混合兼容函数,结合点积注意力以建模成对token依赖,以及加性注意力以建模全局特征级依赖。
  • 将对齐分数表示为张量(三维),以增强表达能力,但通过高效的矩阵乘法计算,而非昂贵的张量运算。
  • 采用每个头具有独立位置掩码的多头注意力机制,实现并行计算,并更好地建模序列结构。
  • 每个注意力头处理特征空间的独立子空间,将内存与计算负载分布在各头之间。
  • 在特征层面集成多维注意力,使每个特征可拥有独立的全局重要性得分,从而增强表征能力。
  • 该框架设计为即插即用,可直接替换Transformer等模型中的标准多头自注意力机制,无需架构重构。

实验结果

研究问题

  • RQ1能否在不产生二次方内存与计算成本的前提下,高效建模成对与全局依赖关系?
  • RQ2将张量化、多维注意力与多头机制及位置掩码结合,对模型性能与效率有何影响?
  • RQ3基于MTSA的无需CNN/RNN的模型能否在多样化的NLP任务中实现最先进结果,同时保持低内存与时间复杂度?
  • RQ4为每个头使用独立的位置掩码是否能提升对序列与相对位置信息的建模能力?

主要发现

  • MTSA在SNLI自然语言蕴含基准测试中达到最先进准确率,测试准确率达95.3%,优于所有基线模型,包括多头注意力与CNN。
  • 在五个句子分类任务中,MTSA在CR、MPQA、TREC与SST-5任务上均取得最高准确率,相比次优模型最高提升0.5%。
  • 在WMT 2014英语-德语机器翻译任务中,MTSA在两种训练设置下均显著优于多头自注意力,p值分别为0.001与0.080。
  • MTSA的内存与计算成本与CNN相当,模型大小无显著增加(6158万参数 vs. Transformer的6138万参数)。
  • 该模型在多样化的NLP任务中均表现出一致的性能提升,包括情感分析、语义角色标注与问题类型分类,具备具有竞争力的推理速度与低内存负载。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。