Word2vec is a widely used algorithm for extracting low-dimensional vector representations of words. State-of-the-art algorithms including those by Mikolov et al. [5, 6] have been parallelized for multi-core CPU architectures, but are based on vector-vector operations with "Hogwild" updates that are memory-bandwidth intensive and do not efficiently use computational resources. In this paper, we propose "HogBatch" by improving reuse of various data structures in the algorithm through the use of minibatching and negative sample sharing, hence allowing us to express the problem using matrix multiply operations. We also explore different techniques to distribute word2vec computation across nodes in a compute cluster, and demonstrate good strong scalability up to 32 nodes. The new algorithm is particularly suitable for modern multi-core/many-core architectures, especially Intel's latest Knights Landing processors, and allows us to scale up the computation near linearly across cores and nodes, and process hundreds of millions of words per second, which is the fastest word2vec implementation to the best of our knowledge. We refer the reader to [5, 6] for an introduction to word2vec and its optimization problem. The original implementation of word2vec by Mikolov et al. 1 uses Hogwild [7] to parallelize SGD. Hogwild is a parallel SGD algorithm that seeks to ignore conflicts between model updates on different threads and allows updates to proceed even in the presence of conflicts. The psuedocode of word2vec Hogwild SGD is shown in Algorithm 1. The algorithm takes in a matrix M V ×D in that contains the word representations for each input word, and a matrix M V ×D out for the word representations of each output word. Each word is represented as an array of D floating point numbers, corresponding to one row of the two matrices. These matrices are updated during the training. We take in a target word, and a set of N input context words around the target as depicted in the top of Figure 1 Algorithm 1 reads and updates entries corresponding to the input context and positive/negative words at each iteration of the loop at Line 6. This means that there is a potential dependence between successive iterations -they may happen to touch the same word representations, and each iteration must potentially wait for the update from the previous iteration to complete. Hogwild ignores such
The work done by Ji et al. REF demonstrates strong scalability on CPU nodes by using a scheme based on minibatching and shared negative samples.
Parallelizing Word2Vec in Multi-Core and Many-Core Architectures
ArXiv
ArXiv
Computer Science Mathematics