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.
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 | — |
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
- The map is a shadow. The 2-D plot keeps only ~13% of the variation in the data (the top two principal components). Two points can look close on screen and be far apart in the full space. Use the map for intuition, not for distances.
- Analogies are real but fragile. “king − man + woman = queen” works only if you exclude the input words: turn the toggle off above and the answer collapses to an input. It also misses often. bigger − big + small returns larger, a synonym of the source, before smaller. doctor − man + woman returns nurse: the embedding has absorbed a societal bias from its training text. The arithmetic is a tendency, not a law (Mikolov 2013; Ethayarajh 2019; Bolukbasi 2016).
- Coordinates are not features. No single dimension in the bar chart is interpretable on its own. Meaning lives in directions and subspaces, not in single axes: the space has “no privileged basis” (Elhage 2021). This returns with the residual stream in a later tool.
- These are static embeddings. Here “bank” has one vector, river bank or savings bank. Context-dependent meaning is what attention adds; the deck comes back to that.
- GloVe vs. GPT-2. GloVe is a standalone word embedding. GPT-2's are token embeddings sitting inside a transformer: same geometric idea, larger, messier analogies. The source toggle switches between them.
- Curated vocabulary. The map shows a hand-picked subset — 117 words for GPT-2, 158 for GloVe. Analogy search runs over the ~2,780 most frequent words, not the whole vocabulary, for speed and legibility.
·Sources
- Mikolov, Yih & Zweig (2013). Linguistic Regularities in Continuous Space Word Representations. NAACL. — the analogy result.
- Mikolov et al. (2013). Efficient Estimation of Word Representations in Vector Space. arXiv:1301.3781. — word2vec.
- Pennington, Socher & Manning (2014). GloVe: Global Vectors for Word Representation. EMNLP. — the GloVe vectors used here.
- Radford et al. (2019). Language Models are Unsupervised Multitask Learners. — GPT-2, whose input embedding matrix is used here.
- Ethayarajh, Duvenaud & Hirst (2019). Towards Understanding Linear Word Analogies. ACL. — when and why analogies hold.
- Bolukbasi et al. (2016). Man is to Computer Programmer as Woman is to Homemaker? NeurIPS. — bias in embeddings.
- Elhage et al. (2021). A Mathematical Framework for Transformer Circuits. Anthropic. — “no privileged basis”.
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.