arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2212.14852cs.LG
收藏

通过可交换性与潜变量模型的视角分析注意力机制

An Analysis of Attention via the Lens of Exchangeability and Latent Variable Models

Northwestern University(西北大学)

Yufeng Zhang, Boyi Liu, Qi Cai, Lingxiao Wang, Zhaoran Wang

AI总结:

本文利用可交换性和潜变量模型,从表示、推断和学习三方面为注意力机制建立理论,证明其可近似潜后验且误差随输入规模递减,并给出与输入规模无关的泛化保证。

摘要:

借助注意力机制,Transformer 取得了显著的实证成功。尽管人们直觉上理解 Transformer 在长序列上执行关系推理以产生理想的表示,但我们仍缺乏关于注意力机制如何实现这一点的严格理论。特别是,几个引人入胜的问题仍未解决:(a)什么构成了理想的表示?(b)注意力机制如何在前向传播中推断出理想的表示?(c)预训练过程如何通过反向传播学会推断理想的表示?我们观察到,正如在 BERT 和 ViT 中的情况,输入 token 通常是可交换的,因为它们已经包含了位置编码。可交换性的概念诱导出一个对输入大小不变的潜变量模型,这使得我们的理论分析成为可能。- 针对表示问题(a),我们证明了输入 token 的充分且最小表示的存在性。特别地,这种表示实例化了给定输入 token 条件下潜变量的后验分布,这在预测输出标签和解决下游任务中起着核心作用。- 针对推断问题(b),我们证明了具有期望参数的注意力机制可以推断潜后验,其近似误差随输入大小增大而减小。具体而言,我们量化了注意力如何近似给定 key 时 value 的条件均值,这刻画了它如何在长序列上执行关系推理。- 针对学习问题(c),我们证明了监督目标和自监督目标都允许经验风险最小化学习到期望参数,其泛化误差与输入大小无关。特别是在自监督设置下,我们识别出一个对解决下游任务至关重要的条件数。

英文摘要:

With the attention mechanism, transformers achieve significant empirical successes. Despite the intuitive understanding that transformers perform relational inference over long sequences to produce desirable representations, we lack a rigorous theory on how the attention mechanism achieves it. In particular, several intriguing questions remain open: (a) What makes a desirable representation? (b) How does the attention mechanism infer the desirable representation within the forward pass? (c) How does a pretraining procedure learn to infer the desirable representation through the backward pass? We observe that, as is the case in BERT and ViT, input tokens are often exchangeable since they already include positional encodings. The notion of exchangeability induces a latent variable model that is invariant to input sizes, which enables our theoretical analysis. - To answer (a) on representation, we establish the existence of a sufficient and minimal representation of input tokens. In particular, such a representation instantiates the posterior distribution of the latent variable given input tokens, which plays a central role in predicting output labels and solving downstream tasks. - To answer (b) on inference, we prove that attention with the desired parameter infers the latent posterior up to an approximation error, which is decreasing in input sizes. In detail, we quantify how attention approximates the conditional mean of the value given the key, which characterizes how it performs relational inference over long sequences. - To answer (c) on learning, we prove that both supervised and self-supervised objectives allow empirical risk minimization to learn the desired parameter up to a generalization error, which is independent of input sizes. Particularly, in the self-supervised setting, we identify a condition number that is pivotal to solving downstream tasks.

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

↑