The Geometry of Meaning · 16.S893 · Session 2
embeddings

A word is a point in space.
Meaning is a direction.

A language model never sees letters. It turns text into vectors, and from then on every judgement of similarity or analogy is geometry. Everything here runs on real GloVe vectors.

The vectors are pre-trained, not faked. Where a 2-D screen forces a simplification, the page says so, and the ledger at the bottom lists them.

1Text to tokens to integers

The model splits text into tokens from a fixed vocabulary and replaces each one with its integer ID. Tokens are not words: a common word is one token, a rare word splits into pieces. This is the real GPT-2 byte-pair encoder, 50,257 tokens. Type anything.

Each ID looks up a row of the embedding matrix. That row is the token's vector. live: real GPT-2 tokenizer

2The embedding lookup table

An embedding is a lookup table: one row per vocabulary entry. Picking a word picks its row, a vector of 768 numbers. Nobody wrote these numbers. They were learned from text.

row — of W_E ∈ ℝ^(|V|×d)
The bars show the components of this row. No single bar means anything on its own.

3The map: a 2-D shadow

PCA flattens the cloud onto its two directions of greatest variation. Hover a point. Drag to pan, scroll to zoom. Click a word for its nearest neighbours. Click a legend entry to hide a category.

4Similarity: cosine and dot product

“How related are two words?” becomes “how aligned are two vectors?” The cosine of the angle is the standard measure. It ignores length and keeps direction.

cosine similarity—
raw dot product—
angle—
The angle drawn in 2-D. simplified: the real vectors have hundreds of dimensions

5Analogies: arithmetic on meaning

Relationships are directions, so you can add and subtract them. “king − man + woman” lands near “queen”. Try the presets, including the ones that fail.

− +

The parallelogram, drawn when all four words are on the map. The open circle is where A − B + C lands in 2-D. The green point is the nearest word in the full space. The gap between them is the projection error.

⚠What this page simplifies

·Sources

GloVe vectors bundled via the npm package wink-embeddings-sg-100d (MIT), which redistributes Stanford GloVe (PDDL). GPT-2 rows exported from the released gpt2 weights. Tokenizer: gpt-tokenizer (GPT-2 / r50k_base). Math typeset with KaTeX. Data and libraries are vendored in this folder; only the webfonts come from the network.