GloVe Embeddings — Global Vectors for Word Representation

Machine Learning
Introduced by
Pennington, Socher & Manning
Year
2014
Type
Static word-embedding model

What does it do?

GloVe (Global Vectors for Word Representation) is a static word-embedding model introduced by Pennington, Socher and Manning (2014).

It learns one dense vector per word from word-word co-occurrence counts aggregated over an entire corpus, so words with similar co-occurrence patterns end up close together. The original paper reports strong results on word analogy and word-similarity evaluations.

The intuition behind the method

Words that appear in similar contexts tend to mean similar things. Instead of scanning text one small window at a time, GloVe first counts how often every pair of words co-occurs across the whole corpus, then fits vectors so that the relationships between those counts are captured as geometric relationships between word vectors. The payoff is that simple vector arithmetic mirrors meaning — the structure that lets analogies like 'king is to queen as man is to woman' fall out of the geometry.

History

GloVe was introduced by Pennington, Socher and Manning at EMNLP 2014. The authors framed it as a combination of two model families: global matrix factorisation, which uses corpus-wide statistics, and local context-window methods. Pretrained GloVe vectors have since been widely distributed and used as a static word-embedding resource.

When to use it

Choose GloVe when you need a fixed, reusable vector per word, for word similarity, analogy tests, or as static features, and when you have either a sizeable domain corpus to train on or pretrained vectors whose vocabulary covers your terms. It is a poor fit when the task depends on the sense of a word in context, such as distinguishing several meanings of one word, where contextual models are the better choice. It also requires text: without a corpus or pretrained vectors there is nothing to learn from. With a very small corpus the co-occurrence counts are sparse and noisy, so pretrained vectors are usually the safer starting point.

Limitations and considerations

  • Each word type has one vector, so 'bank' has the same representation in 'river bank' and 'bank account'; the senses are merged.
  • The vectors reflect the corpus they were trained on, so a model trained on one domain or register may transfer poorly to another.
  • Words that occur rarely have few co-occurrence counts, so their vectors are estimated poorly.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Combines corpus-wide co-occurrence counts with a log-bilinear fit, rather than relying only on local context windows, as the original paper describes.
  • Trains only on the nonzero entries of the co-occurrence matrix, so unobserved word pairs contribute nothing to the fit.
  • The original paper reports 75% performance on a recent word analogy task, and better performance than the comparison models on word-similarity and named entity recognition tasks.
  • Pretrained GloVe vectors can be used directly, so a user with little text can still obtain vectors without training.

Applications

  • Computing word similarity and nearest neighbours within a vocabulary.
  • Solving semantic analogy tasks through vector arithmetic.
  • Providing pretrained word features as input to downstream text-classification or clustering models.
  • Exploring semantic structure and relationships in a large text corpus.

How it works

How it works

1

The raw text is tokenised and a vocabulary is defined from it, which includes decisions about casing, punctuation and rare tokens. These choices determine which words receive vectors and which pairs are counted, so they shape the co-occurrence matrix directly. Inconsistent tokenisation can split one word into several entries and divide its counts among them.

2

For each pair of vocabulary words, the model counts how often they appear within a context window across the whole corpus, producing a sparse word-word matrix. Because the counts are accumulated over the full corpus rather than one window at a time, the matrix holds global statistics, and it is only the nonzero entries that are used in training.

3

Word vectors and context vectors, each with a bias term, are fitted by weighted least squares over the nonzero co-occurrence counts: for each observed pair, the dot product of the two vectors plus their biases is pushed toward the logarithm of the count. A non-decreasing weighting function caps the influence of very frequent pairs and down-weights very rare ones, so common function-word pairs do not dominate the fit. Unobserved pairs do not enter the objective. The result is dense static vectors of a chosen dimensionality.

4

The trained or pretrained vectors are then used for similarity queries, analogy arithmetic, or as fixed input features for downstream models. Vectors can be trained on a corpus or loaded from pretrained releases; in either case each word has a single lookup vector, independent of the sentence it appears in. When the vectors are loaded into the embedding layer of a downstream neural model, a common practice, shown in a Keras example, is to freeze that layer during training, so that large gradients from randomly initialised layers do not overwrite the pretrained values. Check vocabulary coverage before loading.

Common pitfalls

  • Inconsistent tokenisation or casing splits one word into several vocabulary entries, dividing its co-occurrence counts and weakening its vector.
  • Training on a small corpus produces sparse co-occurrence counts and unstable vectors; in that case a pretrained model is usually preferable.
  • Reading the nearest neighbours of a polysemous word as its senses: a single vector per word cannot separate those senses.
  • Applying vectors trained on another domain or language without checking vocabulary coverage. Out-of-vocabulary words have no vector at all, and in-vocabulary words may carry meanings from the source corpus.

Frequently asked questions

How is GloVe different from word2vec?

Both produce static word vectors, but GloVe trains on a global word-word co-occurrence matrix built from the whole corpus, while word2vec learns from local context windows scanned through the text. GloVe was designed to combine the global-statistics view of matrix factorisation with the context-window view.

Do I need to train GloVe myself?

Not necessarily. You can train on your own corpus, or load pretrained GloVe vectors directly. Pretrained vectors are the safer choice when your corpus is small, or when its vocabulary and domain differ strongly from the text the pretrained vectors were built on.

Why are the vectors called 'static'?

Each word receives a single fixed vector regardless of the sentence it appears in. This means GloVe cannot distinguish different senses of the same word from context, unlike contextual embedding models.

How much text do I need?

The amount needed depends on whether the words you care about co-occur often enough to be estimated reliably, rather than on total corpus size alone. With little text most co-occurrence counts are sparse and the vectors unstable, so pretrained vectors are usually the safer route.

Related methods

Sources

  1. Pennington, J., Socher, R. & Manning, C. D. (2014). GloVe: Global Vectors for Word Representation. EMNLP.

    Open DOI reference
  2. [Fran_ois_Chollet_with_J.J._Allaire]_Deep_Learnin(z-lib.org), p. ?