arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.02969stat.MLcs.CLcs.LG
收藏

理解注意力层的词敏感性:基于随机特征的研究

Towards Understanding the Word Sensitivity of Attention Layers: A Study via Random Features

Institute of Science and Technology Austria (ISTA)(奥地利科学技术研究所)

Simone Bombari, Marco Mondelli

AI总结:

该研究聚焦NLP中注意力层的词敏感性特性,通过随机特征理论分析证明注意力层因softmax作用具备高词敏感性,泛化能力优于标准随机特征,并在imdb数据集的BERT-Base嵌入上验证了理论结论。

摘要:

理解Transformer取得卓越成功的背后原因,需要更深入分析注意力层为何适用于自然语言处理(NLP)任务。具体而言,这类任务要求预测模型捕捉语境语义,而语境语义往往依赖于一个或少数几个词,即便句子很长。本研究在随机特征的典型设定下,研究了这一被称为词敏感性(WS)的关键属性。我们证明注意力层具有高词敏感性,即嵌入空间中存在一个向量,能大幅扰动随机注意力特征映射。该论证关键利用了注意力层中softmax的作用,凸显了其相较于其他激活函数(如ReLU)的优势。相比之下,标准随机特征的词敏感性量级为$1/\sqrt{n}$,其中$n$为文本样本中的词数,因此其会随上下文长度衰减。随后我们将这些词敏感性结果转化为泛化界:由于词敏感性低,随机特征在理论上无法学会区分仅相差一个词的两个句子;与之相反,由于词敏感性高,随机注意力特征具备更强的泛化能力。我们通过在imdb评论数据集的BERT-Base词嵌入上开展的实验,验证了上述理论结果。

英文摘要:

Understanding the reasons behind the exceptional success of transformers requires a better analysis of why attention layers are suitable for NLP tasks. In particular, such tasks require predictive models to capture contextual meaning which often depends on one or few words, even if the sentence is long. Our work studies this key property, dubbed word sensitivity (WS), in the prototypical setting of random features. We show that attention layers enjoy high WS, namely, there exists a vector in the space of embeddings that largely perturbs the random attention features map. The argument critically exploits the role of the softmax in the attention layer, highlighting its benefit compared to other activations (e.g., ReLU). In contrast, the WS of standard random features is of order $1/\sqrt{n}$, $n$ being the number of words in the textual sample, and thus it decays with the length of the context. We then translate these results on the word sensitivity into generalization bounds: due to their low WS, random features provably cannot learn to distinguish between two sentences that differ only in a single word; in contrast, due to their high WS, random attention features have higher generalization capabilities. We validate our theoretical results with experimental evidence over the BERT-Base word embeddings of the imdb review dataset.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑