生成式AI中数学建模与概率优化工程的本质
The Nature of Mathematical Modeling and Probabilistic Optimization Engineering in Generative AI
AI总结:
本文从数学建模与概率优化角度审视Transformer关键组件,提出最优SWE、word2vec超参数优化、RoPE与ALiBi调和组合、PrFlashAttention及KV缓存SAQ等改进方案。
摘要:
本文深入分析了生成式AI领域中Transformer模型[33]部分关键组件的数学问题表述与概率优化探索。我们从算法和概率优化视角,探讨并讨论了生成式AI模型部分关键底层技术的当前最先进方法可能的进一步增强方向。具体而言,我们基于与文献[9]中byte-pair encoding(BPE,字节对编码)算法相似的初始设置,并采用与文献[28,31]中WordPiece方法相似的目标,提出了一种sub-word encoding(SWE,子词编码)最优解决方案,以最大化训练数据的似然。我们还提出了用于优化word2vec模型[17]超参数的交叉熵优化方法。此外,我们利用调和级数提出了rotary positional encoding(RoPE,旋转位置编码)[32]与attention with linear biases(ALiBi,线性偏置注意力)[23]的因式组合。我们还提出了概率化FlashAttention[6,7](PrFlashAttention)方法:该方法在矩阵中的块距离上引入概率分布,以决定哪个块可能参与给定轮次的注意力计算,同时通过重塑张量为自回归语言模型保持张量的下三角形状。最后,我们基于文献[16]提出的框架,给出了面向multi-query attention(MQA,多查询注意力)的key-value(KV,键值)缓存staircase adaptive quantization(SAQ,阶梯式自适应量化),以实现渐进式量化退化,同时获得合理的模型质量与成本节约。
英文摘要:
In this paper, we give an in-depth analysis on the mathematical problem formulations and the probabilistic optimization explorations for some of the key components in Transformer model [33] in the field of generative AI. We explore and discuss some potential further enhancement for current state of the art methods for some key underlying technologies of generative AI models from algorithmic and probabilistic optimization perspective. In particular, we present an optimal solution for sub-word encoding (SWE) based on similar initial settings as that of byte-pair encoding (BPE) algorithm in [9] with similar objectives as that of WordPiece approach in [28, 31] to maximize the likelihood of the training data. We also present cross entropy optimization method to optimize hyperparameters for word2vec model [17]. In addition, we propose a factored combination of rotary positional encoding (RoPE) [32] and attention with linear biases (ALiBi) [23] with a harmonic series. We also present a probabilistic FlashAttention [6, 7] (PrFlashAttention) method with a probability distribution over block distances in the matrix to decide which block is likely to participate in a given round of attention computation while maintaining the lower triangle shape of the tensor for autoregressive language models by re-shaping the tensors. Finally, we present staircase adaptive quantization (SAQ) of key-value (KV) cache for multi-query attention (MQA) based on the framework presented in [16] to have gradual quantization degradation while achieving reasonable model quality and cost savings.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。