Paper Breakdowns  /  GloVe
Paper 95~10 min read2014worked math + runnable code
Paper Breakdown

Global
vectors.

Meaning lives in company: you know a word by the words it keeps. Count how often every word appears beside every other across a whole corpus and you get a giant table of co-occurrences — the raw distributional fingerprint of a language. GloVe's move is to squeeze that table into short vectors so that a simple dot product reproduces the log of each count. The result is a geometry where "king" minus "man" plus "woman" lands near "queen." Not by prediction over a sliding window like word2vec, but by fitting the global statistics directly. Here's the weighted least-squares objective, the weighting function that keeps "the" from swamping everything, and why the log matters.

Video breakdown
The animated walkthrough is in production.
Read the full breakdown below in the meantime ↓
01

Meaning by company

The distributional hypothesis says a word's meaning is revealed by the words it appears near. Make that concrete: scan a huge corpus and build a co-occurrence matrix X, where X_ij is the number of times word j shows up in the context of word i. That matrix is enormous and sparse, but it holds the entire distributional signature of the vocabulary — everything statistics can tell you about how words relate.

GloVe (Global Vectors, Pennington, Socher & Manning, 2014) turns that table into short dense vectors. It learns a vector for each word such that the dot product of two word vectors (plus a couple of bias terms) approximates the logarithm of their co-occurrence count. Fit that across all nonzero entries and you get embeddings where similar words cluster and where vector differences encode relationships. Unlike word2vec, which streams the corpus predicting local windows, GloVe aggregates the whole corpus into X first and then factorizes it — global statistics, used explicitly.

The one-sentence version

Learn word vectors so that w_i · w̃_j + b_i + b̃_j ≈ log(X_ij) across all co-occurring word pairs, minimizing a weighted least-squares loss whose weighting f(X_ij) caps frequent pairs and ignores unseen ones.

02

Ratios carry meaning

Why fit the log of the counts, rather than the counts themselves? GloVe's central observation is that the useful information isn't in a single co-occurrence probability but in the ratio of two. Take the words ice and steam. Both co-occur with water (they're both about H₂O), and both co-occur rarely with fashion. Neither raw count distinguishes them. But probe with solid: it appears much more with ice than with steam. Probe with gas: the reverse. The ratio P(solid | ice) / P(solid | steam) is large; P(gas | ice) / P(gas | steam) is small. Those ratios are where the meaning lives.

Ratios are multiplicative, and a vector space is additive — dot products add and subtract, they don't divide. Taking logs bridges the two: a ratio of probabilities becomes a difference of logs, and a difference of logs can be modeled by a difference of dot products. So fitting w_i · w̃_j ≈ log(X_ij) is precisely the design that lets vector arithmetic capture co-occurrence ratios — and, as a bonus, the linear analogies (king − man + woman ≈ queen) that made word embeddings famous. The log isn't cosmetic; it's the hinge that turns statistics into geometry.

03

The weighting function

A plain least-squares fit on log(X_ij) has two problems, and one weighting function f(x) fixes both:

f(x) = (x/x_max)^α for x < x_max, else 1
x = 0f(0) = 0 — unseen pairs contribute nothing; the sum skips the vast empty matrix.
small xRare pairs are downweighted — noisy, unreliable counts don't dominate.
x ≥ x_maxFrequent pairs are capped at weight 1 — "the" doesn't swamp the loss.
α = 0.75The exponent shapes the ramp; the paper used α = 0.75, x_max = 100.

Without weighting, the two extremes wreck the fit. Extremely common pairs — every content word with the, of, and — would contribute overwhelming error and pull all the vectors toward modeling function words. Meanwhile rare pairs, whose counts are just noise, would be treated as equally important as reliable ones. The weighting f(x) ramps up for rarer-but-real pairs, saturates to 1 above a cap so hyper-frequent pairs can't dominate, and — the quietly crucial part — is exactly zero at x = 0, so the loss only ever sums over the small fraction of word pairs that actually co-occur. That's what makes fitting a vocabulary-squared matrix tractable.

04

The objective

GloVe minimizes a single weighted least-squares loss over all word pairs:

J  =  Σi,j  f(Xij)  ·  ( wi·w̃j + bi + b̃jlog Xij

Each term pulls the dot-product-plus-biases toward the log co-occurrence, weighted by f(X_ij). w_i and w̃_j are the "word" and "context" vectors (the final embedding is usually their sum); b_i, b̃_j are learned biases that absorb per-word frequency.

Read it as a regression: the target is log X_ij, the prediction is w_i·w̃_j + b_i + b̃_j, the residual is squared, and each residual is scaled by f(X_ij). Two learned bias terms per word soak up the fact that some words are just more frequent than others, so the dot product is free to capture the interesting relational structure. Training is plain gradient descent (AdaGrad in the paper) over only the nonzero entries. The runnable version below computes the weighting, the prediction, and a single weighted loss term — the whole objective in miniature.

RUN IT YOURSELF

The GloVe objective, from scratch

GloVe fits word vectors so a dot product recovers the log co-occurrence, under a weighting that caps frequent pairs and ignores unseen ones. Here are the pieces: the weighting f(x) = (x/xmax)^α (0 at x=0, capped at 1 above xmax), the model's prediction (dot product plus two biases), and one weighted-loss term. A perfect fit — prediction equal to log X — contributes zero. Change the counts and the vectors and watch the loss move.

CPython · WebAssembly
05

What it showed

GloVe unified count-based and prediction-based embeddings and produced strong, reusable vectors:

ContributionSignificance
Global counts, done rightFitting log co-occurrence with a weighted regression matched or beat word2vec on word-analogy and similarity tasks.
The ratio insightShowed explicitly that co-occurrence ratios — not raw counts — encode meaning, motivating the log-linear model.
A principled weightingf(x) tamed frequent words and noisy rare pairs, and its f(0)=0 made the huge sparse matrix tractable.
Free pretrained vectorsGloVe vectors trained on Wikipedia and Common Crawl became a standard NLP starting point for years.

The limitations are the limitations of all static embeddings: one vector per word type, so "bank" (river) and "bank" (money) collapse into a single point, and no sensitivity to sentence context. Building the global matrix also costs memory. But within the static-embedding world, GloVe was a clean, well-motivated, top-performing method — and a clear demonstration that classic matrix factorization on co-occurrence counts and neural prediction were two views of the same thing.

06

From counts to geometry

For several years, GloVe and word2vec were the way to represent words, and pretrained GloVe vectors were a default first layer in a huge fraction of NLP models — sentiment classifiers, taggers, early question-answering systems. They proved that meaning could be distilled from raw co-occurrence statistics into a compact geometry, cheaply and reusably, and they popularized the analogy demonstrations that made embeddings intuitive to a wide audience.

The field then moved to contextual embeddings, where a word's vector depends on the sentence it's in — ELMo, then BERT and the Transformer, which resolve "bank" differently in "river bank" and "bank account." Those largely superseded static vectors for high-accuracy tasks. But GloVe's lesson endures inside them: the input embedding tables of every modern language model still map tokens to dense vectors learned from distributional statistics — the same idea, now trained end-to-end and made context-dependent. GloVe remains one of the clearest on-ramps to understanding how text becomes numbers a network can reason over.

Worth knowing

GloVe learns two vectors per word — a "target" vector w and a "context" vector w̃ — because a word plays both roles in co-occurrence. They're initialized differently but are largely symmetric by the end. The standard trick is to use their sum (w + w̃) as the final embedding rather than either alone; averaging the two acts as a small ensemble and reliably gives a modest quality bump over picking just one.

Frequently asked

Quick answers

What is GloVe?

A word-embedding method that learns vectors from global co-occurrence counts, fitting them so a dot product (plus biases) recovers the log co-occurrence of each word pair.

How does it differ from word2vec?

word2vec is local and predictive (sliding-window word prediction); GloVe is global and count-based (a weighted least-squares fit on the whole co-occurrence matrix). Similar quality, related math.

Why the log and the weighting f(x)?

The log turns meaningful co-occurrence ratios into differences a vector space can model. f(x) caps frequent pairs, downweights rare ones, and is 0 at x=0 so unseen pairs are skipped.

Why does it matter?

GloVe (with word2vec) was the standard word embedding for years; its pretrained vectors seeded countless NLP systems and showed counts factorize into meaningful geometry.

GloVe: Global Vectors for Word Representation · Jeffrey Pennington, Richard Socher, Christopher D. Manning · Stanford · 2014 · read the original paper → · Vibe Engines · 2026
Finished this one? 0 / 101 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns