Word Embeddings: PPMI, GloVe & Bias
Build count-based and learned word vectors, derive GloVe gradients, and interpret embedding visualizations and analogy results.
Yong-Hwan Lee
Published · Updated
Overview
This study uses AG News text to compare positive pointwise mutual information (PPMI) with dimensionality reduction and learned GloVe vectors. A separate analysis examines analogy outputs from pretrained word2vec embeddings.
The charts, training log, and analogy scores below come from the original experiment. They are not newly measured results.
Vocabulary and memory
The original report retained tokens occurring at least 12 times and reported approximately 96% token coverage. Coverage means the fraction of token occurrences represented, not the fraction of distinct word types.

A dense co-occurrence matrix with vocabulary size requires bytes, where is the number of bytes per entry. The earlier estimate of about 1 GB applies to that experiment's vocabulary and representation; it is not a general memory bound. Probability calculations and factorization can require additional copies.
Count-based vectors with PPMI
Let count occurrences of word with context , and let . Estimate
For positive joint and marginal probabilities,
PPMI stands for positive pointwise mutual information. Zero-count pairs need explicit handling to avoid evaluating .
The repository computes , concatenates and , and normalizes each row. With its default , this produces 32-dimensional vectors before visualization.

View the three topic close-ups



These views help inspect local neighborhoods. Distances between distant clusters, cluster sizes, and empty spaces in t-SNE should not be read as direct measurements of the original embedding geometry. See the t-SNE paper.
GloVe objective and gradients
For a pair with , define
The objective and weighting function are
The implementation uses and . Zero-count pairs are omitted. This weighted regression objective follows the GloVe paper.
One pair versus the full objective
For the single-pair loss ,
The full gradient must sum every contribution involving the parameter:
The context-vector gradient sums over ; bias gradients sum over their respective partners. A minibatch implementation must accumulate repeated indices rather than overwrite their contributions.
Recorded training behavior
The final logged averages over 100 batches were approximately 0.0467–0.0483. This describes the end of the run; a short, stable loss segment alone does not establish convergence or downstream quality.
Iter 14400 / 15227: average loss = 0.046686563985831216
Iter 14700 / 15227: average loss = 0.04827717854832922
Iter 15200 / 15227: average loss = 0.04732485846561704
Interpreting analogy results
The separate word2vec analysis queried . The original nearest-neighbor outputs included:
| Query | Selected returned words | Similarity scores |
|---|---|---|
| man : doctor :: woman : ? | gynecologist, nurse, doctors | 0.709, 0.648, 0.647 |
| woman : doctor :: man : ? | physician, doctors, surgeon | 0.646, 0.586, 0.572 |
These asymmetric associations motivate a broader bias evaluation. Scores measure vector similarity, not probabilities or facts about people. Two queries do not establish bias prevalence across the vocabulary or identify its cause. These pretrained word2vec results are separate from the AG News GloVe experiment.
Reproducing the study
The repository contains:
| Script | Purpose |
|---|---|
build_freq_vectors.py | Counts, PPMI, SVD, and visualization |
build_glove_vectors.py | GloVe training |
Exploring_learned_biases.py | Pretrained embedding analogy analysis |
Record dependency versions, dataset, tokenizer, vocabulary cutoff, context definition, and random seed when comparing runs. The historical results have not been reproduced in a fresh training run.
Takeaways
- Coverage and memory depend on tokenization, cutoff, and storage format.
- Distinguish a pairwise gradient from the full gradient when implementing GloVe.
- Visualizations and analogy queries support exploration; general claims need broader evaluation.