自调整Softmax
Self-Adjust Softmax
AI总结:
针对Softmax在注意力分数极端时梯度消失的问题,提出SA-Softmax通过修改函数形式增强梯度,可无缝集成至Transformer,并在多达27亿参数的多种实验中验证其性能。
摘要:
Softmax函数在Transformer注意力机制中至关重要,它将注意力分数的每一行归一化为总和为1,从而比其他替代函数取得了更优的性能。然而,当注意力分数的某些元素接近极端值(如概率接近1或0)时,Softmax函数可能面临梯度消失问题。在本文中,我们提出自调整Softmax(SA-Softmax)来解决这一问题,通过将$softmax(x)$修改为$x \cdot softmax(x)$及其归一化变体$\frac{(x - min(x_{\min},0))}{max(0,x_{max})-min(x_{min},0)} \cdot softmax(x)$。我们从理论上证明,与原始Softmax函数相比,SA-Softmax提供了增强的梯度特性。此外,SA-Softmax注意力可以无缝集成到现有Transformer模型的注意力机制中,仅需少量调整。我们进行了实验,以评估使用SA-Softmax与原始Softmax函数的Transformer模型的实证性能。这些实验涉及多达27亿参数的模型,并在多种数据集、语言任务和位置编码方法上进行。
英文摘要:
The softmax function is crucial in Transformer attention, which normalizes each row of the attention scores with summation to one, achieving superior performances over other alternative functions. However, the softmax function can face a gradient vanishing issue when some elements of the attention scores approach extreme values, such as probabilities close to one or zero. In this paper, we propose Self-Adjust Softmax (SA-Softmax) to address this issue by modifying $softmax(x)$ to $x \cdot softmax(x)$ and its normalized variant $\frac{(x - min(x_{\min},0))}{max(0,x_{max})-min(x_{min},0)} \cdot softmax(x)$. We theoretically show that SA-Softmax provides enhanced gradient properties compared to the vanilla softmax function. Moreover, SA-Softmax Attention can be seamlessly integrated into existing Transformer models to their attention mechanisms with minor adjustments. We conducted experiments to evaluate the empirical performance of Transformer models using SA-Softmax compared to the vanilla softmax function. These experiments, involving models with up to 2.7 billion parameters, are conducted across diverse datasets, language tasks, and positional encoding methods.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。