The quadratic time and memory complexity inherent to self-attention mechanisms, with respect to sequence length, presents a critical computational bottleneck in the training and deployment of large-scale Transformer-based language models. Recent theoretical results indicate the intractability of sub-quadratic softmax attention approximation under reasonable complexity assumptions. This paper addresses this challenge by first demonstrating that polynomial attention with high degree can effectively replace softmax without sacrificing model quality. Next, we develop polynomial sketching techniques from numerical linear algebra to achieve linear-time polynomial attention with approximation guarantees. Crucially, our approach achieves this speedup without requiring the sparsification of attention matrices. We also present a block-based algorithm to apply causal masking efficiently. Combining these techniques, we provide \emph{PolySketchFormer}, a practical linear-time Transformer architecture for language modeling that offers provable guarantees.
We validate PolySketchFormer empirically by training language models capable of handling long contexts. These experiments utilize both synthetic and real-world datasets (PG19, Wikipedia and C4) on Google Cloud TPUs. For context lengths of 32k and GPT-2 style models, our model achieves a 2.5-4x speedup in training compared to FlashAttention, with no observed degradation in quality across our experiments.
Norwegian University of Science and Technology(挪威科技大学)
加权最小哈希是一种标准的降维技术,可应用于相似性搜索和大规模核机器。我们介绍了一个简单的算法,采用加权集$x \in \mathbb{R}_{\geq 0}^{d}$并在预期时间$O(k \log k + \Vert x \Vert_{0}\log( \Vert x \Vert_1 + 1/\Vert x \Vert_1))$内计算$k$独立minhash,改进了最先进的BagMinHash算法(KDD '18),并代表了稀疏数据的最快加权minhash算法。我们的实验表明,与ICWS(ICDM '10)和BagMinhash相比,$k$和$\Vert x \Vert_0$的运行时间扩展更好,在常见用例中获得$10$ x加速。我们的方法还产生了一种技术,用于计算完全独立的局部敏感的哈希值$(L, K)$ -参数化的近似近邻搜索加权Jaccard相似性下的最佳预期时间$O(LK + \Vert x \Vert_0)$,改善以前的工作,即使在未加权集的情况下。