用语法角色指导注意力,让模型更高效且可解释。
Grammatically-Guided Sparse Attention for Efficient and Interpretable Transformers
- 根据词性标签动态生成注意力掩码,约束计算范围。
- 硬掩码和软掩码均达82%准确率,接近全注意力表现。
- 适合追求效率与可解释性的自然语言处理研究者。
Transformer模型中自注意力的二次复杂度仍是处理长序列和高效部署大语言模型的主要瓶颈。现有研究致力于稀疏注意力,Deepseek稀疏注意力已结合多种分段策略以降低时间复杂度。本文提出一种新方法——语法引导稀疏注意力,基于词性(POS)标签约束注意力计算,动态生成关注掩码,确保语义连贯性连接,减少计算图规模而不损失关键语言依赖。提出两种掩码策略:严格限定预定义语法交互的硬掩码,以及偏好此类交互的软掩码。在基于DistilBERT架构的SST-2情感分类任务上实验表明,该方法在保持与全注意力相近精度的同时显著降低理论计算开销。初步结果:硬掩码准确率为0.8200,软掩码为0.8165,全注意力为0.8200,为构建更高效、可解释且语言感知的Transformer架构提供路径。
原文摘要 · Abstract (English)
The quadratic complexity of self-attention in Transformer models remains a significant bottleneck for processing long sequences and deploying large language models efficiently. For this approach, there has been significant research into Sparse Attention, and Deepseek Sparse Attention has combined various methods of creating segments of tokens to reduce the time complexity. This paper introduces a novel approach, Grammatically-Guided Sparse Attention, which constrains attention computations based on the grammatical roles of tokens. By leveraging Parts-of-Speech (POS) tags, attention masks are dynamically generated that enforce linguistically coherent connections between tokens, reducing the computational graph without sacrificing essential linguistic dependencies. Two masking strategies are proposed and evaluated: a hard mask that strictly allows only predefined grammatical interactions, and a soft mask that biases attention towards these interactions. The experiments, conducted on the SST-2 sentiment classification task using a DistilBERT-like architecture, demonstrate that Grammatically-Guided Sparse Attention maintains comparable accuracy to full attention while significantly reducing the theoretical computational overhead. Preliminary results show accuracy values of 0.8200 for hard masking and 0.8165 for soft masking, closely matching the 0.8200 of full attention, providing a path towards more efficient, interpretable, and linguistically-informed Transformer architectures.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。