[论文解读] Efficient Exact Gradient Update for training Deep Networks with Very Large Sparse Targets
该论文通过避免显式计算D维输出,提出了一种针对非常大且稀疏目标(如神经语言模型中的情况)的深度网络梯度更新的精确O(d²)算法。通过利用平方误差和球面Softmax等结构化损失函数,该方法在GPU上实现了最高达3,257倍的加速,在CPU上实现了最高达763倍的加速,从而实现了无需近似或层次树结构的高效训练。
An important class of problems involves training deep neural networks with sparse prediction targets of very high dimension D. These occur naturally in e.g. neural language models or the learning of word-embeddings, often posed as predicting the probability of next words among a vocabulary of size D (e.g. 200 000). Computing the equally large, but typically non-sparse D-dimensional output vector from a last hidden layer of reasonable dimension d (e.g. 500) incurs a prohibitive O(Dd) computational cost for each example, as does updating the D x d output weight matrix and computing the gradient needed for backpropagation to previous layers. While efficient handling of large sparse network inputs is trivial, the case of large sparse targets is not, and has thus so far been sidestepped with approximate alternatives such as hierarchical softmax or sampling-based approximations during training. In this work we develop an original algorithmic approach which, for a family of loss functions that includes squared error and spherical softmax, can compute the exact loss, gradient update for the output weights, and gradient for backpropagation, all in O(d^2) per example instead of O(Dd), remarkably without ever computing the D-dimensional output. The proposed algorithm yields a speedup of D/4d , i.e. two orders of magnitude for typical sizes, for that critical part of the computations that often dominates the training time in this kind of network architecture.
研究动机与目标
- 解决在训练具有非常大且稀疏目标向量(如语言建模中的词表大小输出)的深度网络时的计算瓶颈问题。
- 在不使用层次Softmax或负采样等近似方法的前提下,实现精确的梯度计算与权重更新。
- 将输出层操作的O(Dd)计算成本降低至O(d²),且与目标大小D无关。
- 在大幅提升训练速度的同时保持模型精度,适用于大规模词表任务。
- 在真实数据集(如One Billion Word语料库)上展示方法的实际可行性与可扩展性。
提出的方法
- 采用输出权重矩阵W = VU的因子分解表示,其中V为D×d,U为d×d,从而避免显式进行D维计算。
- 通过矩阵U和隐藏层激活h重新表述损失函数与梯度计算,使所有操作均在d维空间中完成。
- 对于平方误差和球面Softmax,该算法在不构建D维输出向量的前提下,计算出W的精确梯度更新。
- 利用损失函数的结构,推导出梯度与Hessian的闭式表达式,从而实现高效优化。
- 该算法在CPU(BLAS)和GPU(cuBLAS)上均实现了高效实现,代码在发表后已开源。
- 支持在线训练与小批量训练,并在浮点精度范围内与朴素基线方法保持数值等价。
实验结果
研究问题
- RQ1能否在O(d²)时间内而非O(Dd)时间内,实现对大稀疏目标的精确梯度更新,其中D为目标维度,d为隐藏层大小?
- RQ2所提出的方法是否能在不牺牲大规模词表任务中模型精度的前提下,实现显著的加速?
- RQ3该方法是否可应用于球面Softmax等非标准损失函数,同时保持精确性与高效性?
- RQ4在实际应用中,该方法与层次Softmax或负采样等近似方法相比性能如何?
- RQ5该算法是否可扩展至真实世界数据集(如拥有800,000词表大小的One Billion Word语料库)?
主要发现
- 所提算法在理论上实现了D/(4d)的加速比,当D=793,471且d=300时,GPU上最高实现3,257倍加速,CPU上最高实现763倍加速。
- 因子化方法的GPU实现仅在输出层就比朴素基线快3,257.3倍,整个模型的加速比达到1,852.3倍。
- LST(Large Sparse Target)模型在SimLex-999上的得分仅略低于Softmax模型,但训练速度显著更快。
- 该方法与朴素基线保持数值等价,学习曲线与模型权重(VU)在浮点精度范围内完全一致。
- 加速效果与词表大小D无关,这在不同D值下的对数-对数图中表现为恒定的运行时间。
- 该方法在训练速度上优于层次Softmax,整个模型在CPU上实现125.2倍加速,在GPU上实现178.1倍加速。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。