GloVe: Global Vectors for Word Representation
Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP))
Subscriber deck — free during early access
23 cards
1 Introduction
- What are the two main families of word vector methods, and the drawback of each, according to Pennington et al.?Global matrix factorization (e.g. LSA) uses corpus statistics efficiently but does poorly on word analogies, a sign of sub-optimal vector space structure. Local context window methods (e.g. skip-gram) do better on analogies but use the statistics poorly, training on separate windows instead of global co-occurrence counts.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §1, p. 1532
- What does GloVe aim to combine?The efficiency of global count-based methods with the meaningful linear substructure of window-based prediction methods: a global log-bilinear regression model trained only on the nonzero entries of a word–word co-occurrence matrix.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §1, p. 1532
2 Related Work
- What problem with raw term–term co-occurrence counts (e.g. HAL) did later methods address?The most frequent words dominate similarity: co-occurring with the or and affects similarity a lot while saying little about meaning. Fixes compress the counts, which span 8–9 orders of magnitude: entropy or correlation normalization (COALS), positive PMI, square roots (Hellinger PCA).
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §2, p. 1533
- What disadvantage of window-based methods like skip-gram does GloVe target?They don’t operate directly on co-occurrence statistics; scanning context windows across the whole corpus fails to take advantage of the vast repetition in the data.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §2, p. 1533
3 The GloVe Model
- Define \(X_{ij}\), \(X_i\) and \(P_{ij}\) in GloVe.\(X_{ij}\) is the number of times word \(j\) occurs in the context of word \(i\); \(X_i = \sum_k X_{ik}\); \(P_{ij} = P(j \mid i) = X_{ij} / X_i\), the probability that \(j\) appears in the context of \(i\).
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3, pp. 1533–1534
- Why does GloVe start from ratios of co-occurrence probabilities? Use ice and steam.The ratio \(P(k \mid \textit{ice}) / P(k \mid \textit{steam})\) is large for probe words related only to ice, small for those related only to steam, and near 1 for words related to both or neither. Ratios separate relevant from irrelevant words better than raw probabilities (data from a 6B-token corpus):
probe \(k\) \(P(k \mid \textit{ice})\) \(P(k \mid \textit{steam})\) ratio solid 1.9·10−4 2.2·10−5 8.9 gas 6.6·10−5 7.8·10−4 0.085 water 3.0·10−3 2.2·10−3 1.36 fashion 1.7·10−5 1.8·10−5 0.96 - Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3, pp. 1533–1534
- How is the GloVe model derived from probability ratios?Start with \(F(w_i, w_j, \tilde w_k) = P_{ik}/P_{jk}\). Use vector differences, \(F(w_i - w_j, \tilde w_k)\); take a dot product so \(F\) can’t mix dimensions, \(F((w_i - w_j)^\top \tilde w_k)\); require \(F\) to turn differences into ratios, so \(F = \exp\) and \(w_i^\top \tilde w_k = \log P_{ik} = \log X_{ik} - \log X_i\).
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3, pp. 1533–1534
- How does GloVe restore the symmetry between words and context words?The term \(\log X_i\) is independent of \(k\), so it becomes a bias \(b_i\); adding a context bias \(\tilde b_k\) gives the symmetric \(w_i^\top \tilde w_k + b_i + \tilde b_k = \log X_{ik}\).
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3, pp. 1533–1534
- Give the GloVe cost function.A weighted least squares regression over the vocabulary: \(J = \sum_{i,j=1}^{V} f(X_{ij}) (w_i^\top \tilde w_j + b_i + \tilde b_j - \log X_{ij})^2\). Since \(f(0) = 0\), only nonzero co-occurrences contribute.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3, pp. 1533–1534
- Why does GloVe need a weighting function, and what properties should it have?Unweighted log-count factorization treats all co-occurrences equally, though rare ones are noisy and zeros (75–95% of \(X\)) make \(\log\) diverge. \(f\) should satisfy \(f(0) = 0\) (vanishing fast enough), be non-decreasing so rare pairs aren’t overweighted, and stay relatively small for large \(x\) so frequent pairs aren’t overweighted.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3, pp. 1533–1534
- What weighting function does GloVe use?\(f(x) = (x / x_{\max})^\alpha\) if \(x < x_{\max}\), else 1, with \(x_{\max} = 100\) and \(\alpha = 3/4\) (slightly better than \(\alpha = 1\)), echoing the 3/4 power in word2vec’s noise distribution.
f caps the weight of frequent pairs and shrinks the weight of rare ones - Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3, pp. 1533–1534
3.1 Relationship to Other Models
- How is skip-gram’s implicit global objective related to GloVe?Grouping identical \((i, j)\) terms, skip-gram’s objective is \(J = -\sum_i X_i H(P_i, Q_i)\), a weighted sum of cross-entropies between corpus distributions \(P_i\) and model softmax \(Q_i\). Replacing cross-entropy with least squares on unnormalized log values and generalizing the weight \(X_i\) to \(f(X_{ij})\) gives GloVe’s cost.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3.1, pp. 1535–1536
- Why did Pennington et al. prefer least squares to cross-entropy for word vectors?Cross-entropy gives too much weight to unlikely events in long-tailed distributions, and it needs a normalized model \(Q\), which requires an expensive sum over the vocabulary. Least squares on log counts drops normalization, and logs tame the very large values of \(X_{ij}\).
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3.1, pp. 1535–1536
3.2 Complexity of the model
- What is the computational complexity of training GloVe?Proportional to the number of nonzero entries of \(X\), at most \(O(|V|^2)\). Assuming co-occurrence counts follow a power law in pair frequency rank with \(\alpha = 1.25\) (as observed), the number of nonzeros is \(O(|C|^{0.8})\), better than window-based methods, which scale as \(O(|C|)\) in corpus size.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §3.2, pp. 1536–1537
4.1 Evaluation methods
- How were GloVe vectors evaluated?On the word analogy task (19,544 semantic and syntactic questions answered by cosine nearest neighbour to \(w_b - w_a + w_c\)), on five word similarity data sets (Spearman correlation with human judgments), and as extra features in a CRF for CoNLL-2003 NER.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.1, pp. 1537–1538
4.2 Corpora and training details
- How was GloVe trained?On corpora of 1B to 42B tokens with a 400,000-word vocabulary, a 10-word context window on each side with pairs \(d\) words apart counted as \(1/d\), AdaGrad on randomly sampled nonzero entries of \(X\), 50–100 iterations. The final vectors are \(W + \tilde W\), the sum of word and context vectors, which gave a small boost.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.2, pp. 1538–1539
- Why does GloVe use \(W + \tilde W\) as the word vectors?With a symmetric \(X\), the two sets are equivalent up to random initialization; summing them, like combining several trained networks, reduces noise and overfitting and gave a small improvement, mostly on semantic analogies.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.2, pp. 1538–1539
4.3 Results
- How did GloVe do on word analogies?75.0% overall with 300-dimensional vectors on 42B tokens; on 6B tokens 71.7% vs 69.1% for skip-gram and 65.7% for CBOW trained by the authors with word2vec. It often beat other models with smaller vectors and corpora; SVD baselines didn’t scale to the larger corpus.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.3, pp. 1539–1540
- How did GloVe vectors do on word similarity and NER?Best on the similarity sets, beating the word2vec CBOW vectors trained on 100B words with less than half the data. As CRF features for NER, best on all metrics except the CoNLL test set, where HPCA was slightly better.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.3, pp. 1539–1540
4.5 Model Analysis: Vector Length and Context Size
- How do vector size and context window affect GloVe’s analogy accuracy?Returns diminish above about 200 dimensions. Small and asymmetric (left-only) windows help syntactic analogies, since syntax depends on immediate context and word order; larger windows capture more semantic, non-local information.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.5, p. 1540
4.6 Model Analysis: Corpus Size
- How did corpus size affect GloVe’s analogy accuracy?Syntactic accuracy rose monotonically with corpus size. Semantic accuracy was higher with the smaller Wikipedia corpora than with the larger Gigaword news corpus, probably because many semantic analogies are about cities and countries, which Wikipedia covers comprehensively.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.6, p. 1540
4.7 Model Analysis: Comparison with word2vec
- How did GloVe compare with word2vec at equal training time?With the same corpus, vocabulary, window size and training time (GloVe iterations vs word2vec negative samples), GloVe was consistently better, reaching better results faster. word2vec got worse with more than about 10 negative samples.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §4.7, pp. 1540–1541
5 Conclusion
- How did Pennington et al. position GloVe in the count-based vs prediction-based debate?The two families aren’t fundamentally different, since both probe the same co-occurrence statistics; count-based methods capture global statistics more efficiently. GloVe uses count data while capturing the linear substructures of log-bilinear prediction models like word2vec.
- Pennington et al., 2014, GloVe (Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)), §5, p. 1541
Source
- Jeffrey Pennington, Richard Socher and Christopher D. Manning. 2014. GloVe: Global Vectors for Word Representation. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 1532–1543. doi:10.3115/v1/D14-1162 https://aclanthology.org/D14-1162/