arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2307.11353cs.LGmath.STstat.MLstat.TH
收藏

单个注意力层能学习什么?基于随机特征视角的研究

What can a Single Attention Layer Learn? A Study Through the Random Features Lens

Peking University(北京大学);UC Berkeley(加州大学伯克利分校);Salesforce AI Research(赛富时人工智能研究院)

Hengyu Fu, Tianyu Guo, Yu Bai, Song Mei

AI总结:

该研究从随机特征视角理论分析单多头注意力层的表达与泛化能力,证明其可表达一大类键置换不变目标函数,给出超额风险界,揭示其相对标准两层随机特征网络的样本复杂度优势等特性,并通过模拟实验验证理论结论。

摘要:

注意力层可将输入序列映射为输出序列,是Transformer架构的核心构建模块,而Transformer在现代人工智能领域已取得重大突破。本文针对以一组键向量序列和一个独立查询向量作为输入的单多头注意力层的学习与泛化能力展开严格的理论研究。我们考虑随机特征设置:注意力层包含大量注意力头,其中查询矩阵和键矩阵为随机采样的冻结参数,值矩阵为可训练参数。我们证明,这类随机特征注意力层能够表达一大类对键向量具有置换不变性的目标函数。我们进一步给出了使用有限头数的随机特征注意力,从有限样本中学习这些目标函数时的量化超额风险界。\n 与现有神经网络随机特征理论相比,我们的结果呈现出若干注意力结构特有的推论,包括:(1)在样本复杂度上优于标准两层随机特征网络;(2)随机特征注意力层可高效学习的具体且自然的函数类别;(3)查询-键权重矩阵(查询矩阵与键矩阵的乘积)的采样分布的影响:对于学习某些自然目标函数时,非零均值的高斯随机权重相比零均值对应权重能带来更优的样本复杂度。在模拟数据上的实验验证了我们的理论发现,并进一步阐明了样本量与目标函数复杂度之间的相互作用。

英文摘要:

Attention layers -- which map a sequence of inputs to a sequence of outputs -- are core building blocks of the Transformer architecture which has achieved significant breakthroughs in modern artificial intelligence. This paper presents a rigorous theoretical study on the learning and generalization of a single multi-head attention layer, with a sequence of key vectors and a separate query vector as input. We consider the random feature setting where the attention layer has a large number of heads, with randomly sampled frozen query and key matrices, and trainable value matrices. We show that such a random-feature attention layer can express a broad class of target functions that are permutation invariant to the key vectors. We further provide quantitative excess risk bounds for learning these target functions from finite samples, using random feature attention with finitely many heads. Our results feature several implications unique to the attention structure compared with existing random features theory for neural networks, such as (1) Advantages in the sample complexity over standard two-layer random-feature networks; (2) Concrete and natural classes of functions that can be learned efficiently by a random-feature attention layer; and (3) The effect of the sampling distribution of the query-key weight matrix (the product of the query and key matrix), where Gaussian random weights with a non-zero mean result in better sample complexities over the zero-mean counterpart for learning certain natural target functions. Experiments on simulated data corroborate our theoretical findings and further illustrate the interplay between the sample size and the complexity of the target function.

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

↑