Word Embeddings
Word Embeddings — A word embedding maps each word to a dense vector of numbers so that words used in similar contexts sit close together, and directions in the space capture relationships — famously, king − man + woman lands near queen.
Explore a galaxy of real GloVe word vectors in 3D: similar words cluster, and meaning becomes geometry. Do arithmetic on words — king minus man plus woman — and watch the answer, queen, light up. Then ask for a relationship the text never showed and watch the analogy fall apart.
The idea in plain words
A word embedding turns every word into a list of numbers — a vector — chosen so that words appearing in similar contexts end up with similar vectors. Plotted in space, synonyms and related words cluster together, and whole regions correspond to themes like countries, family roles, or colors. The model never sees a dictionary; it learns these positions purely from which words tend to appear near each other across billions of sentences.
The surprising part is that directions carry meaning too. The step from man to king is almost the same direction as woman to queen — a “royalty” direction — so you can do arithmetic on words. These vectors are what feed modern language models: before attention can relate words, each token is first turned into an embedding like the ones you are exploring here.
Now, the math
Similarity between two word vectors is measured by the cosine of the angle between them:
An analogy “a is to b as c is to ?” is solved by vector arithmetic, then a nearest-neighbor search:
- the embedding vector for word w.
- the dot product — large when vectors point the same way.
- cosine similarity ignores length and compares only direction.
▸ Show the derivation
The demo uses real 50-dimensional GloVe vectors. You cannot see 50 dimensions, so the galaxy projects them down to three with principal component analysis, keeping the directions of greatest variance. Analogies and neighbor rankings are computed on the full 50-dimensional vectors, so the math is exact even though the picture is a shadow of the true space.
Now Break It
Try this: Ask for an analogy with no basis in text — cat is to table as music is to what — and the top match is arbitrary with a low similarity score.
Control: Analogy builder (the "Shaky analogy" preset)
What happens: Weak analogy! Word vectors only capture patterns that actually co-occur in text — a relationship the corpus never saw returns a low-confidence, essentially random word.
Where word embeddings is used
Word embeddings quietly power much of modern language technology. Search engines use them to match a query to documents that share meaning rather than exact words; recommendation systems embed products and users into the same space to suggest related items; and every large language model begins by converting tokens into embeddings before any deeper processing. The same idea generalizes far beyond words — embeddings represent images, songs, molecules, and graph nodes, letting systems measure similarity and cluster items by learned meaning instead of hand-written rules.
A common misconception is that embeddings “understand” words. They only capture statistical co-occurrence from the training text, which is why they also absorb its biases — analogies can reproduce stereotypes present in the data, a serious fairness concern. Another pitfall is trusting every analogy: the famous king−man+woman result is unusually clean, and many triples return vague or wrong matches because the relationship simply is not encoded linearly. Finally, classic GloVe and word2vec give each word a single fixed vector, so they cannot distinguish the two senses of “bank” — that limitation is exactly what contextual models were built to fix.
Frequently asked questions
What is a word embedding?
How does king minus man plus woman equal queen?
What is the difference between word2vec and GloVe?
What is cosine similarity and why use it instead of distance?
Do word embeddings capture bias?
How are these related to large language models?
Written & reviewed by the ML Visualization team · Last updated .