Neural Probabilistic Language Model written in C
We analyze three critical components of word embedding training: the model, the corpus, and the training parameters. We systematize existing neural-network-based word embedding algorithms and compare them using the same corpus. We evaluate each word embedding in three ways: analyzing its semantic properties, using it as a feature for supervised tasks and using it to initialize neural networks. We also provide several simple guidelines for training word embeddings. First, we discover that corpus domain is more important than corpus size. We recommend choosing a corpus in a suitable domain for the desired task, after that, using a larger corpus yields better results. Second, we find that faster models provide sufficient performance in most cases, and more complex models can be used if the training corpus is sufficiently large. Third, the early stopping metric for iterating should rely on the development set of the desired task rather than the validation loss of training embedding.READ FULL TEXT VIEW PDF
In this research, we manually create high-quality datasets in the digita...
In this paper, we propose three novel models to enhance word embedding b...
We introduce language-driven image generation, the task of generating an...
Depression is ranked as the largest contributor to global disability and...
A review of Word Embedding Models through a deconstructive approach reve...
This paper explores linear methods for combining several word embedding
In this paper, we present a distributional word embedding model trained ...
Neural Probabilistic Language Model written in C
and has attracted considerable attention from many researchers. In recent years, several models have been proposed, and they have yielded state-of-the-art results in many natural language processing (NLP) tasks. Although these studies always claim that their models are better than previous models based on various evaluation criteria, there are still few works that offer fair comparisons among existing word embedding algorithms. In other words, we still do not know how to design an effective word embedding algorithm for a specific task. Therefore, this paper focuses on this issue and presents a detailed analysis of several important features for training word embeddings, including the model construction, the training corpus and the parameter design. To the best of our knowledge, no such study has previously been performed.
|Model||Relation of||Representation of|
|Skip-gram ||predicts||one of|
To design an effective word embedding algorithm, we must first clarify the model construction. We observe that almost all methods for training word embeddings are based on the same distributional hypothesis: words that occur in similar contexts tend to have similar meanings . Given this hypothesis, different methods model the relationship between a word (the target word) and its context in the corpus in different ways, where and
are embedded into vectors. Generally, existing methods vary in two major aspects in model construction: (i) the relationship between the target word and its context and (ii) the representation of the context. Table1
shows a brief comparison of commonly used models. In terms of aspect (i), the first five models are identical. They use an object similar to the conditional probability, which predicts the target word based on its context . C&W  uses an object similar to the joint probability, where the , pairs in the corpus are trained to obtain higher scores. In terms of aspect (ii), the models use four different types of methods. They are listed in ascending order of complexity from top to bottom in Table 1. Skip-gram  use the simplest strategy, which is to choose one of the words from the window of the target word and utilize its embedding as the representation of the context. CBOW  uses the average embedding of the context words as the context representation. Both of these methods ignore the word order to accelerate the training process. However, Landauer estimates that 20% of the meaning of a text comes from the word order, whereas the remaining meaning comes from word choice. Therefore, these two models may lose some critical information. In contrast, the Order model (Section 2.1.5) uses the concatenation of the context words’ embeddings, which maintains the word order information. Furthermore, the LBL , NNLM  and C&W models add a hidden layer to the Order model. Thus, these models use the semantic compositionality  of the context words as the context representation. Based on the above analysis, we wish to know which model performs best? and what selection we should make in terms of the relationship between the target word and its context as well as the different types of context representation?
Moreover, the ability to train precise word embeddings is strongly related to the training corpus. Different training corpora of different sizes and different domains can considerably influence the final results. Thus, we additionally wish to know how the corpus size and corpus domain affect the performance of a word embedding?
Finally, training precise word embedding strongly depends on certain parameters, such as the number of iterations and the dimensionality of the embedding. Therefore, we attempt to analyze the choice of these parameters. In particular, we wish to know how many iterations should be applied to obtain a sufficient word embedding while avoiding overfitting? and what dimensionality we should choose to obtain a sufficiently good embedding?
To answer these questions objectively, we evaluate various word embedding models on eight total tasks of three major types. We argue that all current applications of word embeddings are covered by these three types. The first type concerns calculating the word embedding’s semantic properties. We use the standard WordSim353 dataset  and the classic TOEFL set 
to check whether the distances of the embeddings in a vector space are consistent with human intuition. The second type concerns employing word embeddings as features for existing NLP tasks. Specifically, we use text classification and named entity recognition as the tasks for evaluation. The third type concerns employing word embedding to initialize neural network models. Specifically, we employ a sentiment classification task based on a convolutional neural network and a part-of-speech tagging task using the neural network proposed by Collobert et al.. Through different tasks with different usage types of word embeddings, we attempt to determine which type of model design is more suitable for each particular task (the first question). Moreover, we vary the corpus size and domains to attempt to answer the second question.
This paper has two main contributions: First, we systematize existing neural word embedding algorithms from the perspective of the relationship between the target word and its context, and the representation of the context (Section 2)111Training and evaluation code are publicly available at: https://github.com/licstar/compare. Second, we comprehensively evaluate the models on multiple tasks (Section 3), and attempt to give some guidelines for generating a good word embedding:
For model construction, more complex models require a larger training corpus to outperform simpler models. Faster (simpler) models are sufficient in most cases. In semantic tasks, the models that predict the target word (the first five models in Table 1) demonstrate higher performance than the model that scores the combination of the target word and its context (the C&W model). (Section 4.2)
When choosing a corpus in a suitable domain, using larger corpus is better. Training on a large corpus generally improves the quality of word embeddings, and training on an in-domain corpus can significantly improve the quality of word embeddings for a specific task. More importantly, we discover that corpus domain is more important than corpus size. (Section 4.3)
The validation loss is not a good early stopping metric for training word embeddings; instead, the best approach is to check the performance of the development set for that task. If evaluating the task is time consuming, the performance for other tasks can be used as an alternative. (Section 4.4.1)
For the tasks that analyzing the semantic properties of a word embedding, larger dimensions can provide a better performance. For NLP tasks that utilize an embedding as a feature or for initialization, a dimensionality of 50 is sufficient. (Section 4.4.2)
In this section, we describe and analyze the word embedding models to be compared in the experiments. We denote the embedding of word by .
Bengio et al.  first proposed a Neural Network Language Model (NNLM) that simultaneously learns a word embedding and a language model. A language model utilizes several previous words to predict the distribution of the next word. For each sample in the corpus, we maximize the log-likelihood of the probability of the last word given the previous words. For example, for a sequence in a corpus, we need to maximize the log-likelihood of
where we refer to the word we need to predict () as the target word. This model uses a concatenation of the previous words’ embeddings as the input:
The model structure is a feed-forward neural network with one hidden layer:
where is a transformation matrix, and
are bias vectors. The final step is to apply
to a softmax layer to obtain the probability of the target word.
The Log-Bilinear Language Model (LBL) proposed by Mnih and Hinton 
is similar to the NNLM. The LBL model uses a log-bilinear energy function that is almost equal to that of the NNLM and removes the non-linear activation function. Mnih and Hinton  accelerated this model by using the hierarchical softmax  to exponentially reduce the computational complexity; the resulting method is named the HLBL. Mnih and Kavukcuoglu 
further accelerated the method by developing the ivLBL model, which is very similar to the Skip-gram model. This model uses noise-contrastive estimation (NCE) to estimate the conditional probability of the target word.
Collobert and Weston (C&W)  proposed a model that trains only the word embedding. The C&W model does not predict the target word; therefore, it combines the target word and its context and then scores them. The target word in this model is the central word in a sequence. The input is the concatenation of the target word’s embedding and the context words’ embeddings, i.e., the concatenation of the sequence . The scoring function is a one-hidden-layer neural network. The training target is to maximize the score of a corpus sequence while minimizing the score of a noise sequence pairwisely, or formally, to minimize
In the noise sequence, the target word is replaced with a random word from the vocabulary.
The CBOW and Skip-gram models 
attempt to minimize computational complexity. The CBOW model uses the average embedding of the context words as the context representation. The Skip-gram model uses one of the context words as the representation of the context. Both models neglect word order information. (In fact, the weighting strategy for context words maintains a small amount of word order information.) Only logistic regression is applied to the context representation to predict the target word. Mikolov et al. further improved these models by introducing negative sampling as a simplification of the softmax approach based on the concepts applied in the two previously discussed models (ivLBL and C&W). Negative sampling yields an improvement compared with the hierarchical softmax or NCE.
The CBOW and Skip-gram approaches simplify the NNLM and LBL models by removing the word order information and the hidden layer. To analyze the use of word order information, we introduce a virtual model “Order”, whose complexity is between those of the CBOW and LBL models. This model maintains word order while removing the hidden layer. In contrast to the CBOW model, this model uses the concatenation of the context words as input. In contrast to the LBL model, our model uses logistic regression instead of the log-bilinear structure.
In addition to the neural network approaches, another line of research regarding word embedding is based on the word-context matrix [35, 14], in which each row corresponds to a word and each column corresponds to a context. The element in the matrix is relevant to the co-occurrence times of the corresponding word and context. These models are called count-based models . The latest research on such matrix approaches is the Global Vectors model (GloVe) , in which only the reconstruction errors of the non-zero values are minimized.
Existing neural word embedding models design the relation between the target word and the context in two different ways. Most models use the context to predict the target word. In NNLM, as shown in Figure 1, the hidden layer is the representation of the context. The dimension of the transformation matrix is , in which is the size of the vocabulary, is the dimension of the hidden layer. Each column in matrix can be regarded as an supplementary embedding of the corresponding word. We denote the supplementary embedding for word as . So, in these models, each word in vocabulary has two embeddings, when is in context, and when is the target word. The energy function for word is . Contrast to the language model based approaches, C&W model put the target word in the input layer and only maintain one embedding for each word. The energy function for word is , in which and are transformation matrices, is the representation of the context. Therefore, the two types of models are considerably different.
The models that predict the target word use different strategies to represent the context. Table 2
shows the formalized representation for each model. The Skip-gram model choose one of the words in context and utilize its embedding as the representation. CBOW use average embedding of the context words, which contains the entire information of the context words. Order use the concatenation of the context words’ embedding, which maintains the word order information. LBL and NNLM further add a hidden layer, which contains the compositionality of context words. NNLM has a non-linear transformation in addition to the LBL model, which makes the model more expressive.
|Model||representation of the context|
We evaluate the various word embedding models in eight tasks grouped into three major types. We argue that all current applications of word embeddings are covered by these three types.
Word embedding models are designed based on the distributional hypothesis; therefore, words with similar meanings tend to have similar word embeddings. Baroni et al.  have argued that word embeddings are characterized by various semantic properties. We include several classic tasks in our evaluation.
ws The WordSim353 set  contains 353 word pairs. It was constructed by asking human subjects to rate the degree of semantic similarity or relatedness between two words on a numerical scale. The performance is measured by the Pearson correlation of the two word embeddings’ cosine distance and the average score given by the participants.
tfl The TOEFL set  contains 80 multiple-choice synonym questions, each with 4 candidates. For example, the question word levied has choices: imposed (correct), believed, requested and correlated. We choose the nearest neighbor of the question word from the candidates based on the cosine distance and use the accuracy to measure the performance.
sem & syn The analogy task  has approximately 9K semantic and 10.5K syntactic analogy questions. The question are similar to “man is to (woman) as king is to queen” or “predict is to (predicting) as dance is to dancing”. Following the previous work, we use the nearest neighbor of in the vocabulary as the answer. Additionally, the accuracy is used to measure the performance. This dataset is relatively large compared to the previous two sets; therefore, the results using this dataset are more stable than those using the previous two datasets.
Word embedding models capture useful information from unlabeled corpora. Many existing works have directly used word embeddings as features to improve the performance of certain tasks. We use two tasks; the first task is a text classification task in which the word embedding is the only feature. The second task is a named entity recognition task in which the word embedding is used as an additional feature in a near state-of-the-art system.
avg This task uses the weighted average of the word embeddings as the representation of the text and subsequently applies a logistic regression to perform text classification. The weight for each word is its term frequency. We use the IMDB dataset . This dataset contains three parts. The training and test set are used to train and test the text classification model. The unlabeled set is used to train the word embeddings.
ner Named entity recognition (NER) is typically treated as a sequence labeling problem. In this task, we utilize word embeddings as the additional feature of the near state-of-the-art NER system . The experimental settings and code follow Turian et al. . The performance is evaluated with the F1 score on the test set of the CoNLL03 shared task dataset.
Erhan et al.  have demonstrated that a better initialization can cause a neural network model to converge to a better local optimum. In recent neural network approaches to NLP tasks, word embeddings have been used to initialize the first layer. In contrast to using word embeddings as features, using them for initialization results in the word embeddings being modified during the training of the neural network model.
cnn We use Convolutional neural networks (CNN) according to Kim  to perform sentence-level sentiment classification on the Stanford Sentiment Treebank dataset . This dataset is relatively small; the initialization of other parameters in the CNN is sensitive to the result. We repeat our experiment five times with the same word embedding and different random initialized neural network parameters. For each experiment, we use the accuracy of the test set when the development set achieved the best performance. We report the average accuracy of the five experiments.
pos The part-of-speech (POS) tagging task is a sequence labeling problem. We use the neural network proposed by Collobert et al.  to perform POS tagging on Wall Street Journal data . The performance is measured by the accuracy on the test set when the development set achieved the best performance.
In this section, to answer the questions posed in the Section 1, we perform comprehensive comparison among the considered models trained on different corpora with various parameters using the eight tasks in Section 3. Table 3 shows the detailed experimental settings.
|Model||GloVe, Skip-gram, CBOW, Order, LBL, NNLM, C&W|
|Corpus||Wiki: 100M, 1.6B; NYT: 100M, 1.2B; W&N: 10M, 100M, 1B, 2.8B; IMDB: 13M;|
|Para.||dimensionality: 10, 20, 50, 100, 200 fixed window size: 5|
A summary of the settings we used to investigate the training of word embeddings, including the chosen models, corpora, and hyperparameters.
In order to compare the models across the eight tasks in Section 3
, we find it lack of a unified evaluation metric because of the following two reasons:
First, the performance metrics for the different tasks lie in different ranges. For example, the performances for the avg task are always in the range of 70% to 80%, whereas the performances for the pos task are typically greater than 96% (refer to Table 4).
Second, the variances of the performances for the tasks are at different scales. For example, in thews task, the best model demonstrates a performance of 63.89%, whereas the worst performance is merely 46.17%. By contrast, in the avg task, the variance among models is relatively small; the best performance is 74.94%, and even the worst model achieves a performance of 73.26%.
For the two reasons mentioned above, we may encounter some difficulty in comparing the word embeddings across tasks; in other words, it is not easy to determine whether a given embedding is generally useful for these tasks. Moreover, if, for a given task, one embedding performs better than another by one percentage point, it may also be unclear whether this difference truly represents a significant improvement or whether it can merely be attributed to the randomness inherent to the training task models.
To address these problems, we propose a new indicator, the Performance Gain Ratio (), in place of the original evaluation metrics (accuracy, F1, etc.). The of embedding with respect to embedding is defined as
where is the performance of embedding for a given task and is the performance achieved by a random embedding. Here, a random embedding is a word embedding of the same dimensionality as embeddingto . The numerator and denominator in Equation (6) are the Performance Gains of embeddings and , respectively. The Performance Gain of a word embedding refers to the increment in performance achieved by embedding compared with the performance achieved by a random embedding. It is necessary to subtract the performance of a random embedding, because for the tfl task, a random guess from among the four choices is expected to have 25% accuracy, whereas for the tasks in which the embedding is used as a feature or for initialization, the model can achieve non-zero performance even without the aid of a word embedding. Therefore, the performance increment of a given word embedding compared with a random embedding reflects the real performance gain offered by that embedding.
Embedding is chosen to be the best embedding for a given setting; thus, we call this measure simply the of embedding . With this definition, the is a number smaller than . If , then the embedding achieved the best result among all embeddings for the same setting. If , then the embedding may contain no more useful information than a random embedding. If , then the embedding is detrimental to the task.
In the way, we argue that the Performance Gain Ratio normalizes the performances on all tasks to the same scale, thereby simplifying the analysis across multiple tasks. In the following experiments, we will use the when we need to compare embeddings across tasks.
In this section, we investigate how the different models perform in the eight evaluation tasks. In particular, we will compare the different types of context representations and the different relations between the target word and its context.
To fairly compare the different models, we use the same implementation for all models. Our GloVe implementation is based on the GloVe toolkit222http://nlp.stanford.edu/projects/glove/. The CBOW and Skip-gram implementations are based on the word2vec toolkit333https://code.google.com/p/word2vec/. The other models are modified from the CBOW implementation in word2vec. The Order model uses the concatenation of the context words instead of the average. The LBL model adds one linear hidden layer to the Order model. The NNLM adds the activation function to the LBL model. The C&W model moves the target word to the input of the neural network, leaving only one node in the softmax layer. For all models, we use the center word in the window as the target word. For the neural-network-based models (all models except GloVe), we use subsampling with and negative sampling with 5 negative samples . We also make two modifications. First, the GloVe toolkit and word2vec use different weighting strategies for context words. We remove these weightings for both models. Levy et al.  demonstrated that these weightings have little influence to the task performances. Second, the original implementation of word2vec
uses stochastic gradient descent with a decaying learning rate as the optimization algorithm. We modified this implementation using AdaGrad to mirror the implementation of GloVe. The learning rate is set to 0.1, which causes the new optimization method to perform similarly to its performance using the original decaying learning rate.
For each model, we iterate until the model converges to or overfits all of the tasks. Table 4 shows the best performance for each model trained on the W&N corpus (a collection of Wikipedia and New York Times articles). Overall, the best results are obtained using various models, from GloVe to LBL. Compared with random embedding, all investigated word embeddings demonstrate better performance on the tasks regardless of the model used.
To investigate the influence of the relationship between the target word and its context, we should compare the C&W model, which scores the combination of the target word and its context, with the other models, which predict the target word. The C&W model exhibits lower performance compared with the other models in the semantic property tasks (syn, sem, ws, and tfl). Particularly in the analogy tasks (syn and sem), the results show that the C&W model almost entirely lacks the feature of linear semantic subtraction. To investigate the difference between the C&W model and the models that predict the target word, we show the nearest neighbors of selected words in Table 5.
From these cases, we find that the nearest neighbors of “Monday” trained by the CBOW model are the other days of the week. In contrast, when trained by the C&W model, the nearest neighbors are times of day. The nearest neighbors of “commonly” also reveal a similar result: the CBOW model finds words that can replace the word “commonly”, whereas the C&W model will find words that are used together with “commonly”. Most of the nearest neighbors of “reddish” in both models are colors. Except for the word “pendulous” in C&W model, which can be used together with “reddish” to describe flowers.
Previous works have shown that models that predict the target word capture the paradigmatic relations between words [28, 30, 15]. In short words, a target word links various groups of contexts that predict it, making them similar among themselves. However, the C&W model does not explicitly model these relations; thus, the relations are less paradigmatic compared with CBOW model. The results (Table 7) in original C&W paper  seems that the neighbors by C&W model are paradigmatic relations. However, their embedding was generated by C&W model and then fine tuned for four supervised tasks (POS tagging, NER, etc.). The supervised targets can also bring paradigmatic relations to word embeddings just like the target words in CBOW model. We argue that the difference arises because the C&W model places the target word in the input layer, and this structure may not capture paradigmatic relations as strongly compared with the models that predict the target word.
To investigate the influence of the representation of the context, we further compare embeddings trained on corpora of different scales. Table 6 reports the number of tasks for which each model achieves 95% (for convenience, when this condition is satisfied, we say that the model “wins”). A model that wins a task when trained on a 10M corpus should thus be compared with the best embedding trained on the 10M corpus. We only focus on the listed five models because the only difference between these models are their representations of the context. According to the analysis in Section 1, we can view the different representations from the perspective of model complicity. Thus the experimental results are easy to explain. We note two observations based on Table 6.
First, a simpler model can achieve better results on a small training corpus. The simplest model, Skip-gram, is the best choice when using a 10M- or 100M-token corpus. When using a larger corpus, more complex models, such as the Order model, win more often. For corpora larger than those we tested, the more complex models LBL and NNLM may be the best choices.
Second, for tasks in which the word embedding is used as a feature or for the initialization of neural networks, the choice of model does not significantly affect the results. In addition, based on the results given in Table 4, the margins between the simple and complex models are relatively small. Therefore, simpler models are typically sufficient for real tasks.
We can now answer the first questions of which model performs best? and what selection we should make in terms of the relationship between the target word and its context words as well as the different types of context representation? In the case of a smaller corpus, a simpler model, such as Skip-gram, can achieve better results, whereas for a larger corpus, more complex models, such as CBOW and Order, are typically superior. Nevertheless, for real tasks, simpler models (Skip-gram, CBOW and Order) are typically adequate. In semantic tasks, the models that predict the target word demonstrate higher performance than does the C&W model, which places the target word and the context together in the input layer.
In this section, we investigate how the corpus size and corpus domain influence the performance of the word embedding. We use two large-scale corpora and one small corpus with different domains in our experiments. These corpora are the Wikipedia (Wiki) dump444https://dumps.wikimedia.org/enwiki/, the New York Times (NYT) corpus555https://catalog.ldc.upenn.edu/LDC2008T19 and the IMDB corpus. We combine the Wiki and NYT corpora to obtain the W&N corpus. The vocabulary is set as the most frequent 200K words in both the Wiki and NYT corpora (each word should occur at least 23 times in both corpora). For each corpus, the words not in the vocabulary are ignored. We shuffle the corpus at the document level to decrease the bias caused by certain online learning models. Small corpora are sampled uniformly from the larger corpus at the document level; thus, a 10M-token corpus is a subset of the corresponding 100M-token corpus.
We choose a representative model CBOW to analyze the influence of the corpus because of the space limitation. The other models yield similar results. Table 7 shows the values for the embeddings trained on various corpora compared with the best results across all corpora. The best for each task is 100%.
From the results in Table 7, we can conclude that using a larger corpus can yield a better embedding, when the corpora are in the same domain. We compare the full-sized NYT corpus with its 100M subset, the Wiki corpus with its subset, and the W&N corpus with its three subsets. In almost all cases, the larger corpus is superior to the smaller corpus. The observed exceptions may be attributable to instability of the evaluation metrics.
Specially, in the syn task (analogy task with syntax test cases, such as “year:years law:__”), the corpus size is the main driver of performance. The 100M-token subsets of the NYT, Wiki and W&N corpora achieve similar results as does the 10M subset of the W&N corpus and the 13M IMDB corpus. Clearly, different corpora use English in a similar manner, thereby producing similar syntax information.
In most of the tasks, the influence of the corpus domain is dominant. In different tasks, it impacts performance in the different ways:
In the tasks involving the evaluation of semantic features, such as the analogy task with semantic test cases (sem) and the semantic similarity task (ws), the Wiki corpus is found to be superior to the NYT corpus. Even the 100M-token subset of Wiki corpus can achieve a better performance than the 1.2B-token NYT corpus. We believe that the Wikipedia corpus contains more comprehensive knowledge, which may benefit semantic tasks.
The small IMDB corpus benefits the avg and cnn tasks, but it performs very poorly in the ner and pos tasks. The IMDB corpus consists of movie reviews from the IMDB website, which is the same source as that used for the training and test sets of the avg and cnn tasks. In-domain corpus is helpful for the tasks. Especially in the avg task, the in-domain IMDB corpus achieves a almost twice than the second best one. On the other hand, these movie reviews are much more informal than the Wiki and NYT corpora, which is detrimental to the part-of-speech tagging (pos) task.
To intuitively illustrate how an in-domain corpus helps a given task, we present several selected words and their nearest neighbors in Table 8. The neighbors of “movie” in the IMDB corpus consist of words such as “this”, “it”, and “thing”, implying that the word “movie” can be treated as a stop word in the IMDB corpus. The neighbors of “Sci-Fi” in the IMDB corpus consist of other abbreviations for “science fiction”, whereas the neighbors in the W&N corpus are predominantly other genres. The word “season” in the IMDB corpus is predominantly associated with the episodes of a TV show, whereas it refers to the sports competition season in the W&N corpus. From these cases, we observe that an in-domain corpus improves performance because it allows more suitable word embeddings for the tasks to be obtained.
In previous sections, the experiment results demonstrated more in-domain training data would benefit to training a precise model. However, for a specific task, it may be impossible to obtain sufficient in-domain data. Increasing more training data may introduce more out-domain data and may contradict the demand of in-domain. In this case, should we keep the corpus pure or add the out-domain corpus? We further design an experiment to answer this question. In this experiment, we use the 13M-token IMDB corpus and a subset of W&N corpus with 13M tokens. The subsets of the both corpora are mixed to train word embedding. Table 9 shows the of the avg task for each embedding. For each column in the table, the elements are listed in ascending order of corpus size, while in descending order of the in-domain purity. The experiment results demonstrate that no matter in which scale the IMDB corpus is, adding the W&N corpus consistently decrease the performance. The pure IMDB corpus is better than the larger mixed corpus.
The answer to the question of how the corpus size and domain affect the word embedding? is now clear. The corpus domain is more important than the corpus size. Using an in-domain corpus significantly improves the performance for a given task, whereas using a corpus in an unsuitable domain may decrease performance. For specific tasks, the use of a pure in-domain corpus yields better performance than does the use of a mixed-domain corpus. For corpora in the same domain, a larger corpus will allow better performance to be achieved.
The word embedding models presented in Section 2 all iteratively optimize the objective function; thus, the performance of these word embeddings depends on the number of iterations. If the iteration number is small, the word embeddings will exhibit a lack of learning. In contrast, if the iteration number is large, the model will be prone to overfitting.
In machine learning, early stopping is a form of regularization used to tackle with this problem. The most widely used early stopping method is to stop the iterator when the loss on the validation set peaks. In word embedding training, the loss measures how well the model predicts the target word. However, real tasks typically do not consist of predicting target words. Therefore, the loss on the validation set is only a proxy for these real tasks, and in some cases, it may be inconsistent with the task performance. Therefore, it is worth investigating whether the traditional early stopping method is a good metric for stopping the training of word embeddings.
In this experiment, we use 95% of the corpus as the training set, and the remaining 5% is used as the validation set. We report the loss on the validation set in addition to the eight evaluation tasks. Figure 3 shows three examples of the training procedure. The embeddings are trained with the CBOW model on various subsets of the W&N corpus.
From these cases, we find that the loss on the validation set is inconsistent with the performance in the real tasks. On the 100M-token corpus, the loss on the validation set peaks at the 20th iteration, which means that the model overfits the training data after the 20th iteration. However, the performance on almost all tasks continues to increase with further iterations. By contrast, on the 1B-token corpus, the model never overfits the training set, but the performances of the ner and pos tasks decrease after several iterations.
Despite the inconsistency between the validation loss and the task performance, it is worth noting that most tasks always exhibit similar peaks. The results demonstrate that we can use a simple task to verify whether the word embedding has peaked on other tasks. We consider the various combinations of the eight tasks, the seven models, and the three subsets of the W&N corpus, thereby obtaining 168 tuples. Table 10 shows the number of cases in which the word embedding model will win (achieve 95% performance with respect to the peak performance on the task) when either the peak validation loss or some other task is used as the stopping criterion. If we use the strategy that stop at the peak of the loss on the validation set, the resulting trained model will win in 89 cases. If we use the strategy that stops at the peak of the tfl task (the simplest task in our experiments), it will win in 117 cases.
When training a word embedding for a specific task, using the development set for that task to determine when to stop iteration is the optimal choice because this approach will yield the results that are the most consistent with the task performance. However, in certain situations, testing the development set performance is time consuming. For example, the cnn and pos tasks require take dozens of minutes for a performance check, whereas the tfl task requires only a few seconds. Therefore, this strategy provides a good approximation of the performance peak and is useful when testing the task performance would be excessively time consuming.
It should also be noted that multiple iterations are necessary. The performance increases by a large margin when we iterate more than once, regardless of the task and the corpus. Thus, the early version of the word2vec toolkit, which only scans the corpus once, may lose some performance as a result.
For the question of how many iterations should be applied to obtain a sufficient word embedding while avoiding overfitting?, we argue that iterating the model until it peaks on some simple task will yield sufficient embeddings for most tasks. To train a more suitable word embeddings for specific tasks, we can use the development set performance for that task to decide when to stop iterating.
To investigate the influence of the dimensionality on word embedding training, we compare models of different dimensions in the eight evaluation tasks. Interestingly, the results show that the tasks that involve analyzing the embedding’s semantic properties all behave in a similar manner. Figure 4(a) shows the performance for the tfl task as an example. Moreover, the tasks in which the embedding is used as a feature or for initialization also behave in a similar manner. Figure 4(b) shows the performance for the pos task as an example.
Which dimensionality should we choose to obtain a good enough embedding? We find that for the semantic property tasks, larger dimensions will lead to better performance (except for the C&W model, as explained in Section 4.2). However, for the NLP tasks, a dimensionality of 50 is typically sufficient.
Regarding model comparison, we find that the most similar work to ours is Turian et al. . In their work, the HLBL and C&W models were compared for the NER and chunking tasks. They trained word embeddings on a relatively small corpus containing 63M tokens and concluded that the two embedding methods resulted in similar improvements to these tasks. Baroni et al.  compared count models (models based on a word-context co-occurrence matrix) and a predict model (the neural-network-based word embedding model; in their experiments, they used the CBOW model) on several tasks involving the evaluation of the semantic properties of words. They claimed that the predict model achieved significantly better performance than did the count model in almost all of the semantic tasks. However, Milajevs et al.  proposed that the co-occurrence matrix approaches should be more efficient than predict models for semantic compositional tasks. Furthermore, Levy and Goldberg  showed that the Skip-gram model with negative sampling implicitly factorizes a word-context PMI matrix, and their experimental results showed that the matrix approaches are competitive with the Skip-gram model for semantic similarity tasks. Pennington et al.  proposed the matrix-based model GloVe and claimed that this model outperformed the CBOW and Skip-gram models. This result is contrary to our findings. We believe that the difference can be predominantly attributed to the different iteration strategies. In their experiments, they used the CBOW and Skip-gram models with a single iteration, whereas 25 iterations were performed for the GloVe model. Our experiment shows that performing multiple iterations can improve performance by a large margin.
Several works have demonstrated the influence of corpus size and domain when comparing corpora. Most of them only discussed the corpus size. These works are not limited to word embedding; certain studies have also used cluster-based word representations. Mikolov et al.  observed that larger training corpora can lead to better performance of the CBOW model on analogy tasks (syn and sem). Pennington et al.  found that a larger corpus size is beneficial only for the syn task and not the sem task when training using the GloVe model. Stenetorp et al.  found that training cluster-based word representations on in-domain corpora can improve performance in a biomedical NER task compared with training on newswire-domain corpora.
We fairly compared various word embedding models on various tasks and analyzed the critical components of word embedding training: the model, the corpus, and the training parameters. Although we did not find any specific settings for training a word embedding that can yield the best performance on all tasks (and indeed, such settings may not exist), we provided several guidelines for training word embeddings.
Why does unsupervised pre-training help deep learning?JMLR, 11:625–660, 2010.
Learning word vectors for sentiment analysis.In ACL, 2011.
Evaluating neural word representations in tensor-based compositional settings.In EMNLP, 2014.
Word representations: a simple and general method for semi-supervised learning.In ACL, 2010.