Solving Regularized Exp, Cosh and Sinh Regression Problems
Zhihang Li, Zhao Song, Tianyi Zhou
Introduction
State-of-the-art language models like Transformer , BERT , GPT-3 , PaLM , and OPT exhibit greater proficiency in natural language processing when compared to smaller models or traditional techniques. These models have the capacity to understand and generate intricate language, proving beneficial in various applications such as language translation, sentiment analysis, and question answering. LLMs can be customized for multiple purposes without necessitating their reconstruction from scratch. An instance of this is ChatGPT, an OpenAI-developed chat software that employs GPT-3’s full potential. The latest iteration, GPT-4 , has the potential to surpass GPT-3 in its impressive capabilities, including text generation, question answering, and language translation. This development could lead to significant implications in the field of NLP, with new applications potentially emerging in areas such as virtual assistants, chatbots, and automatic content creation. However, even though deep learning has a swift incline in popularity, we hold the belief that there exist discrepancies in our comprehension of the concept of attention and the reasoning behind its effectiveness.
The primary technical foundation behind LLMs is the attention matrix . An attention matrix is a matrix that features rows and columns aligning with individual words or ”tokens” and their relationships within a given text. Its purpose is to measure the critical nature of each token in a sequence in relation to the intended output. The attention matrix is learned during training. These parameters are optimized to maximize the model’s accuracy in predicting the desired output. Through the attention mechanism, each input token is evaluated based on its importance or relevance to the desired output. This is achieved by weighing the token score, which is based on a similarity function comparing the current output state and input states.
More formally, the attention matrix can be expressed by considering two matrices, and , containing query and key tokens, respectively. Both and hold values in the dimensional space. The attention matrix can be denoted by the square matrix which is of size . This matrix establishes a relationship between the input tokens in the sequence where every entry represents the attention weight or score between a particular input token (query token ) and an output token (key token ). It is essential to mention that diagonal entries of this matrix display self-attention scores, signifying the importance of each token with respect to itself. A majority of the methods used for effective computation of attention matrices are divided into two primary categories based on their approach. One approach involves leveraging sparsity, as seen in Reformer , while the other involves utilizing the low-rank attributes of the attention matrices, as observed in Linformer and Performer .
During training, our primary goal is to tackle the issue of multiple attention regression by utilizing the exponential function and its corresponding equation: , where denotes the normalization factor. However, upon further investigation, it has been brought to our attention that the single regression scenario has not been thoroughly studied. As a result, this study is centered on the situation of single regression.
In our setting, the presence of is unnecessary due to the fact that is a column vector (but not a matrix). Thus, we have opted to address the optimization problem with regards to . It is important to note that our approach is not exclusive to the exponential function, and can also be extended to other hyperbolic functions such as and . and
Let be any of functions and . Let denote the gradient of function .
Let denote the optimal solution of
that and .
Let . Let for all .
Let denote an initial point such that .
For any accuracy parameter and failure probability . There is a randomized algorithm (Algorithm 1) that runs iterations and spend
holds with probability at least .
2 Related Work
Input sparsity is a term used to describe datasets that have a majority of elements that are either zero or negligible. Utilizing algorithms optimized for sparse input data enables faster processing times than those utilized in dense data algorithms. This is because these algorithms can solely focus on non-zero elements, thereby minimizing computational and memory usage. Sparse algorithms’ time complexity depends only on the number of non-zero elements rather than the number of total elements. Input sparsity algorithms are highly applicable within fields such as solving John Ellipsoid , discrepancy minimization , low-rank approximation , subspace embeddings , column subset selection and least squares regression .
Algorithmic Regularization
The standard exponential regression is non-convex. We study the regularization version of the exponential regression problem which is a convex problem. In the context of deep learning, the non-convexity of the objective function necessitates the use of regularization techniques. Due to the possibility of the objective function generating multiple global minima that are widely scattered and vary significantly in their generalization capabilities, this becomes essential. Algorithmic regularization can be observed in various machine learning applications such as binary classification , matrix factorization , convolutional neural networks , generative adversarial networks , contrastive learning and mixture of experts . There are numerous factors that can induce algorithmic regularization. introduce how learning rate and batch size help regularize the training process. explains that while a small initial learning rate may result in prompt training and better performance initially, a larger learning rate tends to yield improved generalization shortly after the annealing of the learning rate. The regularizer’s role in the GAN model is expounded in . In addition, has conducted a theoretical analysis of the regularization generated by momentum. Furthermore, the employment of an adaptive step-size optimizer, such as Adam optimizer, can also function as a form of regularization during the training process . Batch normalization is analyzed in a theoretical capacity in , which delves into its impact on regularization. A separate study conducted by explains how introducing dropout into the training process can prevent overfitting. In , they apply TensorSketch to the Kronecker product of multiple matrices efficiently without explicitly computing the tensor product and also apply the regularization to solve the Kronecker product regression.
Attention Theory
The topic of attention’s expressivity has been a focus of early theoretical works. In the case of self-attention blocks, interpret self-attention as a system of self-interacting particles and theoretically explain the attention. explain it from inductive biases and variable creation perspective. The role of attention in Transformers was studied by . In terms of optimization, examined the impact of adaptive approaches on attention models, while analyzed the dynamics of single-head attention to approximate Seq2Seq architecture’s learning process. For most LLMs, it generally suffices to conduct attention computations in an approximate manner during the inference process, provided that there are adequate assurances of accuracy. Research conducted by various sources such as has underscored this perspective. Due to that motivation, study the computation of the attention matrix from the hardness perspective and purpose faster algorithms.
Newton Method and Hessian Computation
Computing the Hessian or approximately computing the Hessian is a standard task in convex optimization. Many of the previous have work on this direction and use that improve several optimization problems such as linear programming , empirical risk minimization , cutting plane method , semi-definite programming , sum of squares , training over-parameterized neural network .
Roadmap.
We organize the following paper as follows. In Section 2 we provide some tools for basic algebra and the analysis of a regularization term . In Section 3 we provide detailed analysis of the loss function based on (denoted as ) and the loss function with a regularization term . In Section 4 we provide detailed analysis of and . In Section 5 we provide detailed analysis of and . In Section 6 we provide an approximate version of newton method which use for solving convex optimization problem which is more efficient under certain assumptions.
Preliminary
In this section, we provide preliminaries to be used in our paper. In Section 2.1 we introduce notations we use. In Section 2.2 we provide some facts about approximate computations and exact computations. In Section 2.3, we provide some trivial facts regarding gradient and hessian. In Section 2.4, we computed the gradient and hessian of a regularization term .
For a matrix , we use to denote the largest singular value of . We use to denote the smallest singular value of .
We use to denote a length- vector where all the entries are ones.
We say if for all vector .
We define and .
For any function , we use to denote .
2 Basic Algebras
We state some facts which can give exact computation.
We state some facts which can give a reasonable approximate computation.
Part 1. For any satisfy that , we have
Part 2. For any satisfy that , we have
Part 3. For any satisfy that , we have
Part 4. For any satisfy that , we have
Part 5. For any satisfy that , we have
Part 6. For any satisfy that , we have
Most of the proofs are standard, we only provide proofs for some of them.
where the first step follows from the definition of , the second step follows from triangle inequality, the third step follows from simple algebra, the fourth step follows from the fact that for all and the last step follows from the definition of .
where the first step follows from the definition of , the second step follows from triangle inequality, the third step follows from simple algebra, the fourth step follows from the fact that for all and the last step follows from the definition of . ∎
Part 1.
Part 2.
Part 3.
Part 4.
Part 5.
Part 6.
Part 7. For any , we have
Part 8. For any , we have
Part 9. For any , we have
Most of the proofs are standard, we only provide proofs for some of them.
where the first step follows from Part 5 in Fact 2.2 and the last step follows from the definition of norm. By summing up the square of both sides, we have
where the first step follows from Part 6 in Fact 2.2 and the last step follows from the definition of norm. By summing up the square of both sides, we have
If , then
3 Standard Gradient and Hessian Computation
The equation takes derivative of the vector by each entry of itself and trivially gets the result of .
where the first step is an expansion of the Hessian, the second step follows from the differential chain rule, and the last step is due to the constant entries of the matrix .
4 Regularization term
where the first step follows from chain rule.
where the first step follows from the expansion of Hessian, the second step follows from by applying the arguments in Part 1, the third step follows from simple algebra. ∎
where the first step follows from simple algebra, the second step follows from the definition of , the third step follows from simple algebra, the fourth step follows from the definition of , the fifth step follows from definition of , the last step follows from simple algebra . ∎
Exponential Regression
In this section, we provide detailed analysis of . In Section 3.1 we define the loss function based on . In Section 3.2 we compute the gradient of by detail. In Section 3.3 we compute the hessian of by detail. In Section 3.4, we summarize the result of Section 3.2 and Section 3.3 and aquire the gradient and hessian for . In Section 3.5 we define by adding the regularization term in Section 2.4 to and compute the gradient and hessian of . In Section 3.6 we proved that and thus showed that is convex. In Section 3.7 we provide the upper bound for and thus proved is lipschitz.
2 Gradient
where the first and second step follow from the differential chain rule.
where the first step follows from the property of the gradient, the second step follows from simple algebra, and the last step directly follows from Lemma 2.7.
By substitute into of Part 3, we get
where this step follows from the result of Part 4 directly. ∎
3 Hessian
where the first step is an expansion of the Hessian, the second step follows from the differential chain rule, the third step extracts the matrix with constant entries out of the derivative, and the last step also follows from the chain rule.
where the first step is an expansion of the Hessian, the second step follows from Part 3 of Lemma 3.2, the third step follows from Part 3 of Lemma 3.2.
where the first step is an expansion of the Hessian, the second step follows from Part 4 of Lemma 3.2, the third step follows from differential chain rule and Part 1 of Lemma 3.2, the last step follows from Fact 2.3.
where the first step is an expansion of the Hessian, the second step follows from Part 4 of Lemma 3.2, the third step follows from differential chain rule and Part 1 of Lemma 3.2, the last step follows from Fact 2.3.
4 Gradient and Hessian of the Loss function for Exp Function
Part 1. We run Lemma 3.2 and Fact 2.3 directly.
Part 2. It follows from Part 3 and 4 of Lemma 3.3. ∎
5 Loss Function with a Regularization Term
Let be defined as Definition 3.5, then we have
Proof of Part 1. We run Lemma 3.4 and Lemma 2.8 directly.
Proof of Part 2. We run Lemma 3.4 and Lemma 2.8 directly.
6 Hessian is Positive Definite
for all
where the first step follows from simple algebra, the second step follows from replacing with , the third step follows from , the fourth step follows from simple algebra, the fifth step follows from .
Since we know for all and Lemma 2.9, we have
Thus, Hessian is positive definite forever and thus the function is convex.
7 Hessian is Lipschitz
where the first step follows from and simple algebra, the second step follows from Fact 2.5, the third step follows from simple algebra, the fourth step follows from simple algebra, the last step follows from Fact 2.4.
For the second term in Eq. (3.7), we have
where the first step follows from Fact 2.4 , the second step follows from Fact 2.4, the third step follows from , the fourth step follows from , the last step follows from .
where the first step follows from and Fact 2.4, the second step follows from Fact 2.4, the third step follows from Fact 2.4 , the fourth step follows from Fact 2.4, the fifth step follows from Fact 2.5 and , the last step follows from .
where the first step follows from by applying Eq. (2), Eq. (3.7), and Eq. (3.7), the second step follows from simple algebra, the third step follows from , the last step follows from simple algebra.
Cosh Regression
In this section, we provide detailed analysis of . In Section 4.1 we define the loss function based on . In Section 4.2 we compute the gradient of by detail. In Section 4.3 we compute the hessian of by detail. In Section 4.4, we summarize the result of Section 4.2 and Section 4.3 and aquire the gradient and hessian for . In Section 4.5 we define by adding the regularization term in Section 2.4 to and compute the gradient and hessian of . In Section 4.6 we proved that and thus showed that is convex. In Section 4.7 we provide the upper bound for and thus proved is lipschitz.
2 Gradient
where the first and second step follow from the differential chain rule.
where the first step follows from the property of the gradient, the second step follows from simple algebra, and the last step directly follows from Lemma 2.7.
By substitute into of Part 3, we get
where the first step follows from the result of Part 2, the second step follows from the result of Lemma 2.7, the last step follows from Fact 2.3.
this follows from the result of Part 4 directly. ∎
3 Hessian
where the first step is an expansion of the Hessian, the second step follows from the differential chain rule, the third step extracts the matrix with constant entries out of the derivative, and the last step also follows from the chain rule.
where the first step is an expansion of the Hessian, the second and third steps follow from the differential chain rule.
Here in the proof, for simplicity, we let use .
where the first step is an expansion of the Hessian, the second step follows from Part 4 of Lemma 4.2, the third step follows from the product rule of calculus, the fourth step follows from Fact 2.3, the last step follows from Fact 2.3.
where the first step is an expansion of the Hessian, the second step follows from Part 4 of Lemma 4.2, the third step follows from the product rule of calculus, the fourth step follows from Fact 2.3, the last step follows from Fact 2.3.
4 Gradient and Hessian of the Loss function for Cosh Function
Part 1. We run Lemma 4.2 and Fact 2.3 directly.
Part 2. It follows from Part 5 of Lemma 4.3. ∎
5 Loss Function with a Regularization Term
Let be defined as Definition 4.5, then we have
Proof of Part 1. We run Lemma 3.4 and Lemma 2.8 directly.
Proof of Part 2. We run Lemma 3.4 and Lemma 2.8 directly.
6 Hessian is Positive Definite
If for all , then
where the first step follows from simple algebra, the second step follows from replacing with and (Fact 2.1), the third step follows from , the fourth step follows from simple algebra, the fifth step follows from .
Since we know for all and Lemma 2.9, we have
Thus, Hessian is positive definite forever and thus the function is convex. ∎
7 Hessian is Lipschitz
where the first step follows from and simple algebra, the second step follows from Fact 2.5, the third step follows from simple algebra, the fourth step follows from simple algebra, the last step follows from Fact 2.4.
For the second term in Eq. (4.7), we have
where the first step follows from Fact 2.4 , the second step follows from Fact 2.4 , the third step follows from , , the fourth step follows from and the last step follows from .
where the first step follows from and Fact 2.4, the second step follows from Fact 2.4, the third step follows from Fact 2.4, the fourth step follows from , the fifth step follows from Fact 2.5, the last step follows from .
where the first step follows from by applying Eq. (6), Eq. (4.7), and Eq. (4.7), the second step follows from simple algebra, the third step follows from , the last step follows from simple algebra.
Sinh Regression
In this section, we provide detailed analysis of . In Section 5.1 we define the loss function based on . In Section 5.2 we compute the gradient of by detail. In Section 5.3 we compute the hessian of by detail. In Section 5.4, we summarize the result of Section 5.2 and Section 5.3 and aquire the gradient and hessian for . In Section 5.5 we define by adding the regularization term in Section 2.4 to and compute the gradient and hessian of . In Section 5.6 we proved that and thus showed that is convex. In Section 5.7 we provide the upper bound for and thus proved is lipschitz.
2 Gradient
where the first and second step follow from the differential chain rule.
where the first step follows from the property of the gradient, the second step follows from the differential chain rule, and the last step directly follows from Lemma 2.7.
By substitute into of Part 3, we get
where the first step follows from the result of Part 2 and the second step follows from the result of Lemma 2.7, the last step follows from Fact 2.3.
where this step follows from the result of Part 4 directly. ∎
3 Hessian
where the first step is an expansion of the Hessian, the second step follows from the differential chain rule, the third step extracts the matrix with constant entries out of the derivative, and the last step also follows from the chain rule.
where the first step is an expansion of the Hessian, the second and third steps follow from the differential chain rule.
where the first step is an expansion of the Hessian, the second step follows from Part 4 of Lemma 5.2, the third step follows from the product rule of calculus, the fourth step follows from Fact 2.3, the last step follows from Fact 2.3.
where the first step is an expansion of the Hessian, the second step follows from Part 4 of Lemma 5.2, the third step follows from the product rule of calculus, the fourth step follows from Fact 2.3, the last step follows from Fact 2.3.
4 Gradient and Hessian of the Loss function for Sinh Function
Part 1. We run Lemma 5.2 and Fact 2.3 directly.
Part 2. It follows from Part 5 of Lemma 5.3. ∎
5 Loss Function with a Regularization Term
Let be defined as Definition 5.5, then we have
Proof of Part 1. We run Lemma 3.4 and Lemma 2.8 directly.
Proof of Part 2. We run Lemma 3.4 and Lemma 2.8 directly. ∎
6 Hessian is Positive Definite
Let denote a parameter. If for all , then
where the first step follows from simple algebra, the second step follows from replacing with and (Fact 2.1), the third step follows from , the fourth step follows from simple algebra, the fifth step follows from .
Since we know for all and Lemma 2.9, we have
Thus, Hessian is positive definite forever and thus the function is convex. ∎
7 Hessian is Lipschitz
where the first step follows from and simple algebra, the second step follows from Fact 2.5, the third step follows from simple algebra, the fourth step follows from simple algebra, the last step follows from Fact 2.4.
For the second term in Eq. (5.7), we have
where the first step follows from Fact 2.4 , the second step follows from Fact 2.4, the third step follows from Fact 2.4, the fourth step follows from , the fifth step follows from , the last step follows from .
where the first step follows from and Fact 2.4, the second step follows from Fact 2.4, the third step follows from Fact 2.4, the fourth step follows from , the fifth step follows from Fact 2.5, the last step follows from .
where the first step follows from by applying Eq. (10), Eq. (5.7), and Eq. (5.7), the second step follows from simple algebra, the third step follows from , the last step follows from simple algebra.
Newton Method
In this section, we provide an approximate version of the Newton method for solving convex optimization problems and provide a detailed analysis of such a method. In Section 6.1 we define some assumptions under which we can tackle the optimization problem efficiently. In Section 6.2 we state a simple lemma which is useful in Section 6.5. In Section 6.3 we provide an approximation variant for the update step of the newton method for convex optimization. In Section 6.4 we provide the upper bound of . In Section 6.5 we provide the upper bound for and thus showed that our approximate update step is effective in solving the optimization problem. In Section 6.6 we provide a lemma that showed our update step is effective. In Section 6.7, we prove our main result.
Let us study the local convergence of the Newton method. Consider the problem
.
Hessian is -Lipschitz. Let denote a parameter that
Good Initialization Point. Let such that
We define gradient and Hessian as follows
2 Connection between Gradient and Hessian
3 Approximation of Hessian and Update Rule
In many optimization applications, computing or is quite expensive. Therefore, a natural motivation is to approximately formulate its Hessian or inverse of Hessian.
For any , we define to satisfy the following condition
To efficiently compute , we use a standard tool from the literature
4 Property of Hessian
Let be function that Hessian is -Lipschitz (see Definition 6.1)
Suppose the optimal solution satisfy that (see Definition 6.1)
where the first step follows from Fact 2.5, the second step follows from is a -bounded function, the third step follows from . ∎
5 One Step Shrinking Lemma
Function follows from Definition 6.1.
where the first step follows from Definition 6.7, the second step follows from , the third step follows from Lemma 6.4, the forth step follows from , the fifth step follows from simple algebra, the sixth step follows from simple algebra, the last step follows from rewrite the equation using below :
where the first step follows from the definition of , the second step follows from simple algebra, the third step follows from simple algebra, the last step follows from Fact 2.5.
where the first step follows from Eq. (6.5) and by definition of , the second step follows form , the third step follows from , the last step follows from Eq. (6.5), Eq. (6.5), and Eq. (6.5).
6 Induction
, for all
, for all
where the first step follows from Lemma 6.9.
7 Main Result
Let be any of functions and .
Let denote the optimal solution of
that and .
Let for all . (If , see Lemma 3.7)
Let for all . (If , see Lemma 4.7)
Let for all . (If , see Lemma 5.7)
Let denote an initial point such that .
For any accuracy parameter and failure probability . There is a randomized algorithm (Algorithm 1) that runs iterations and spend
holds with probability at least .
It follows from combining Lemma 3.7, Lemma 6.10, Lemma 6.6, and Lemma 6.9.
By choice of , we get the desired bound. The failure probability is following from union bound over iterations.
It follows from combining Lemma 4.7, Lemma 6.10, Lemma 6.6, and Lemma 6.9.
It follows from combining Lemma 5.7, Lemma 6.10, Lemma 6.6, and Lemma 6.9.