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

通过预条件器求解注意力核回归问题

Solving Attention Kernel Regression Problem via Pre-conditioner

Adobe Research(奥多比研究院);Boston University(波士顿大学);MIT(麻省理工学院)

Zhao Song, Junze Yin, Lichen Zhang

AI总结:

本文针对注意力矩阵的高效近似,提出基于矩阵指数和逐元素指数Gram矩阵的两类代理回归问题,并利用草图化与预条件化设计快速算法,为注意力矩阵近似研究提供新视角。

摘要:

注意力机制是大语言模型的关键,而注意力矩阵构成了此类方案在算法与计算上的瓶颈。本文定义了两个问题,其动机是为注意力矩阵的代理设计快速算法,并针对这些代理求解回归问题。给定输入矩阵 $A\in \mathbb{R}^{n\times d}$(其中 $n\gg d$)和响应向量 $b$,我们首先考虑矩阵 $A^\top A$ 的矩阵指数作为代理,进而为两类回归问题设计算法:对任意正整数 $j$,求解 $\min_{x\in \mathbb{R}^d}\\|(A^\top A)^jx-b\\|_2$ 和 $\min_{x\in \mathbb{R}^d}\\|A(A^\top A)^jx-b\\|_2$。研究这些回归问题的算法至关重要,因为矩阵指数可以通过这些较小的问题逐项近似。第二个代理是对 Gram 矩阵逐元素应用指数函数,记为 $\exp(AA^\top)$,并求解回归 $\min_{x\in \mathbb{R}^n}\\|\exp(AA^\top)x-b\\|_2$。我们称该问题为注意力核回归问题,因为矩阵 $\exp(AA^\top)$ 可被视为关于 $A$ 的核函数。我们基于草图化和预条件化技术为这些回归问题设计了快速算法。我们希望这些工作能为研究注意力矩阵的高效近似提供另一种视角。

英文摘要:

The attention mechanism is the key to large language models, and the attention matrix serves as an algorithmic and computational bottleneck for such a scheme. In this paper, we define two problems, motivated by designing fast algorithms for proxy of attention matrix and solving regressions against them. Given an input matrix $A\in \mathbb{R}^{n\times d}$ and a response vector $b$, the first proxy, for $n\gg d$, uses powers of the matrix $A^\top A$, and we consider two types of regression problems: $\min_{x\in \mathbb{R}^d}\|(A^\top A)^jx-b\|_2$ and $\min_{x\in \mathbb{R}^d}\|A(A^\top A)^jx-b\|_2$ for any positive integer $j$. We design fast algorithms for these power regressions, based on sketching and preconditioning. The second proxy is applying exponential entrywise to the Gram matrix, denoted by $\exp(AA^\top)$ and solving the regression $\min_{x\in \mathbb{R}^n}\|\exp(AA^\top)x-b \|_2$. We call this problem the attention kernel regression problem, as the matrix $\exp(AA^\top)$ could be viewed as a kernel function with respect to $A$. For this problem, we show that the sketching and preconditioning approach known for Gaussian kernels gives error $ε\|b\|_2$ for every $b$, with a sketch dimension that is, up to logarithmic factors, $ε^{-2}n$ times the condition number of the kernel matrix, which is at least $n/e$ when the rows of $A$ have norm at most $1$. For rows of norm at most $1$, we also give an algorithm whose sketch dimension, up to logarithmic factors, does not depend on $n$. It sketches the kernel plus a ridge term, and for a given $K\geq 1$ its error is at most $ε\|b\|_2$ plus $(1+\sqrtε)$ times the best residual among solutions of norm at most $(K/n)\|b\|_2$. We hope these efforts will provide an alternative perspective of studying efficient approximation of attention matrices.

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

↑