arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.07418cs.DScs.LGstat.ML
收藏

一种快速优化视角:基于张量与 SVM 技巧重构 LLM 中的单层注意力,并在矩阵乘法时间内求解

A Fast Optimization View: Reformulating Single Layer Attention in LLM Based on Tensor and SVM Trick, and Solving It in Matrix Multiplication Time

The University of Washington(华盛顿大学);Adobe Research(奥多比研究院);Johns Hopkins University(约翰斯·霍普金斯大学);Boston University(波士顿大学)

Yeqi Gao, Zhao Song, Weixin Wang, Junze Yin

AI总结:

本文提出一种基于张量与 SVM 技巧的迭代贪心算法,用于优化单层注意力网络的目标函数,并在矩阵乘法时间内实现可证明的求解保证。

摘要:

大型语言模型(LLMs)在彻底改变我们日常生活的各个方面发挥了关键作用。解决注意力回归是优化 LLMs 的一项基本任务。在这项工作中,我们专注于为单层注意力网络目标函数 $L(X,Y) = \sum_{j_0 = 1}^n \sum_{i_0 = 1}^d ( \langle \langle \exp( \mathsf{A}_{j_0} x ) , {\bf 1}_n \rangle^{-1} \exp( \mathsf{A}_{j_0} x ), A_{3} Y_{*,i_0} \rangle - b_{j_0,i_0} )^2$ 提供可证明的保证。这里 $\mathsf{A} \in \mathbb{R}^{n^2 \times d^2}$ 是 $A_1 \in \mathbb{R}^{n \times d}$ 和 $A_2 \in \mathbb{R}^{n \times d}$ 之间的 Kronecker 积。$A_3$ 是 $\mathbb{R}^{n \times d}$ 中的矩阵,$\mathsf{A}_{j_0} \in \mathbb{R}^{n \times d^2}$ 是 $\mathsf{A}$ 的第 $j_0$ 个块。$X, Y \in \mathbb{R}^{d \times d}$ 是我们想要学习的变量。$B \in \mathbb{R}^{n \times d}$ 且 $b_{j_0,i_0} \in \mathbb{R}$ 是 $B$ 中第 $j_0$ 行和第 $i_0$ 列的一个元素,$Y_{*,i_0} \in \mathbb{R}^d$ 是 $Y$ 的第 $i_0$ 列向量,$x \in \mathbb{R}^{d^2}$ 是 $X$ 的向量化。在多层 LLM 网络中,矩阵 $B \in \mathbb{R}^{n \times d}$ 可以被视为某一层的输出,而 $A_1= A_2 = A_3 \in \mathbb{R}^{n \times d}$ 可以被视为某一层的输入。$x$ 的矩阵版本可以被视为 $QK^\top$,$Y$ 可以被视为 $V$。我们提供了一种迭代贪心算法来训练损失函数 $L(X,Y)$ 达到 $ε$ 精度,运行时间为 $\widetilde{O}( ({\cal T}_{\mathrm{mat}}(n,n,d) + {\cal T}_{\mathrm{mat}}(n,d,d) + d^{2ω}) \log(1/ε) )$。这里 ${\cal T}_{\mathrm{mat}}(a,b,c)$ 表示 $a \times b$ 矩阵乘以另一个 $b \times c$ 矩阵的时间,$ω\approx 2.37$ 表示矩阵乘法的指数。

英文摘要:

Large language models (LLMs) have played a pivotal role in revolutionizing various facets of our daily existence. Solving attention regression is a fundamental task in optimizing LLMs. In this work, we focus on giving a provable guarantee for the one-layer attention network objective function $L(X,Y) = \sum_{j_0 = 1}^n \sum_{i_0 = 1}^d ( \langle \langle \exp( \mathsf{A}_{j_0} x ) , {\bf 1}_n \rangle^{-1} \exp( \mathsf{A}_{j_0} x ), A_{3} Y_{*,i_0} \rangle - b_{j_0,i_0} )^2$. Here $\mathsf{A} \in \mathbb{R}^{n^2 \times d^2}$ is Kronecker product between $A_1 \in \mathbb{R}^{n \times d}$ and $A_2 \in \mathbb{R}^{n \times d}$. $A_3$ is a matrix in $\mathbb{R}^{n \times d}$, $\mathsf{A}_{j_0} \in \mathbb{R}^{n \times d^2}$ is the $j_0$-th block of $\mathsf{A}$. The $X, Y \in \mathbb{R}^{d \times d}$ are variables we want to learn. $B \in \mathbb{R}^{n \times d}$ and $b_{j_0,i_0} \in \mathbb{R}$ is one entry at $j_0$-th row and $i_0$-th column of $B$, $Y_{*,i_0} \in \mathbb{R}^d$ is the $i_0$-column vector of $Y$, and $x \in \mathbb{R}^{d^2}$ is the vectorization of $X$. In a multi-layer LLM network, the matrix $B \in \mathbb{R}^{n \times d}$ can be viewed as the output of a layer, and $A_1= A_2 = A_3 \in \mathbb{R}^{n \times d}$ can be viewed as the input of a layer. The matrix version of $x$ can be viewed as $QK^\top$ and $Y$ can be viewed as $V$. We provide an iterative greedy algorithm to train loss function $L(X,Y)$ up $ε$ that runs in $\widetilde{O}( ({\cal T}_{\mathrm{mat}}(n,n,d) + {\cal T}_{\mathrm{mat}}(n,d,d) + d^{2ω}) \log(1/ε) )$ time. Here ${\cal T}_{\mathrm{mat}}(a,b,c)$ denotes the time of multiplying $a \times b$ matrix another $b \times c$ matrix, and $ω\approx 2.37$ denotes the exponent of matrix multiplication.

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

↑