Skip to main content
QUICK REVIEW

[Paper Review] Efficient Exact Gradient Update for training Deep Networks with Very Large Sparse Targets

Pascal Vincent, Alexandre de Brébisson|arXiv (Cornell University)|Dec 22, 2014
Domain Adaptation and Few-Shot LearningComputer Science12 references17 citations
TL;DR

This paper proposes an exact, O(d²) algorithm for gradient updates in deep networks with very large, sparse targets—such as in neural language models—by avoiding explicit computation of the D-dimensional output. It achieves up to 3,257x speedup on GPU and 763x on CPU by exploiting structured loss functions like squared error and spherical softmax, enabling efficient training without approximation or hierarchical trees.

ABSTRACT

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.

Motivation & Objective

  • To address the computational bottleneck in training deep networks with very large, sparse target vectors (e.g., vocabulary-sized outputs in language modeling).
  • To enable exact gradient computation and weight updates without approximations like hierarchical softmax or negative sampling.
  • To reduce the O(Dd) cost of output layer operations to O(d²), independent of target size D.
  • To maintain model accuracy while drastically improving training speed for large-vocabulary tasks.
  • To demonstrate practical feasibility and scalability on real-world datasets like the One Billion Word corpus.

Proposed method

  • The method uses a factored representation of the output weight matrix W = VU, where V is D×d and U is d×d, to avoid explicit D-dimensional computations.
  • It reformulates the loss and gradient computation using the matrix U and the hidden layer activation h, enabling all operations to be performed in d-dimensional space.
  • For squared error and spherical softmax, the algorithm computes the exact gradient update for W without ever forming the D-dimensional output vector.
  • The approach leverages the structure of the loss function to derive closed-form expressions for the gradient and Hessian, enabling efficient optimization.
  • The algorithm is implemented efficiently on both CPU (BLAS) and GPU (cuBLAS), with code open-sourced upon publication.
  • It supports online and mini-batch training, and maintains numerical equivalence to the naive baseline up to floating-point precision.

Experimental results

Research questions

  • RQ1Can exact gradient updates for large sparse targets be computed in O(d²) time instead of O(Dd), where D is the target dimension and d is the hidden layer size?
  • RQ2Does the proposed method achieve significant speedups without sacrificing model accuracy in large-vocabulary tasks?
  • RQ3Can the method be applied to non-standard loss functions like spherical softmax while maintaining exactness and efficiency?
  • RQ4How does the performance of the proposed method compare to approximate alternatives like hierarchical softmax or negative sampling in practice?
  • RQ5Can the algorithm scale to real-world datasets such as the One Billion Word corpus with 800k vocabulary size?

Key findings

  • The proposed algorithm achieves a theoretical speedup of D/(4d), translating to up to 3,257x speedup on GPU and 763x on CPU for D=793,471 and d=300.
  • The GPU implementation of the factorized method runs 3,257.3x faster than the naive baseline on the output layer alone, with a whole-model speedup of 1,852.3x.
  • The LST (Large Sparse Target) model converges to SimLex-999 scores only slightly lower than softmax models but trains significantly faster.
  • The method maintains numerical equivalence to the naive baseline, with identical learning curves and model weights (VU) up to floating-point precision.
  • The speedup is independent of vocabulary size D, as shown by constant timing across different D values in log-log plots.
  • The approach outperforms hierarchical softmax in training speed, with a 125.2x speedup on CPU and 178.1x on GPU for the whole model.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.