Abstract
Large Language Models (LLMs) rely heavily on the attention mechanism, which unfortunately scales quadratically with sequence length. This paper introduces a novel sub-quadratic iterative algorithm designed to solve "rescaled softmax regression," a mathematical optimization problem that more accurately models the normalization processes in modern Transformer architectures. By extending this framework to hyperbolic functions such as sinh and cosh, the authors provide a unified theoretical approach for optimizing a broader class of neural architectures. The proposed method utilizes an Approximated Newton Method combined with sketching techniques to achieve $\epsilon$-accuracy in sub-quadratic time, supported by rigorous proofs of Hessian stability and Lipschitz continuity.
Introduction
The success of models like GPT-4 is largely attributed to the attention mechanism, which allows the model to dynamically weigh the importance of different tokens in a sequence. However, this mechanism faces a significant "quadratic problem": as the input sequence length ($n$) increases, the computational cost grows by $n^2$. This scaling bottleneck makes processing long-form content, such as entire books or long legal documents, prohibitively expensive.
To mitigate this, researchers often approximate attention computation using regression frameworks. While previous work has explored standard softmax regression, this paper identifies a critical gap: standard formulations do not perfectly align with how attention is normalized in practical implementations. The authors introduce "Rescaled Softmax Regression," which shifts the normalization factor to better reflect the "rescaled" nature of attention units, and generalize the solution to include hyperbolic functions.
The Rescaled Regression Problem
The core of the paper is the definition and solution of a new optimization objective. Unlike classical softmax regression where normalization is often internal to the function, the rescaled version treats the normalization as a multiplier. This shift significantly alters the optimization landscape, requiring a new approach to ensure convergence.
As shown in the figure above, the objective function minimizes the squared difference between a target vector and a rescaled exponential (or hyperbolic) function of the input. The formulation also incorporates weighted L2 regularization (the second term involving $\text{diag}(w)$), mirroring the weight decay techniques used during the training of actual Transformer models. The challenge lies in minimizing this objective efficiently when $n$ is very large.
Algorithmic Methods
The authors propose a randomized iterative algorithm based on an Approximated Newton Method. The strategy involves several key components:
- Hessian Analysis: The researchers prove that the Hessian (the matrix of second-order derivatives) of the rescaled loss function is both Positive Definite and Lipschitz continuous. These properties are essential for ensuring that the optimization landscape is a stable "bowl" shape and that the gradient does not change too abruptly, allowing for reliable convergence.
- Sketching and Subsampling: To overcome the $O(n^2)$ cost associated with standard Newton steps, the algorithm employs "sketching." By subsampling the data to create a sparse approximation of the Hessian, the authors reduce the per-iteration complexity to sub-quadratic time—specifically $O((nnz(A) + d^\omega) \cdot \text{poly}(\log(n/\delta)))$, where $d$ is the hidden dimension and $\omega$ is the exponent of matrix multiplication.
- Iterative Convergence: The algorithm is guaranteed to find an $\epsilon$-approximate solution in $O(\log(1/\epsilon))$ iterations with high probability.
Key Insights and Theoretical Results
- Hyperbolic Versatility: By proving the algorithm works for
sinhandcoshin addition toexp, the authors provide a toolkit for optimizing non-standard attention units that may appear in future neural architectures. - Stability and In-Context Learning (ICL): The paper includes a corollary regarding the stability of the solution under small perturbations. This provides a theoretical foundation for understanding In-Context Learning, suggesting why LLMs remain robust when presented with slightly different prompts or "shots."
- Efficiency Gains: The total running time is nearly linear with respect to the number of non-zero entries in the input matrix $A$. This makes the approach theoretically viable for the massive datasets and long sequences typical of modern AI tasks.
Limitations and Future Directions
While the mathematical framework is rigorous, the authors note some limitations. Like most Newton-style methods, the algorithm's speed is sensitive to the initial starting point ($x_0$). Furthermore, the study is primarily theoretical; it does not provide "wall-clock" benchmarks against empirical methods like FlashAttention. However, the authors suggest that this framework could pave the way for entirely new, more efficient Transformer architectures that move beyond standard exponential attention to more computationally efficient hyperbolic alternatives.
Summary updated