{'fraction_non_alphanumeric': 0.03799276547704076, 'fraction_numerical': 0.011220422551436536, 'mean_word_length': 4.426856714178545, 'pattern_counts': {'":': 1, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On SkipGram Word Embedding Models with Negative Sampling: Unified Framework and Impact of Noise Distributions

SkipGram word embedding models with negative sampling, or SGN in short, is an elegant family of word embedding models. In this paper, we formulate a framework for word embedding, referred to as Word-Context Classification (WCC), that generalizes SGN to a wide family of models. The framework, utilizing some"noise examples", is justified through a theoretical analysis. The impact of noise distribution on the learning of the WCC embedding models is studied experimentally, suggesting that the best noise distribution is in fact the data distribution, in terms of both the embedding performance and the speed of convergence during training. Along our way, we discover several novel embedding models that outperform the existing WCC models.


Introduction
Learning the representations of words, or word embeddings (Mikolov et al., 2013a), is an important task in natural language processing (NLP).The advances of word embedding models (Pennington, Socher, and Manning, 2014;Peters et al., 2018;Devlin et al., 2019;Yang et al., 2019;Brown et al., 2020) have enabled numerous successes in NLP applications. In the past years, when building a machine learning model for NLP, starting from a pretrained word embedding has become a nearly standard practice.
The SkipGram models are among the first word-embedding models and have been widely used since their introduction. In a SkipGram model, the corpus is first parsed into a collection of (word, context) pairs, where the "context" is also a word living in a neighbourhood surrounding the "word" (often referred to as the "center word"). Then a predictor of the context from the center word is learned. The predictor is parameterized by the word embeddings, and learning the predictor gives the word embeddings. Learning a SkipGram model may incur significant training complexity when the word vocabulary is large (since the predictor is a V -class classifier with large V ). An elegant approach to by-pass this complexity is through "negative sampling". In this approach, a set of word-context pairs are drawn from a "noise" distribution, under which the context is independent of the center word. These "noise pairs", or "negative examples", together with the word-context pairs from the corpus, or the "positive examples", are then used to train a binary classifier that is parameterized by the word embeddings. In particular, the classifier is parameterized by the word embeddings and when the classifier is learned, one obtains the word embeddings. This "SkipGram with negative sampling" model is denoted by SGN in this paper for simplicity.
Despite its simplicity, SGN is shown to perform quite well in Mikolov et al. (2013b). Even though SGN now tends to be replaced by more sophisticated embedding models in NLP applications, to us, SGN is still a fundamental model: its elegance seems to imply a general principle for representation learning; its simplicity may allow a theoretical analysis. In contrast, in those more advanced and sophisticated models, e.g., BERT (Devlin et al., 2019), the design is primarily motivated by conceptual intuitions; theoretical analysis appears very difficult, at least with current analytic tools developed for deep learning.
But theoretical analysis of SGN remains thin to date. The main analytic result derived for SGN to date is that of Levy and Goldberg (2014). The result states that under a particular noise distribution, SGN can be interpreted as an implicit factorization of a point-wise mutual information matrix.
Many questions in fact are unanswered for SGN. Specifically, in this paper, we ask the following questions. Beyond that particular distribution, if one chooses a different noise distribution, is SGN still theoretically justified? Is there a general principle underlying SGN that allows us to build new embedding models? If so, how does the noise distribution impact the training of such models and their achievable performances? These questions are answered in this paper.
To that end, we formalize a unified framework, referred to as "word-context classification" or WCC, for SGN-like word embedding models. The framework, including SGN as a special case, allows the noise distribution to take arbitrary forms and hence results in broad family of SGN-like models. We also provide a theoretical analysis that justifies the WCC framework. Consequently, the matrix-factorization result of Levy and Goldberg (2014) can also be derived from this analysis as a special case.
In addition, the impact of noise distribution on learning word embeddings in WCC is also studied in this paper. For this purpose, we classify WCC models into the conventional SGN models and the conditional SGN models, according to the factorization form of the noise distribution. We argue theoretically that the conditional models are inherently advantageous, thereby hypothesizing that the best WCC model is in fact the conditional SGN model with noise distribution precisely equal to the data distribution, i.e., the word-context pair distribution in the corpus. It is unfortunate however that the conditional models are in fact discouraged due to their high training complexity. To tackle this, we propose a variant of the conditional SGN models, the adaptive conditional SGN (caSGN) models, where the noise distribution adapts itself gradually towards the data distribution. Such an adaptation achieved by modeling the noise distribution generatively and learning the generator in a way similar to GAN (Goodfellow et al., 2014). We show that the caSGN models may be constructed with various structures of the generator. In particular, a previously proposed model, ACE (Bose, Ling, and Cao, 2018), may be regarded as a special form of caSGN. For the sake of comparison, the adaptive version of the unconditional SGN model is also presented.
Extensive experiments are then conducted to further this study. A wide spectrum of WCC models (SGN, versions of caSGN, and ACE) are implemented and compared to investigate the impact of noise distribution. These learned embeddings are evaluated using three downstream tasks over twelve datasets. Our experimental results suggest that indeed the caSGN models outperform other models, validating the validity of the WCC framework and confirming the hypothesis that the best noise distribution in WCC is in fact the data distribution.

Related Work
There have been a number of recent efforts to improve negative sampling in the word embedding learning. Zhang and Zweigenbaum (2018) designed a fixed conditional negative sampler, but the complexity of sampling is proportional to the size of the vocabulary. Hence to reduce time complexity, the authors pre-computed the noise distribution off-line for each center word and restricted the vocabulary size as 10k in their experiments. Both Chen et al. (2018) and Guo et al. (2018) designed a dynamic sampler that selects negative words by ranking score. Specifically, they mended the negative sampling strategy from the optimization perspective. In addition, there are some other works regarding revising negative sampling (Sun et al., 2016;Soleimani and Matwin, 2018;Mu, Yang, and Zheng, 2019), but they focus on designing new objective functions and are not directly related to our paper.
GAN-based negative sampler has also been used in other lines of NLP research (Wang, Liu, and Zhao, 2017;Wang, Li, and Pan, 2018;Dai et al., 2019;Budhkar et al., 2019). For example, Wang, Li, and Pan (2018) employed GAN-based framework on knowledge representation learning and Budhkar et al. (2019) imposed GAN-based method to generate natural language.
It is worth noting that the well-known unsupervised learning framework, noise constrastive estimation or NCE (Gutmann and Hyvärinen, 2012), adopts a similar negative-sampling approach. Indeed, some previous work has suggested that negative sampling and NCE are very close to each other when applied to the same model (Melamud, Dagan, and Goldberger, 2017;Labeau and Allauzen, 2018;Ma and Collins, 2018). However, the connection between the two is rather loose here. In particular, SGN and more broadly WCC can not be justified using NCE in the sense that in NCE it is required that one can evaluate the noise distribution, whereas in WCC this is not required.

The Word Embedding Problem
Let X denote a vocabulary of words, and let Y denote a set of contexts. When considering the SkipGram models, context is often considered as a single word, which is the case Y is X . But to better distinguish words and contexts, we prefer using Y to denote the set of all contexts.
In this setting, a given training corpus may be parsed into a collection D + of word-context pairs (x, y) from X × Y. For example, as is standard (Mikolov et al., 2013b), we may use a running window of length 2L + 1 to slide over the corpus; for each window location, we collect 2L word-context pairs, where the word located at the center of the window is taken as x in each (x, y) pair, and each of the remaining 2L words in the window is taken as a context y, paired with x. This gives rise to the training data, or the positive sample D + . With respect to the context y, we sometimes call the word x the "center word".
As is conventional, the word-context pairs D + are assumed to contain i.i.d. instances of a random word-context pair (X, Y ) drawn from an unknown distribution P on X × Y. We will use P X to denote the marginal of P on X , and for each x ∈ X , use P Y|x to denote the conditional distribution of Y given X = x under P. Let N + denote the number of pairs in D + .
The objective of word embedding is to learn a vector representation for each word in X (and possibly also for each context in Y).
We now introduce the Word-Context Classification (WCC) framework, which provides a unified perspective to negative-sampling based SkipGram embedding models.

The WCC Framework
For each x ∈ X , we let Q Y|x be a distribution on Y, and we define a distribution Q on X × Y as the noise distribution. Given Q, we draw N − word-context pairs i.i.d. from Q to form a noise sample or negative sample D − . Now we define a binary classification problem on samples D + and D − with the objective of learning a binary classifier capable of distinguishing the word-context pairs drawn from P from those drawn from Q. The word embedding problem of interest will be nested inside the classifier-learning problem.
To that end, let binary variable U denote the class label associated with each word-context pair (X, Y ). Specifically, whenever we draw a pair (X, Y ) from P, we also create a label U = 1, and likewise, whenever we draw a pair (X, Y ) from Q, we also create a label U = 0. That is, all pairs in D + are associated with label U = 1, and all pairs in D − associated with label U = 0. Then the classification problem is equivalent to learning the conditional distribution p U |XY (·|x, y) from D + and D − .
Let σ(·) denote the logistic function and let the classifier p U |XY (·|x, y) take the form for some function s on X × Y. Note that such form of classifiers is well known to be sufficiently expressive and entail no loss of generality (Jordan, 1995). We will refer to s(x, y) as the score of word-context pair (x, y). Any parameterized modelling for such classification problem then reduces to a selection of the score function s(·).
In order to learn a distributed representation of words, consider the following family of parameterization of the score function s.
Let X and Y be two vector spaces, serving as the embedding spaces for words and contexts respectively. Let f : X → X and g : Y → Y be two functions representing the embedding maps for words and contexts. Let s(x, y) take the form s(x, y) := score (f (x), g(y)) , for some function score(·) on X × Y. In the most general case, the functions f , g and score can all be made learnable.
In this paper, we however follow the classical choice in Mikolov et al. (2013b) for simplicity, where X and Y are taken as the same vector space, and the function score(·) is taken as standard inner product operation therein, namely not to be learned. It is easy to see that the standard cross-entropy loss for this classification problem is The standard Maximum Likelihood formulation of the learning problem is then minimizing the loss function over all possible embedding maps f and g, namely, solving for Above we have explicitly written the cross-entropy loss as a function of the embedding maps f and g.
At this end, we see that solving this binary "word-context classification" problem provides an embedding map f , thus giving a solution to the word embedding problem of interest. We refer to this framework as the Word-Context Classification or WCC framework.

Theoretical Properties of WCC
To justify the WCC framework, we derive a set of theoretical properties for the optimization problem in (4).
Let P and Q be the empirical word-context distributions observed in D + and D − respectively. That is, P(x, y) = where #(x, y) is the number of times the word-context pair (x, y) appears in D + , and Q(x, y) is defined similarly.
We will say that the distribution Q covers the distribution P if the support Supp P of P is a subset of the support Recall that the support of a distribution is a set of all points on which the probability is non-zero.
Note that the function s assigns a score to each word-context pair (x, y). Thus we can view s as an |X | × |Y| "score matrix". Additionally, the loss in (3) may also be treated as a function of matrix s.
Theorem 1. Suppose that Q covers P. Then the following holds.
1. The loss , as a function of s, is convex in s.
2. If f and g are sufficiently expressive, then there is a unique configuration s * of s that minimizes (s), and the global minimizer s * of (s) is given by Proof. The first part is straightforward by computing the second derivative: Thus, − log σ (s) is a convex function in s, and we can prove − log σ (−s) is also a convex function following the same way. Since the summation of the convex functions is still a convex function, the loss is convex in s. For the second part, we know that the size of D + is N + P(x, y) and the size of D − is N − Q(x, y). Hence the prior distribution of binary random variable U is: where H(p U ) is the entropy of p U and KL(p U ||p U |XY ) is the Kullback-Leibler divergence between p U and p U |XY . Given N + , N − , P(x, y) and Q(x, y), H(p U ) is a constant. In this case, Since KL(p U ||p U |XY ) reaches the minimum value 0 when p U = p U |XY , we let which indicates s * (x, y) = log P(x,y) Q(x,y) + log N + N − . We then know this is the unique solution due to the convexity.
Note that the second statement of the theorem does not imply that there is a unique (f * , g * ) that minimizes (f, g). In fact there is a continuum of (f * , g * )'s which all minimize (f, g) equally well. A consequence of Theorem 1 is the following result. Corollary 1. Let N + = n and N − = kn. Suppose that Q covers P, and that f and g are sufficiently expressive. Then it is possible to construct a distribution P on X × Y using f * , g * , k, and Q such that for every (x, y) ∈ X × Y, P(x, y) converges to P(x, y) in probability as n → ∞.
Proof. Suppose f * , g * , k, and Q are all known. Recall that s * (x, y) = log P(x,y) Q(x,y) −log k and s * (x, y) = f * (x), g * (y) . We then reconstruct P as According to the weak law of large numbers, P(x, y) converges to P(x, y) in probability as n → ∞ and Q(x, y) converges to Q(x, y) in probability as n → ∞. Thus, for every (x, y) ∈ X × Y, P(x, y) converges to P(x, y) in probability as n → ∞ We note that Corollary 1 justifies the WCC framework, since under the condition of the corollary, one can reconstruct the unknown data distribution P from the learned embedding maps f * and g * without referring to the samples D + and D − . That is, for sufficiently large sample sizes N + and N − , the learned embedding maps f * and g * results in virtually no loss of the information contained in the data distribution P.
There are other consequences of Theorem 1, which we postpone to discuss in a later section. For later use, we present another result.
Lemma 1. The derivative of the loss function with respect to s(x, y) is

Different Forms of Noise Distribution Q
From the formulation of WCC, it is apparent that the choice of the noise distribution Q has an effect on this classifier learning problem and possibly impact the quality and training of the word embeddings. We now discuss various options in selecting the noise distribution Q, resulting in different versions of SkipGram models. Such models will all be referred to SGN models, for the ease of reference.

SGN Model
Let Q factorize in the following form In such a model, the noise context does not depend on the noise center word. Thus we may also refer to such a model as an unconditional SGN model. The standard SGN model of Mikolov et al. (2013b), which we will refer to as "Vanilla SGN", can be regarded as unconditional SGN in which Q Y takes a particular form (see later).
The following result follows from Theorem 1.

Corollary 2.
In an unconditional SGN model, suppose that f and g are sufficiently expressive. Let N + = n and N − = kn. Then the global minimizer of loss function (3) is given by As a special case of Corollary 2, when Q Y = P Y , the term log P(x,y) P X (x) Q Y (y) is called "pointwise mutual information" (PMI) (Levy and Goldberg, 2014). In this case, the above corollary states that the WCC learning problem can be regarded as implicitly factorizing a "shifted PMI matrix", recovering the well-known result of Levy and Goldberg (2014) on SkipGram word embedding models.
It is natural to consider the following forms of Q Y in unconditional SGN.
where f y is the frequency at which the context word y has occurred in the corpus.
y . This is precisely the noise distribution used in vanilla SGN (Mikolov et al., 2013b).

Conditional SGN
In this case, we factorize Q as varies with x. Such form of Q includes all possible distributions Q whose marginals Q X on the center word are the same as P X . Specifically, if we take Q Y|x as P Y|x , then Q is P. Before we proceed, we make the following remark. Remark 1. In Theorem 1 and Corollary 1, the WCC framework is justified for any choice of empirical noise distribution Q that covers P. Consider some (x, y) ∈ Supp Q \ Supp P , namely, (x, y) is "covered" by Q but not by P. By Lemma 1, the gradient is That is, the gradient signal contains only one term, which is used to update the representation (f (x), g(y)) for the pair (x, y), which is outside the positive examples. Although the gradient signal updates the embedding f (x), but the training is towards making the classifier sensitive to negative examples (make it to have low loss), without contributing to differentiating the negative examples from the positive one (namely, without aiming at reducing the loss for positive examples). Such a direction of training, not necessarily "wrong", somewhat deviates from the training objective (i.e., reducing the loss for both positive and negative examples). In the case when the Supp Q of Q contains the support Supp P of P but is much larger, there are a significant fraction of such negative examples outside Supp P . This may result in slow training. Thus in the sense to efficiently learn word embeddings in the WCC framework, we have the following hypothesis: Hypothesis 1. The best Q is the one that barely covers P, namely, equal to P.
Remark 2. It is important to note that in order to achieve better performance on some NLP downstream tasks, Q should not be exactly P during the whole training phase. This is because target words in these tasks may not frequently appear in the training corpus, and if they are rarely trained, the learned embeddings will not able to give a good performance. It turns out that we usually apply the sub-sampling technique and try to improve the entropy of Q ( e.g., using "3/4-unigram" instead of "unigram" (Mikolov et al., 2013b) ) in practice.
Under this hypothesis, we wish to choose Q Y|x to be equal to, or at least to closely resemble, P Y|x . This choice however entails nearly prohibitively high computation complexity for optimization using mini-batched SGD. This is because for each word-context pair in a mini-batch, the context word needs to be sampled from its own distribution P Y|x , depending on the center word x. Such a sampling scheme is not parallelizable within the mini-batch, under current deep learning libraries.
In the next subsection, we will present a solution that can bypass this complexity.

Conditional Adaptive SGN (caSGN)
Now we consider a version of Q t Y|x : x ∈ X that varies with training iteration t. We consider training based on mini-batched SGD, where each batch is defined as a random collection of positive examples together with their corresponding negative examples (which are k times many). We take t as the index of a batch. Suppose training is such that the loss computed for a batch converges and that Q t Y|x converges to P Y|x for each x ∈ X . Let T be the total number of training iterations (largest batch number). The empirical distribution, say Q T , of the noise word-context pair seen during the entire training process is then Q T (x, y)= T t=1 Q t Y|x (y) P X (x)/T . Under the above stated assumptions, it is easy to see that Q T must converge to P with increasing T . Thus, when T is large enough, we can regard training as a version of mini-batched SGD with Q chosen as a distribution arbitrarily close to P, or a conditional SGN with Q Y|x arbitrarily close to P Y|x . This observation motivates us to design the "Conditional Adaptive SGN" (caSGN) model. The idea is to parameterize Q Y|x using a neural network and force learning with mini-batched SGD to make Q Y|x converge to P Y|x . Inspired by GAN (Goodfellow et al., 2014), we parametrize Q Y|x using a latent variable Z that takes value from a vector space Z, and model Y as being generated from (X, Z). Figure 1 (a-c) show three structures of such a generator. Each generator can be implemented as a probabilistic neural network G. Then one can formulate the loss function in a way similar to GAN, e.g. in caSGN3 (Figure 1(c)), The min-max optimization problem is defined as where G Z|X and G Y |XZ are parts of the network G. Following the same derivation as that in GAN, the distribution of (X, Y ) induced by G * is Q, and optimizing (9) using mini-batched SGD forces Q to converge to P. Note that caSGN1 and caSGN2 in Figure 1 are special cases of caSGN3, where additional factorization constraint is applied.
x z y (a) caSGN1 x z y In this model, we simplify the generator so that Y only depends on Z as shown in Figure 1(d). Since in every language the context always depends on the center word, using such a generator, Q tend not to converge to P by construction, except for very small training sample, to which model over-fits.

ACE
ACE (Bose, Ling, and Cao, 2018) can also be regarded as a WCC model with an adaptive noise distribution. In particular, it can be regarded as a special case of caSGN1 or caSGN2, where Y depends only on X.

Experiments
The main objective of our experiments is to investigate the effect of different forms of noise distribution Q in the WCC models on the training of embedding and the achieved performance thereby. The approach taking in this study is first training word embeddings using a given corpus and then evaluating the quality of the embeddings using a set of downstream benchmark datasets.

Corpus
We downloaded a Wikipedia dump 1 as our training corpus. After lower-casing the text and removing non-lexical items, it contains 1.1 billion tokens and the vocabulary contains 153, 378 most-frequent words.

Word Similarity
This task is to predict the similarity of a pair of words. A dataset for this task is a collection of records each containing a word pair and a human-assigned similarity score. When using this task to evaluate a word-embedding model, one computes the cosine similarity for the learned embeddings of the two words in each record. The Spearman's correlation coefficent, ρ, between the model-predicted similarities and human-assigned scores are then used to evaluate the model.  (Luong, Socher, and Manning, 2013), MT287 (Radinsky et al., 2011), MT771 (Halawi et al., 2012), MEN (Bruni et al., 2012), RG (Rubenstein and Goodenough, 1965), MC (Miller and Charles, 1991), and SimLex (Hill, Reichart, and Korhonen, 2015). Note that not all the words in these datasets are included in the vocabulary of the corpus. The number of word pairs in each dataset that are covered by each training corpus is shown in Table 1.

Word Analogy
In this task, each record in the dataset is a sequence of four words (w 1 , w 2 , w 3 , w 4 ) indicating "w 1 is to w 2 as w 3 is to w 4 ", and the objective of the task is to predict w 4 using the learned embedding f . Preciously, one computes the cosine similarity between (f (w 2 ) − f (w 1 ) + f (w 3 )) and the learned embedding of each candidate word in the vocabulary, and then select the word that has the minimum cosine similarity value as w 4 . The prediction accuracy is the percentage of questions whose w 4 is predicated correctly. Google's Analogy dataset consisting of a Semantic subset and a Syntactic subset (Mikolov et al., 2013a) is used in this task.

Named entity recognition (NER)
We select the NER task as a real NLP application to compare the WCC models. The CoNLL-2003 English benchmark dataset (Sang and Meulder, 2003) is used for this task, which consists of Reuters newswire articles that are tagged with four entity types (person, location, organization, and miscellaneous). The objective of this task is to identify these entities in the input text. With learned word embeddings as input, we trained a CNN-BiLSTM-CRF model described in Ma and Hovy (2016).

Implementation of Compared Models
In this section, we report more details about implementation including the model structure and some tricks used in experiments. 1 The data is downloaded in July 2019 SGN We implement the SkipGram model with the default architecture in Mikolov et al. (2013b). aSGN The generator of aSGN is a single multilayer perceptrons (MLP). The input to this generator is a 100 dimensional latent vector drawn from a standard Normal distribution. The generator contains a hidden layer with 512 dimension and an output softmax layer that defines the categorical distribution over all the candidate context words. There is a ReLU layer between the hidden layer and the output layer. caSGN1 For the first conditional version, for each center word x, we concatenate its embedding vector f (x) with a latent vector z drawn from the standard Normal distribution as the input to the generator. The remaining part uses the same structure of aSGN. caSGN2 Instead of drawing a latent vector independent of x as in caSGN1, we construct a Gaussian distribution whose mean µ x and variance σ x both depend on the center word vector f (x). Specifically, we use two Linear-ReLU-Linear structures for µ x and σ x respectively and they share the first 512-dimension linear layer. Then we sample a latent vector from the Gaussian distribution described by µ x and σ x . The output layer of this generator is again a Linear-softmax layer. caSGN3 The last version combines the features of caSGN1 and caSGN2. We pick a latent vector from a Gaussian distribution as in caSGN2, and then we concatenate the latent vector with the center word vector before it moves to the next layer as in caSGN1. The remainder of the generator consists of a linear hidden layer and a output layer. Again there is a non-linear layer ReLU between the hidden layer and the output layer. ACE We implement ACE according to Bose, Ling, and Cao (2018), except that the NCE (Gutmann and Hyvärinen, 2012) negative sampler in the model is removed, for the purpose of fair comparison.

Stochastic Node
In our adaptive SkipGram model, the generator as an adaptive sampler produces the noise context tokens to the discriminator. The output of the generator is a non-differentiable categorical variable so the gradient estimation trick is utilized. REINFORCE (Williams, 1992) and the Gumbel-Softmax trick (Jang, Gu, and Poole, 2017;Maddison, Mnih, and Teh, 2017) are two options. Although we conduct some simulations using Gumbel-Softmax but REINFORCE indeed produces slightly better results so the comparisons of our adaptive SkipGram are all based on the REINFORCE trick. We use the variance reduction technique for the REINFORCE estimator as described in Bose, Ling, and Cao (2018) but the result is barely distinguishable from the experiment without this technique, which indicates the high variance problem is not critical here. After we obtain the mean and variance from the center word, we construct a Gaussian distribution and sample a noise from this distribution. This sampling layer is also a non-differentiable stochastic node so we apply the reparameterization trick (Kingma and Welling, 2014;Rezende, Mohamed, and Wierstra, 2014) to this layer.

Entropy control
When the generator finds out a specific context word that receives a relatively high score from the discriminator for many center words, it tends to become 'lazy' and not explore other candidates. Thus, the entropy of the categorical distribution gave by the generator is getting smaller and smaller during training. In this case, the discriminator is unable to learn more about the true data structure and the binary classification task is not challenging any more. In order to guarantee the rich diversity of tokens produced by the generator, we apply a regularizer to give the generator a high penalty when the entropy of the categorical distribution is small. The regularizer proposed by Bose, Ling, and Cao (2018) uses the entropy of a prior uniform distribution as a threshold, and encourages the generator to have more candidates: where log(α) is the entropy of the uniform distribution and H(y|x)) is the entropy of the categorical distribution defined by the generator. Indeed, the entropy control trick is already used in the previous work. For example, the prior distribution Mikolov et al. (2013b) used is "3/4-unigram", and the entropy of this distribution is higher than the unigram distribution.

Experimental Results
We first show the performance of 100-dimension word embeddings learned by vanilla SGN, ACE and 4 our own adaptive SGN models on the downstream tasks. Then we discuss the impact of the different Q discussed before. Notice that the results presented here are not competitive to the current state of the art results which not only need a sufficiently larger corpus and embedding dimension but more complex structure of f 2 is also required.    Table 3: Accuracy on the Word Analogy task.

Model
Furthermore, the extensive experimental results in Appendix verify that these observations are robust across different corpus sizes and word dimensions. In particular, we provide the significance test results in Appendix based on 12 runs, and their corresponding violin plots are also given.
Among the adaptive samplers (caSGN1,2,3, aSGN and ACE), caSGN3 seems to be able to capture more information than others but we find caSGN2 has superior results in practice. Unfortunately, we don't have a formal justification to address this so we leave the comparison between these models for future work. In addition, we notice that ACE also performs well on some tasks, but this fact should not be taken negatively on our results. As stated earlier, ACE is essentially an adaptive conditional member of WCC. Its good performance further endorses some claims of our paper, namely WCC is a useful generalization and adaptive conditional schemes can be advantageous.

Further Discussions on the Impact of Q
To demonstrate Hypothesis 1, we show the estimated Jensen-Shannon divergence (JSD) between Q and P in Table 5. Concretely, the objective function of the generator in GAN is taken to estimate JSD (Goodfellow et al., 2014). For comparison in the same scaling level, JSD of different Q is computed using the same embeddings learned by caSGN2. Notice that we're not able to fairly compare JSD of different adaptive Q in the same way since generators in these models are jointly trained with word embeddings, using the same word embeddings will not enable different generators to produce valid samples. In addition, Figure 2 shows the performance varying curves on two datasets.   Table 5: Estimated JSD between Q and P.

Model
In Table 5, we find that "unigram Q" is closest to P in the JSD sense but it gives poor performance as shown in Figure 2. It's easy to see that "unigram" is "sharper" than "3/4-unigram", or in other words, "unigram" has smaller entropy, which indicates the classifier of ugSGN is trained by limited frequent words in corpus for the most of the time. It turns out that its learned embeddings 'over-fit' those frequent words but 'under-fit' others. This does not violate Hypothesis 1, as discussed in Remark 2, Q that close to P cannot perform well due to the mismatch of the downstream task and the training corpus. On top of that, Figure 2 shows that ufSGN performs poorly. Notably, ufSGN's Q is far from P as shown in Table 5 so the classification task is "not challenging" and the classifier does not need to learn much about the data. Notice that ufSGN's performance converges very slowly, and this phenomenon is consistent with Remark 1. Figure 2 also presents two caSGN2 models with different n critic 3 . We notice that caSGN2 with n critic =1 does not converge faster than n critic =5. Thus we can choose larger n cirtic to reduce the running time (see Appendix for more discussions about time complexity). At the beginning of training, caSGN2's performance is improved a little slowly than 3/4-ugSGN and ugSGN. This is not surprising since caSGN2's Q is not "competitive" at first. After getting closer to P (as indicated in Table 5), caSGN2 outperforms other models. These observations convey the message that best Q is P and GAN is a desired method to apply Hypothesis 1 to practice, because word pairs can be uniformly trained at the initialization and the generator will force the classifier to learn as much as possible about data when Q gradually moves to P.

Conclusion
In this paper, we introduce the WCC framework for word embedding that generalizes SGN to a much wider family. We provide a theoretical analysis that justifies the framework. The well-known matrix-factorization result of Levy and Goldberg (2014) can be recovered from this analysis. We experimentally study the impact of noise distribution in the framework. Our experiments confirm the hypothesis that the best noise distribution is in fact the data distribution. Along our way, novel word embedding models are developed and shown to outperform the existing models in the WCC family.

A Experiment Setup
In this section, we give more details regarding the experiment setup. In addition to the Wikipedia dump (wiki) used in main paper, the small corpus text8 Mahoney (2011) is also used, which contains 17M English words and is pre-processed by lower-casing the text and removing non-lexical items. Words appearing less than 5 times are removed, giving rise to a vocabulary of 71, 290 unique words. A benefit of adopting this small corpus is to enable repeated runs of training under different random seeds so as to arrive at reproducible results with good confidence.

A.1 Hyper-parameters
In our experiment, the window size of all the WCC models is 10 so each center token has 10 positive context tokens. We use the subsampling technique to randomly eliminate the words in the corpus following the same scheme in Mikolov et al. (2013b). For every WCC model, there are input word embeddings for the center words and output embeddings for the context words. We run all the models trained on text8 for 12 times, and report 3 -run results for models trained on the wiki due to the limitation of our computation resource. More details are in   Table 9: Accuracy on the word analogy task (text8).

B.1 Significance Tests of 100-dimension word embeddings
The results 100-dimension word embeddings and the statistical significance tests based on 12 runs are given in Table 8 and Table 9.
In Table 8, we see that each adaptive SGN model outperforms vanilla SGN on all the datasets. Based on the 12 running results, the violin plots are given in Figure 3. Basically, most differences in Table 8 are significant except for SIM on which no difference is significant (p-value > 0.05).
In Table 9, adaptive WCC models (especially conditional adaptive models) still outperform others. More precisely, there is no statistical significance difference on Semantic but the differences for total accuracy are significant except for caSGN3. the The violin plots are given in Figure 4.   Table 11: Accuracy of 50-dimension word embeddings on the word analogy task (text8).

B.2 Results of different word dimensions
We provide results of 50-dimension word embeddings in Table 10 and Table 11, and we also provide results of 200dimension word embeddings in Table 12 and   C Further discussions C.1 Limitation: time complexity Arguably, one of the reasons for using NCE (Gutmann and Hyvärinen, 2012) is the efficiency gain in terms of time complexity. As each adaptive SGN becomes complex due to the training of the generator, it would likely require growing amount of time. In fact, compared with vanilla SGN, the running time of adaptive SGN models has increased more than tenfold. However, word embeddings, or even other embeddings, are usually pre-trained for downstream tasks. Thus the computation is a one-off cost. Moreover, there are many specific tricks that can accelerate the training of GAN. In addition to the way mentioned in Section 4.6.2, one can see Bose, Ling, and Cao (2018) and Budhkar et al. (2019) for more suggestions.

C.2 WCC vs NCE
NLP researchers tend to regard SGN as an application of NCE to word embedding. We however assert that this understanding is incorrect. Agreeably both SGN and NCE uses noise samples to construct a binary classification problem, and it is possible to convert NCE to a conditional version so that resulting binary classification problem looks the same as that in SGN. However, NCE and SGN differ significantly.
NCE aims at learning a possibly unnormalized "density function" f on a space of examples, through a set of observed examples; the starting point of NCE is setting up the function f . NCE then draws noise examples to form a negative class and reformulates the learning problem as a binary classification problem. It is remarkable that the parametrization of f is independent of any noise distribution used in NCE.
SGN aims at learning the representation of the elements in a space (where each element is a word-context pair); the starting point of SGN is a binary classification formulation. That is, in SGN, there does not exist a parametrized density function independent of the choice of noise distribution. If one must equate SGN with a special case of NCE, then the effective density model in SGN would have to be parametrized by the noise distribution.
This difference between NCE and SGN also result in their differences in training: in NCE, one must be able to evaluate the noise distribution, but this is not required in SGN; in NCE, the partition function of the unnormalized density function f must also be estimated during training, but this is also not required in SGN. Thus although SGN is inspired by NCE, it is not NCE.
The distinction of the two extends to distinguishing WCC from NCE. Specifically WCC is a generalization of SGN to allowing more general forms of noise distribution. This generalization is "orthogonal" to the difference between NCE and SGN. Although the formalism of NCE allows any noise distribution, negative sampling with arbitrary noise distribution is established for the first time in this paper. When generalizing SGN to WCC, the PMI-MF result no longer holds. Another contribution of this paper is establishing the "correctness" of WCC in Corollary 1.

C.3 WCC vs ACE
ACE may be viewed as an adaptive conditional member of WCC, with a structure corresponding to Figure 1 (a) or (b) in Section 3.4 with variable Z deleted.

C.4 WCC vs BERT
Although the success of language models like BERT boils down to the complex structures (e.g., Transformer) rather than negative sampling (NS), these complex structure based models are already contained in the WCC framework. More precisely, the functions f ,g and s in Section 3.2 are only taken by the simplest choices , and they can be more complicated. For example, s can be a learnable neural network instead of an inner product. Specifically, if the model of f is taken as Transformer or LSTM, which is essential to compare to BERT or ELMo, WCC will convert to the pre-trained model from the pre-trained embedding. Since the analysis is structure-independent, the theoretical results still hold. In addition, the language model can be regarded as a special case of the Continuous Bag of Words (CBOW) model with modified definitions of "context" and "window", so it also has the NS version. Particularly, on the Masked LM task of BERT, one can replace the Softmax layer by NS scheme, and on the Next Sentence Prediction task, one can maximize the similarity of the sentence pairs and minimize the similarity of randomly sampled sentences. In these cases, our analysis will be helpful. We leave these studies to the researchers who have enough computation resources to run the pre-training process of BERT.

C.5 Performance gain of WCC over existing models
The main objective of this paper is to present a unifying principle for SGN-like models, not to develop a BERT-like "super model" for word embedding. Word embedding and more generally representation learning have witnessed great successes in recent years. However the fundamental principles underlying these models are poorly explored. For example, even the problem of "representation learning" is poorly defined: except relying some downstream tasks to evaluate a learned representation, very little has been developed pertaining to the metrics or principles for word-embedding alike representation learning; what makes a "good" representation remains elusive. In this respect, Corollary 1 of this paper and PMI-MF are among the only results, to the best of our knowledge.
Despite our theoretical focus, this paper does yield new models that outperform the existing models. Compared with 3/4-ugSGN, our models not only performs significantly better, they are also more "negative-sample efficient": our adaptive samplers draw one noise sample per data sample, whereas 3/4-ugSGN draws 5 noise samples per data sample. The fact that ACE also performs well should not be taken negatively on our results. As stated earlier, ACE is essentially an adaptive conditional member of WCC. Its good performance further endorses some claims of our paper, namely that WCC is a useful generalization and that adaptive conditional schemes can be advantageous. Nonetheless, the new models discovered in this work still significantly outperform ACE on some tasks.