Turn each word into a dense vector so that closeness in space means closeness in meaning — and relationships become directions.
A word embedding turns each word into a vector — a list of numbers placing it as a point in space. The layout is learned so that geometry encodes meaning: words used in similar ways sit close together, and consistent relationships become consistent *directions*. Famously, king − man + woman lands near queen.
cat is no closer to dog than to Tuesday. Embeddings are dense (a few hundred numbers) and *learned*, so similarity actually shows up as distance.The signal is co-occurrence — which words appear near each other in raw text. word2vec exploits this with a tiny prediction task over a sliding window. There are two flavors:
man to king is roughly the same step as from woman to queen. That's why analogies can be solved with vector addition and subtraction.# closeness is measured by COSINE similarity (angle), not raw distance
cos(a, b) = dot(a, b) / (norm(a) * norm(b)) # 1 = same direction
# the classic analogy
vec = embed["king"] - embed["man"] + embed["woman"]
nearest(vec) # -> "queen"word2vec / GloVe embeddings are static — bank gets one vector whether it's a river or a vault. Modern transformers produce contextual embeddings, where the vector changes with the sentence. But the static-embedding intuition is the foundation underneath.