Papers
Topics
Authors
Recent
Search
2000 character limit reached

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

Published 14 Sep 2023 in cs.DS, cs.LG, and stat.ML | (2309.07418v1)

Abstract: 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)=j0=1<sup>n</sup>i0=1<sup>d</sup>(exp(A<em>j0x),1n<sup>1</sup>exp(A</em>j0x),A3Y<em>,i0bj0,i0)<sup>2L(X,Y) = \sum_{j_0 = 1}<sup>n</sup> \sum_{i_0 = 1}<sup>d</sup> ( \langle \langle \exp( \mathsf{A}<em>{j_0} x ) , {\bf 1}_n \rangle<sup>{-1}</sup> \exp( \mathsf{A}</em>{j_0} x ), A_{3} Y_{<em>,i_0} \rangle - b_{j_0,i_0} )<sup>2. Here AR<sup>n<sup>2</sup></sup>×d<sup>2\mathsf{A} \in \mathbb{R}<sup>{n<sup>2</sup></sup> \times d<sup>2} is Kronecker product between A1R<sup>n</sup>×dA_1 \in \mathbb{R}<sup>{n</sup> \times d} and A2R<sup>n</sup>×dA_2 \in \mathbb{R}<sup>{n</sup> \times d}. A3A_3 is a matrix in R<sup>n</sup>×d\mathbb{R}<sup>{n</sup> \times d}, A<em>j0R<sup>n</sup>×d<sup>2\mathsf{A}<em>{j_0} \in \mathbb{R}<sup>{n</sup> \times d<sup>2} is the j0j_0-th block of A\mathsf{A}. The X,YR<sup>d</sup>×dX, Y \in \mathbb{R}<sup>{d</sup> \times d} are variables we want to learn. BR<sup>n</sup>×dB \in \mathbb{R}<sup>{n</sup> \times d} and b</em>j0,i0Rb</em>{j_0,i_0} \in \mathbb{R} is one entry at j0j_0-th row and i0i_0-th column of BB, Y</em>,i0R<sup>dY_{</em>,i_0} \in \mathbb{R}<sup>d is the i0i_0-column vector of YY, and xR<sup>d<sup>2x \in \mathbb{R}<sup>{d<sup>2} is the vectorization of XX. In a multi-layer LLM network, the matrix BR<sup>n</sup>×dB \in \mathbb{R}<sup>{n</sup> \times d} can be viewed as the output of a layer, and A1=A2=A3R<sup>n</sup>×dA_1= A_2 = A_3 \in \mathbb{R}<sup>{n</sup> \times d} can be viewed as the input of a layer. The matrix version of xx can be viewed as QK<sup>QK<sup>\top and YY can be viewed as VV. We provide an iterative greedy algorithm to train loss function L(X,Y)L(X,Y) up ϵ\epsilon that runs in O~((T<em>mat(n,n,d)+T</em>mat(n,d,d)+d<sup>2ω)</sup>log(1/ϵ))\widetilde{O}( ({\cal T}<em>{\mathrm{mat}}(n,n,d) + {\cal T}</em>{\mathrm{mat}}(n,d,d) + d<sup>{2\omega})</sup> \log(1/\epsilon) ) time. Here Tmat(a,b,c){\cal T}_{\mathrm{mat}}(a,b,c) denotes the time of multiplying a×ba \times b matrix another b×cb \times c matrix, and ω2.37\omega\approx 2.37 denotes the exponent of matrix multiplication.

Authors (4)
Citations (20)

Summary

No one has generated a summary of this paper yet.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Continue Learning

We haven't generated follow-up questions for this paper yet.