Title: EFFICIENT SOFTMAX APPROXIMATION FOR GPUS

Abstract: We propose an approximate strategy to efficiently train neural network based language models over very large vocabularies. Our approach, called adaptive softmax, circumvents the linear dependency on the vocabulary size by exploiting the unbalanced word distribution to form clusters that explicitly minimize the expectation of computational complexity. Our approach further reduces the computational cost by exploiting the specificities of modern architectures and matrix-matrix vector operations, making it particularly suited for graphical processing units. Our experiments carried out on standard benchmarks, such as EuroParl and One Billion Word, show that our approach brings a large gain in efficiency over standard approximations while achieving an accuracy close to that of the full softmax. The code of our method is available at https://github.com/facebookresearch/adaptive-softmax.

1. INTRODUCTION:

This paper considers strategies to learn parametric models for language modeling with very large vocabularies. This problem is key to natural language processing, with applications in machine translation (Schwenk et al., 2012; Sutskever et al., 2014; Vaswani et al., 2013) or automatic speech recognition (Graves et al., 2013; Hinton et al., 2012) . In particular, Neural Network Language Models (NNLMs) have received a renewed interest in recent years, by achieving state of the art performance on standard benchmarks (Jozefowicz et al., 2016; Mikolov et al., 2010) . These approaches are more costly but generalize better than traditional non-parametric models (Bahl et al., 1983; Kneser & Ney, 1995) .

Statistical language models assign a probability to words given their history (Bahl et al., 1983) . They are evaluated by objective criteria such as perplexity (ppl), which directly measures the ability of the system to determine proper probabilities for all the words. This potentially makes parametric models prohibitively slow to train on corpara with very large vocabulary. For instance, the vocabulary of the One Billion Word benchmark (Chelba et al., 2013) contains around 800K words. In standard NNLMs, such as feedforward networks (Bengio et al., 2003a) or recurrent networks (Mikolov et al., 2010) , computing this probability over the whole vocabulary is the bottleneck. Many solutions have been proposed to reduce the complexity of this expensive step (Bengio et al., 2003b; Goodman, 2001a; Gutmann & Hyvärinen, 2010) . We distinguish (i) the methods that consider the original distribution and aim at providing approximations of the probabilities, or of a subset of them (Bengio et al., 2003b; Ji et al., 2015) , from (ii) the approaches that compute exact probabilities for an approximate model yielding a lower computational cost, such as the popular hierarchical softmax (Goodman, 2001a; Mnih & Hinton, 2009; Morin & Bengio, 2005) .

Our approach, called adaptive softmax, belongs to the second category. More specifically, it is inspired by the hierarchical softmax and its subsequent variants. In contrast to previous works and motivated by the trend that GPUs are comparatively more and more performant than CPUs, our design is oriented towards efficient processing on GPUs. In this context, our paper makes the following points:

• We define a strategy to produce an approximate hierarchical model. It departs from previous ones in that it explicitly takes into account the complexity of matrix-matrix multiplications on modern architectures, which is not trivially linear in the dimensions of the matrices.

• We conduct an empirical complexity analysis of this model on recent GPUs. This leads us to define a realistic complexity model that is incorporated in the proposed optimization;

• Our approach provides a significant acceleration factor compared to the regular softmax, i.e., 2× to 10× speed-ups. Equivalently we improve the accuracy under computational constraints. Importantly, on the largest corpus, this higher efficiency empirically comes at no cost in accuracy for a given amount of training data, in contrast to concurrent approaches improving the efficiency.

This paper is organized as follows. Section 2 briefly reviews the related work and Section 3 provides some background on the language modeling task that we consider. Section 4 describes our proposal, which is subsequently evaluated in Section 5 on typical benchmarks of the language modeling literature, including Text8, Europarl and One Billion Word datasets.

2. RELATED WORK:

Many methods have been proposed to approximate the softmax efficiently (Bengio et al., 2003b; Goodman, 2001a; Gutmann & Hyvärinen, 2010; Morin & Bengio, 2005) . We briefly describe the most popular ones below and point the reader to Chen et al. (2015) for a comparative study. For the sake of completeness, we refer the reader to other strategies that can speed-up the training of language models in complementary manners (Mikolov et al., 2011b) .

Loss function approximation. The Hierarchical Softmax (HSM) is an approximation of the softmax function introduced by Goodman (2001a) . This approach is generally used with a two-level tree (Goodman, 2001a; Mikolov et al., 2011c) but has also been extended to deeper hierarchies (Morin & Bengio, 2005; Mnih & Hinton, 2009) . In general, the hierarchy structure is built on word similarities (Brown et al., 1992; Le et al., 2011; Mikolov et al., 2013) or frequency binning (Mikolov et al., 2011c) . In particular, Mikolov et al. (2013) proposes an optimal hierarchy by constructing a Huffman coding based on frequency. However this coding scheme does not take into account the theoretical complexity reduction offered by matrix-matrix multiplication and distributed computation, in particular with modern GPUs.

Similar to our work, Zweig & Makarychev (2013) constructs their hierachy in order to explicitly reduce the computational complexity. They also solve the assignment problem with dynamic programming. However, they only consider hierachies where words are kept in the leaves of the tree, leading to a significant drop of performance (reported to be around 5 -10%), forcing them to also optimize for word similarity. In our case, allowing classes to be stored in the internal node of the tree leads to almost no drop of performance. Also, they assume a linear cost for the vector-matrix operation which significantly limits the use of their approach on distributed system such as GPU.

The idea of keeping a short-list of the most frequent words has been explored before (Le et al., 2011; Schwenk, 2007) . In particular, Le et al. (2011) combines a short-list with a hierachical softmax based on word representation. In contrast, the word hierarchy that we introduce in Section 4 explicitly aims at reducing the complexity.

Our work also shares similarities with the d-softmax introduced by Chen et al. (2015) . They assign capacity to words according to their frequency to speed up the training. Less frequent words have smaller classifiers than frequent ones. Unlike our method, their formulation requires accessing the whole vocabulary to evaluate the probability of a word.

Sampling based approximation. Sampling based approaches have been successfully applied to approximate the softmax function over large dictionaries in different domains, such as language modeling (Jozefowicz et al., 2016) , machine translation (Jean et al., 2015) and computer vision (Joulin et al., 2015) . In particular, importance sampling (Bengio & Senécal, 2008; Bengio et al., 2003b) selects a subset of negative targets to approximate the softmax normalization. Different schemes have been proposed for sampling, such as the unigram and bigram distribution (Bengio et al., 2003b) or more recently, a power-raised distribution of the unigram (Ji et al., 2015; Mikolov et al., 2013) . While this approach often leads to significant speed-up at train time, it still requires to evaluate the full softmax at test time.

Self-normalized approaches. Self-normalized approaches aim at learning naturally normalized classifier, to avoid computing the softmax normalization. Popular methods are Noise Contrastive Estimation (Gutmann & Hyvärinen, 2010; Mnih & Teh, 2012; Vaswani et al., 2013) or a penalization on the normalization function (Andreas & Klein, 2014; Devlin et al., 2014) . Noise Contrastive Estimation (Gutmann & Hyvärinen, 2010) replaces the softmax by a binary classifier distinguishing the original distribution form a noisy one. While the original formulation still requires to compute the softmax normalization, Mnih & Teh (2012) shows that good performance can be achieved even without it.

Finally, Vincent et al. (2015) have also proposed an efficient way to train model with high dimensional output space. Their approach is exact and leads to a promising speed-up but it cannot be directly applied to the softmax function, limiting its potential application to language modeling.

3. PRELIMINARIES ON LANGUAGE MODELING:

The goal of language modeling is to learn a probability distribution over a sequence of words from a given dictionary V. The joint distribution is defined as a product of conditional distribution of tokens given their past (Bahl et al., 1983) . More precisely, the probability of a sequence of T words w 1 , . . . , w T ∈ V T is given as

EQUATION

)

This problem is traditionally addressed with non-parameteric models based on counting statistics (Goodman, 2001b) . In particular, smoothed N-gram models (Bahl et al., 1983; Katz, 1987; Kneser & Ney, 1995) achieve good performance in practice (Mikolov et al., 2011a) , especially when they are associated with cache models (Kuhn & De Mori, 1990) . More recently, parametric models based on neural networks have gained popularity for language modeling (Bengio et al., 2003a; Jozefowicz et al., 2016; Mikolov et al., 2010) . They are mostly either feedforward networks (Bengio et al., 2003a) or recurrent networks (Mikolov et al., 2010) .

Feedforward network. In a standard feedforward network for language modeling, we fix a window of length N and predict the next words according to the words appearing in this window. In the simplest case, this probability is represented by a 2-layer neural network acting on an input x t ∈ V N , defined as the concatenation of the one-hot representation of the N previous words, w t-N +1 , . . . , w t .

The state h t of the hidden layer and subsequently the vector of scores y t associated with the next token w t+1 are computed as

EQUATION

y t = f (Bh t ),

(3) where σ is a non linearity, e.g., the pointwise sigmoid function σ(z) = 1/(1 + exp(-z)), and f is the softmax function discussed in the next section. This model is parameterized by the weight matrices P , A and B and is routinely learned with an optimization scheme such as stochastic gradient descent or Adagrad (Duchi et al., 2011) .

Recurrent network. A Recurrent network (Elman, 1990) extends a feedforward network in that the current state of the hidden layer also depends on its previous state. The hidden state h t is updated according to the equation h t = σ(Aw t + Rh t-1 ), where R is a weight matrix and x t is the one-hot representation of the current word w t . Computing the exact gradient for this model is challenging but it is possible to compute an efficient and stable approximation of it, using a truncated back-propagation through time (Werbos, 1990; Williams & Peng, 1990 ) and norm clipping (Mikolov et al., 2010) .

Since the model introduced by Elman (1990), many extensions have been proposed, such as Longer Short Term Memory (LSTM) (Hochreiter & Schmidhuber, 1997) , Gated recurrent units (Chung et al., 2014) or structurally constrained network (Mikolov et al., 2014) . These models have been successfully used in the context of language modeling (Jozefowicz et al., 2016; Mikolov et al., 2010; Mikolov & Zweig, 2012) . In this work, we focus on the standard word level LSTM architecture since it has obtained state of the art performance on the challenging One Billion Word Benchmark (Jozefowicz et al., 2016) .

Class-based hierarchical softmax. In neural language modeling, predicting the probability of the next word requires to compute scores for every word in the vocabulary and to normalize them to form a probability distribution. This is typically achieved by applying a softmax function to the unnormalized score z w associate with each word w, where the softmax function is defined as

EQUATION

)

For a vocabulary comprising k = |V| words, this function requires O(k) operations once the scores are computed. In the case of neural networks, the overall complexity is O(dk), where d is the size of the last hidden layer. When the vocabulary is large, this step is computationally expensive and often dominates the computation of the whole model (Jozefowicz et al., 2016; Mikolov et al., 2014) , as discussed in introduction and related work. A simple approach (Goodman, 2001a) to reduce this computational cost is to assign each word w of the vocabulary to a unique class C(w) and to factorize the probability distribution over words as

p(w t | h t ) = p 1 (C(w t ) | h t ) × p 2 (w t | C(w t ), h t ),

where p 1 and p 2 are obtained using the softmax function (Eq. 4). If each class contains

√ k words, the computational cost is reduced from O(dk) to O(d √ k).

4. OUR APPROACH: THE ADAPTIVE SOFTMAX:

In this section, we propose the adaptive softmax, a simple speedup technique for the computation of probability distributions over words. The adaptive softmax is inspired by the class-based hierarchical softmax, where the word classes are built to minimize the computational complexity. Our method is designed to be efficient for GPUs, which are commonly used to train neural networks. For the sake of clarity, we first present the intuition behind our method in the simple case where we simply split our dictionary in two distinct clusters, before analyzing a more general case.

4.1. GPU COMPUTATIONAL MODEL:

The bottleneck of the model described in the previous section is the matrix multiplication between the matrix representing the hidden states (of size B × d, where B denotes the batch size), and the matrix of word representations, of size d × k. For a fixed size d of the hidden layer, we denote by g(k, B, d) the complexity of this multiplication, and simplify the notation wherever some parameters are fixed. Figure 1 reports empirical timings as a function of k for typical parameters of B and d for two GPU models, namely K40 and Maxwell. We observe that the complexity g(k) is constant for low values of k, until a certain inflection point k 0 ≈ 50, and then becomes affine for values k > k 0 . This suggests a cost function of the form

EQUATION

Empirically, c m = 0.40 ms on a K40 and 0.22 ms on a Maxwell. We observe the same behavior when measuring the timings as a function of the other parameters, i.e., it is inefficient to matrix-multiply when one of the dimensions is small. This observation suggests that hierarchical organizations of words with a low number of children per node, such as binary Huffman codes, are highly suboptimal.

4.2. INTUITION: THE TWO-CLUSTERS CASE:

In natural languages, the distribution of the words notoriously follows a Zipf law (Zipf, 1949) . Most of the probability mass is covered by a small fraction of the dictionary, e.g., 87% of the document is covered by only 20% of the vocabulary in the Penn TreeBank. Similar to the frequency binning hierarchical softmax (Mikolov et al., 2011c) , this information can be exploited to reduce the computation cost.

A simple strategy to reduce the overall complexity is to partition the dictionary V into two clusters as V h and V t , where V h denotes the head of the distribution consisting of the most frequent words, and where V t is the tail associated with a large number of rare words. The classifier frequently accesses the head, which motivates the fact that it should be computed efficiently. In contrast, the tail occurs

������ ���� ����� ������ �� � � � � � � � � � � � � � � � � � � �� � �� � �� � �� � �� � �� � � � � � � �� � � � � � � � � � � � � � � � � � ������������������� ��� �������

Figure 1 : GPU timings for multiplying two matrices in the dominant step of the RNN model. We consider matrices of size 2560 × 2048 and 2048 × k representing hidden states and word representations. We report the timings as a function of k (number of word representations), and we compute the averages (circles) over 1000 measures, and the minima and maxima for the K40. The standard deviation does not exceed 5% of each timing. less frequently and the corresponding computation can be slower. This suggests to define clusters with unbalanced cardinalities |V h | |V t | and probabilities P (V h ) P (V t ), where P (A) = w∈A p i is the probability of a word to occur in the set V i . For instance, one may define the head would only contain 20% of the vocabulary (covering for 87% on PennTree Bank). These two clusters can be organized in two different ways: either they are both leaves of a 2-level tree (Mikolov et al., 2011c) , or the head cluster is kept as a short-list in the root node (Le et al., 2011) . We now analyze what is the best structure and how to split the vocabulary by determining the corresponding complexities, assuming that the head consists of the most frequent words. The next subsection shows the optimality of this choice.

Given a vocabulary of k words, we are looking for the number k h = |V h | of words from the head of the distribution to be assigned to the first cluster. These words will cover for p h of the distribution. The tail cluster will then contain the rest of the vocabulary, made of k t = k -k h words and covering for p t = 1 -p h of the overall distribution. We denote by g(k, d) the computational complexity of computing the softmax function over k words with d dimensional input features. Figure 1 shows an example of this function for a fixed d. The complexity of putting the head of the distribution in the root of the tree is g(k h + 1, d) + p t g(k t , d), while the complexity associated with putting both cluster in leaves is g(2, d) + p h g(k h , d) + p t g(k t , d). Depending on the distribution of a corpus, it is then simple to choose the best assignment of words into the two clusters. For example, on PennTree Bank, with a hidden layer of size d = 128, the optimal configuration is to keep a short-list of 1400 classes in the root node, leading to an average cost of 0.33 ms per batch of size 512, while it takes 0.36 ms when both clusters are in the leaves. In comparison, the full softmax takes 0.80 ms for the same configuration, leading to a ×2.4 speed-up.

Adapting the classifier capacity for each cluster. Each cluster is accessed independently of each other, they thus do not need to have the same capacity. Frequent words need high capacity to be predicted correctly. In contrast, rare words cannot be learned very well, since we only see them a few times. It would then be wasteful to associate them with high capacity. Like in Chen et al. (2015) , we exploit this observation to further reduce the computational cost of our classifier. Unlike Chen et al. (2015) , we share the state of hidden layer across clusters and simply reduce the input size of the classifiers by applying a projection matrix. Typically, the projection matrix for the tail cluster reduces the size from d to d t = d/4, reducing the complexity from g(k t , d) to g(d t , d) + g(k t , d t ).

Compromising between efficiency and accuracy. We observe empirically that putting all the clusters in the leaves of the tree leads to a significant drop of performance (around 5 -10% performance drop, Mikolov et al., 2011c; Zweig & Makarychev, 2013) . The reason is that the probability of every word w belonging to a cluster c is multiplied by the probability of its class, i.e., it is equal to P (c | h)P (w | c, h), while attaching a frequent word directly to the root associates it directly to the probability P (w | h) making its inference sharper. For this reason, unless there is a significant difference in computational complexity, we favor using a short-list, over the standard 2-level hierarchical softmax.

V h V 1 V 2 V 3

Figure 2: Our hierarchical model is organized as (i) a first level that includes both the most frequent words and vectors representing clusters, and (ii) clusters on the second level that are associated with rare words, the largest ones being associated with the less frequent words. The sizes are determined so as to minimize our cost model on GPU.

4.3. GENERAL CASE:

Let us now consider the more general case where the dictionary is partitioned as

V = V h ∪ V 1 . . . V J , V i ∩ V j = ∅ if i = j.

We consider the hierarchical model depicted in Figure 2 , where the subdictionary V h is accessed at the first level, and the others in the second level. We now investigate the computational cost C of the forward (equivalently, backward) pass of this approximate softmax layer. For the time being, we fix the batch size B and the dimensionality d of the hidden layer, in order to analyze the complexity as a function of the sub-dictionary sizes and probabilities. We denote by p i = w∈Vi p(w) the probability P (w ∈ V i ) and k i = |V i | the cardinality of each cluster.

The expected cost C is decomposed as

EQUATION

leading to

EQUATION

We add the constraint k ≥ k 0 to ensure that there is no penalty induced by the constant part of the cost model of Equation 5, the previous equation simplifies as

EQUATION

Let us discuss this equation, by first considering that the cardinalities of the sub-vocabularies are fixed. The right-most term is the only one that depends on the word probabilities. For two distinct clusters V i and V j , we can re-write p j k j as (p i+j -p i )k j , where p i+j = p i + p j , so that

EQUATION

Without loss of generality, we assume that k i > k j . The quantities p i+j , k i and k j being fixed, the second term of the right-hand side of this equation is constant, and the best strategy is trivially to minimize the probability of the largest cluster V i . In other terms, an optimal solution for Equation 9requires that the most frequent words are assigned to the smallest cluster. This remark is true for any tuple (i, j), and we easily see that this point also holds for the head cluster. As a consequence, for a fixed number of clusters of given sizes, the best strategy is to assign the words by decreasing probabilities to clusters of increasing size. Note, this analysis remains valid as long as the g is monotonically increasing in k.

Determining k i with J fixed: dynamic programming. We now assume that the number of clusters is fixed. Following our analysis above, the optimization solely depends on the cardinalities k i for all clusters, which perfectly determines how to split the list of words ordered by frequency. We solve this problem by dynamic programming.

Finding the number of clusters. The only remaining free variable in our optimization is J, since the other parameters are then determined by the aforementioned optimizations. For this step, the cost of Equation 9 over-estimates the number of clusters because we have neglected the effect of the non-linearity of the batch size: in the second layer, the batches are typically smaller than the inflection 

5. EXPERIMENTS:

This section provides a set of experiments aiming at analyzing the trade-off between actual complexity and effectiveness of several strategies, in particular the approach presented in the previous section. First we describe our evaluation protocol, then we evaluate some of the properties of our model and finally we compare it on standard benchmark against standard baselines.

Datasets. We evaluate our method on standard datasets, and use the perplexity (ppl) as an evaluation metric, as the function of the training time or of the number of training data (epochs). The datasets have varying vocabulary sizes, in different languages, which allows us to better understand the strengths and weaknesses of the different approaches.

• Text81 is a standard compression dataset containing a pre-processed version of the first 100 million characters from Wikipedia in English. It has been recently used for language modeling (Mikolov et al., 2014) and has a vocabulary of 44k words.

• Europarl2 is a machine translation corpus, containing 20 languages (Koehn, 2005) . For most languages, there are 10M-60M tokens and the vocabulary is in between 44k and 250k words.

• One Billion Word3 is a massive corpus introduced by Chelba et al. (2013) . It contains 0.8B tokens and a vocabulary comprising almost 800k words.

Implementation details. We use an LSTM with one layer in all our experiments. On Text8 and Europarl, the models have d = 512 hidden units and are regularized with weight decay (λ = 10 -6 ).

Model Test perplexity:

Interpolated Kneser-Ney 5-gram (Chelba et al., 2013) 67.6 Feedforward NN + D-Softmax (Chen et al., 2015) 91.2 4-layer IRNN-512 (Le et al., 2015) 69.4 RNN-2048 + BlackOut sampling (Ji et al., 2015) 68.3 Sparse Non-negative Matrix Language Model (Shazeer et al., 2015) 52.9 RNN-1024 + MaxEnt 9-gram (Chelba et al., 2013) 51.3 LSTM-2048-512 (Jozefowicz et al., 2016) 43.7 2-layer LSTM-8192-1024 + CNN inputs (Jozefowicz et al., 2016) 30.0

Ours (LSTM-2048) 43.9 Ours (2-layer LSTM-2048) 39.8

Table 2 : One Billion Word benchmark. Perplexity on the test set for single models. Our result is obtained after 5 epochs.

On the One Billion Word benchmark, we use d = 2048 hidden units and no regularization. The dimension of the input word embeddings is set to 256, so that large models fit in GPU memory. For the backpropagation through time, we unroll the models for 20 steps. We use Adagrad (Duchi et al., 2011) , with a step size of 0.1 and 5 epochs, and we clip the norm of the gradients to 1. The batch size B is set to 128, except on the Finnish portion of Europarl where B=64 due to memory constraints.

All the experiments were run on the same GPU with the Maxwell architecture.

Baselines. Our method is compared to: (1) the full softmax, (2) the hierarchical softmax (HSM) with frequency binning (Mikolov et al., 2011b) , (3) importance sampling (Bengio et al., 2003b; Bengio & Senécal, 2008) and (4) the differentiated softmax (Chen et al., 2015) . For HSM, we tried different strategies for the binning. We observe that using the square root function on the count before computing the word bins is the most efficient. For the negative sampling method, we used a number of samples equal to 20% of the size of the vocabulary (Chen et al., 2015) . For the differentiated softmax (D-softmax), we used the same partitions for the vocabulary as for our approach. We tried two version of the differentiated softmax. The first is the one described by Chen et al. (2015) , where each word cluster uses a disjoint subset of the hidden representation. We also present an improved version, referred to as D-softmax [*], which uses our choice to have the whole hidden representation mapped to the different word clusters using projection matrices of different sizes.

Comparison with the state of the art. Table 1 reports the results that we achieve on Text8. On this small vocabulary, approximate methods are comparatively less interesting. Our approach is the only one to approach the result of the full soft-max (below by 3 points of perplexity), while being the fastest. Our improved variant D-softmax [*] of the work by Chen et al. (2015) obtains similar results but is slower by a factor ×1.8.

On Europarl, we first present the convergence properties of our approach compared to other approximate strategies in Figure 3 show the perplexity (ppl) as a function of training time. Our approach significantly outperforms all competitors by a large margin. For reference, we also show the performance (D-softmax [*]) obtained by improving the D-softmax, to make it more comparable to our method. Our method is 2× to 3× faster than this improved competitor, which demonstrates how critical is our optimization strategy. Similar conclusions are drawn from Table 3 for other languages from the Europal corpus.

Table 2 gives the test perplexity on One Billion Word benchmark: Our method achieves a perplexity of 43.9 after five epochs, taking less than three days to train on a single GPU. In comparison, only Jozefowicz et al. (2016) achieves a lower perplexity, but with a model 8× bigger than ours and trained over 32 GPUs during 3 weeks. We also note that for models of similar size, we achieve similar perplexity than the method introduced by Jozefowicz et al. (2016) . As far as we know, ours the first method to achieve a perplexity lower than 50 on a single GPU. 

6. CONCLUSION:

In this paper, we have proposed a simple yet efficient approximation of the softmax classifier. To our knowledge, it is the first speed optimizing approximation that obtains performance on par with the exact model. This is achieved by explicitly taking into account the computational complexity of parallel systems and combining it with a few important observations, namely keeping a short-list of frequent words in the root node (Schwenk, 2007) and reducing the capacity of rare words (Chen et al., 2015) . In all our experiments on GPU, our method consistently maintains a low perplexity while enjoying a speed-up going from 2× to 10× compared to the exact model. This type of speed-up allows to deal with extremely large corpora in reasonable time and without the need of a large number of GPUs. We believe our approach to be general enough to be applied to other parallel computing architectures and other losses, as well as to other domains where the distributions of the class are unbalanced.

:

http://mattmahoney.net/dc/textdata

http://www.statmt.org/europarl/

https://code.google.com/archive/p/1-billion-word-language-modeling-benchmark/

Figures and Tables:

Text8. Perplexity and training time after 5 epochs. Our approach is significantly better than other published approximate strategies. We also show that improving the baseline D-softmax [*] as discussed in text improve the results, but is slower than our proposal. Note, approximate strategies are comparatively less interesting for small vocabularies such as in this case. k 0 . In practice, we optimize over small values of J = 1, 2, 3, 4 and empirically determine the best compromise speed/perplexity on training data. Note, having a lower number of clusters with numerous frequent words on the first level has another flavor: we empirically observe that it offers a better perplexity than word hierarchy with a large number of clusters. It is comparable to that of the exact softmax for large corpora, as shown later by our experiments.

Table content: <table><tr><td/><td/><td/><td>ppl</td><td colspan="2">training time</td><td/><td/><td/><td/></tr><tr><td colspan="2">full softmax</td><td/><td>144</td><td colspan="2">83 min</td><td/><td/><td/><td/></tr><tr><td colspan="2">sampling</td><td/><td>166</td><td colspan="2">41 min</td><td/><td/><td/><td/></tr><tr><td colspan="2">HSM (freq)</td><td/><td>166</td><td colspan="2">34 min</td><td/><td/><td/><td/></tr><tr><td colspan="2">D-softmax</td><td/><td>195</td><td colspan="2">53 min</td><td/><td/><td/><td/></tr><tr><td colspan="4">D-softmax [*] 147</td><td colspan="2">54 min</td><td/><td/><td/><td/></tr><tr><td colspan="2">Ours</td><td/><td>147</td><td colspan="2">30 min</td><td/><td/><td/><td/></tr><tr><td>����������</td><td>���� ���� ���� ���� ����</td><td/><td/><td/><td colspan="3">������������ �������� ��� ������������� ����</td><td/><td/><td>Figure 3: Training on Europarl (Finnish): perplexity (on validation) as the function of time for our method and approaches from the state of the art. We represent the result after each epoch by a point. Our method fa-vorably compares with all other ap-</td></tr><tr><td/><td>����</td><td/><td/><td/><td/><td/><td/><td/><td/><td>proaches w.r.t. the tradeoff perplexity and training time, and of training data</td></tr><tr><td/><td>���</td><td/><td/><td/><td/><td/><td/><td/><td/><td>vs perplexity. Similar conclusions are</td></tr><tr><td/><td>��</td><td>����</td><td>����</td><td>����</td><td>����</td><td>����</td><td>����</td><td>����</td><td>����</td><td>drawn for the other languages.</td></tr><tr><td/><td/><td/><td/><td colspan="3">����������</td><td/><td/><td/></tr></table>

Europarl. Perplexity after 5 epochs for different languages as a function of time t (minutes).

Table content: <table><tr><td>Language:</td><td>bg</td><td/><td>cs</td><td/><td>da</td><td/><td>de</td><td/><td>el</td><td/><td>es</td><td/></tr><tr><td>k=</td><td>50k</td><td/><td>83k</td><td/><td>128k</td><td/><td>143k</td><td/><td>100k</td><td/><td>87k</td><td/></tr><tr><td>Method</td><td>ppl</td><td>t</td><td>ppl</td><td>t</td><td>ppl</td><td>t</td><td>ppl</td><td>t</td><td>ppl</td><td>t</td><td>ppl</td><td>t</td></tr><tr><td>Full</td><td colspan="2">37 58</td><td colspan="2">62 132</td><td colspan="2">37 713</td><td colspan="2">42 802</td><td colspan="2">38 383</td><td colspan="2">30 536</td></tr><tr><td>Sampling</td><td colspan="2">40 29</td><td>70</td><td>53</td><td colspan="2">40 247</td><td colspan="2">45 262</td><td colspan="2">41 144</td><td colspan="2">32 217</td></tr><tr><td>HSM (freq)</td><td colspan="2">43 17</td><td>78</td><td>29</td><td colspan="2">42 114</td><td colspan="2">51 124</td><td>45</td><td>73</td><td colspan="2">34 110</td></tr><tr><td>D-softmax</td><td colspan="2">47 36</td><td>82</td><td>75</td><td colspan="2">46 369</td><td colspan="2">56 397</td><td colspan="2">50 211</td><td colspan="2">38 296</td></tr><tr><td>D-softmax [*]</td><td colspan="2">37 36</td><td>62</td><td>76</td><td colspan="2">36 366</td><td colspan="2">41 398</td><td colspan="2">37 213</td><td colspan="2">29 303</td></tr><tr><td>Ours</td><td colspan="2">37 18</td><td>62</td><td>30</td><td colspan="2">35 105</td><td colspan="2">40 110</td><td>36</td><td>72</td><td colspan="2">29 103</td></tr></table>

Peer review (iclr2017):
SYNOPSIS: The authors introduce an efficient approximation to the softmax function that speeds up the empirical calculation of the softmax on GPUs. They leverage the unbalanced distribution of words and specific empirical timings of matrix multiplies on GPUs to devise an algorithm that selects an optimal placement of the vocabulary into clusters. They show empirical results that show speedups over alternative methods, while not losing much accuracy compared to the full softmax. THOUGHTS: Since the goal of this work is to speed up training, I*m curious why you compare only to the flat 2-level HSM (O(sqrt(V)) speedup at best), and not the deeper binary-tree HSM (O(lgV) speedup at best)? Overall, the paper is clear, easy to understand, and well written, bar a few notation issues as pointed out by other reviewers. It adds an interesting extra tool in the language modeling toolbox. The idea is based on several previous works that aim to optimize vocabulary clustering to improve the speed-accuracy tradeoff often experienced in practice with hierarchical methods. The interesting result here seems to be that this particular clustering objective improves speed (what it was designed for), while apparently not losing much i.t.o. accuracy (what it wasn*t designed for). Although the authors do not speculate reasons for the latter part at all, I suspect it is largely related to the fact that the flat region on the timing graph (Fig 1) means that the head group V_h can actually include a sizeable portion of the most frequent words in the vocabulary at constant cost. This reduces the approximation error (regions of no support in P_approx(next | previous) compared to P_real ), which in turn mitigates the hit in perplexity compared to the full softmax. However, since the method is intimately related to the speed-optimal method proposed by Zweig et al. (2013) (albeit without the explicit tailoring towards GPU), I feel that a direct comparison is warranted (I understand this is underway). If the performance and accuracy improvements still hold, I will update my rating to a 7.