Zero Labs
Industry News / AI

Word2Vec Explained: The Moment Words Became Relations

Source · Towards AI By ABHISHEK S M

From the publisher’s feed, collected in the ZeroLabs newsroom.

How models first learned meaning from context — and why that changed everythingIn the first post, we built the base layer:Text → Tokens → Numbers → (lots of math) → Tokens → TextIn the second post, we stayed with the deeper question:Once words become numbers, how does meaning not disappear?We saw that the answer is not “because numbers are magical.” The answer is this: the numbers are learned in a space that preserves relationships. That was the real story of embeddings.Now we are ready for the next step. Because once you accept that words can become numbers without losing meaning, the next question becomes unavoidable:How are those numbers actually learned?This is where Word2Vec enters the story. And Word2Vec matters for more than historical reasons. It was not just a clever neural network from early NLP. It marked a deeper shift:Before Word2Vec, words were mostly treated like labels. With Word2Vec, words began to be treated like positions in a relational world.That is why this model still matters. It is small compared to today’s LLMs. But philosophically, it was one of the first great turning points.Before Word2Vec: words were mostly namesSuppose we assign every word a unique ID:cat → 1842dog → 932milk → 441engine → 77That helps a machine distinguish one word from another. But it tells the machine almost nothing about relationship. It does not say:cat is closer to dog than to enginedoctor belongs nearer hospital than volcanomilk and water participate in partly similar worldsA unique ID preserves identity. It does not preserve structure. One-hot vectors improved the formatting, but not the philosophy. For example, in a tiny vocabulary:cat → [1, 0, 0, 0, 0]dog → [0, 1, 0, 0, 0]engine → [0, 0, 1, 0, 0]This gives the model a clean symbolic input. But still, cat and dog are just as different as cat and engine. That is the problem.In this older view, a word is still basically an isolated token with a name attached to it. It is almost like saying: “Here is the symbol. Now go figure out what to do with it.”But language does not really work as isolated symbols. Words live in patterns. They live in neighborhoods. They live in repeated company. And that is exactly the crack through which Word2Vec enters.Word2Vec changed the questionWord2Vec does not begin by asking:“What is the definition of cat?”It asks something subtler:“What kinds of local worlds does cat tend to appear in?”That is a profound shift.That is the real philosophical evolution.A word is no longer understood only by its private identity. A word is understood by the company it keeps, the predictions it supports, and the kinds of linguistic worlds it fits into. That is why Word2Vec felt bigger than its tiny network. It quietly changed what counted as meaning.The central intuition: a word is shaped by its neighborhoodLet us take a tiny corpus:the cat drinks milkthe dog drinks waterthe cat chases mousethe dog chases ballNow pause on the word cat. What surrounds it? Across these sentences, it appears near things like:thedrinksmilkchasesmouseNow pause on dog. It appears near:thedrinkswaterchasesballNot identical. But similar. That matters.Because if a model is repeatedly forced to predict these local surroundings, then cat and dog will keep receiving similar correction signals. And if they receive similar correction signals over and over, their learned vectors will gradually move toward similar regions.That is one of the cleanest ideas in machine learning:Meaning does not need to be hand-written into the model. It can emerge from repeated pressure to predict context well.Word2Vec in one sentenceHere is the simplest accurate definition:Word2Vec learns a dense vector for each word such that the vector is useful for predicting nearby words.That sentence is easy to miss, so it is worth sitting with.Word2Vec is not directly optimizing for a dictionary definition. It is optimizing for a prediction task. And while solving that task, it learns weights. Those weights become embeddings. That is why embeddings are so interesting:They are not definitions first and vectors second. They are vectors first, and useful structure emerges through training.The two forms: CBOW and Skip-gramWord2Vec became famous in two main versions:CBOW — Continuous Bag of WordsSkip-gramAt first glance, they seem like two minor engineering variants. Mechanically:CBOW predicts the center word from nearby wordsSkip-gram predicts nearby words from the center wordThat is correct. But underneath, they reflect two subtly different views of how meaning is revealed.CBOW: the world reveals the wordTake the sentence:the cat drinks milkSuppose the center word is cat. The nearby context words might be:thedrinksCBOW makes a training example like this:Input: the, drinksTarget: catSo CBOW asks:“Given this neighborhood, what word belongs here?”Mechanically, that is context → word. But the deeper intuition is:A word can be understood from the world in which it fits.The surroundings constrain the identity of the center. This gives CBOW a quietly interpretive character. The context acts like a field of clues. The neighborhood helps disclose the missing word.You could say:CBOW treats meaning as something that can be recovered from situation.That is a deeper idea than it first appears.Skip-gram: the word reveals the worldNow take the same sentence:the cat drinks milkAgain choose cat as the center word.Now Skip-gram turns this into training pairs like:Input: cat → Target: theInput: cat → Target: drinksSo Skip-gram asks:“Given this word, what kinds of neighbors tend to gather around it?”Mechanically, that is word → context. But the deeper intuition is different:A word can be understood by the kinds of worlds it tends to generate.Now the word is not being recovered from surroundings. It is being represented through its relational footprint — the set of local contexts it tends to imply.You could say:Skip-gram treats meaning as something expressed through consequence.That is why Skip-gram feels slightly more generative.Their deeper unityCBOW and Skip-gram are not just opposites in code. Together, they express something very important:A word and its world define each other.CBOW says world → word. Skip-gram says word → world. Together they say:Meaning is not trapped inside isolated symbols. Meaning lives in the mutual fit between a token and its neighborhood.This was one of the quiet philosophical beauties of Word2Vec. It was one of the first moments in mainstream NLP where “meaning” began to be treated as relation rather than essence.A tiny training worldLet us make the whole thing concrete with a tiny vocabulary:thecatdogdrinksmilkwaterchasesmouseballSuppose we choose an embedding size of 3. That means each word will eventually be represented by a vector of 3 learned numbers. At the start of training, these numbers are usually small random values. So maybe, before the model has learned anything:the → [0.02, -0.01, 0.03]cat → [0.11, -0.08, 0.05]dog → [-0.04, 0.09, 0.01]drinks → [0.07, 0.02, -0.06]These numbers do not mean anything useful yet. That point matters.At the beginning:Nothing means anything yet.There are only random coordinates. Training is the long process by which those random coordinates get reshaped into a meaningful relational map.How training data is createdSuppose the sentence is:the cat drinks milkLet the context window size be 1.That means for each center word, we look one word to the left and one word to the right. So we get relations like:center = cat → context = the, drinkscenter = drinks → context = cat, milkcenter = milk → context = drinksIf we use CBOW, then from:the, drinkswe try to predict:catIf we use Skip-gram, then from:catwe try to predict:thedrinksThis sliding window is how raw text gets converted into training examples. No dictionary definitions. No grammar theory required. Just repeated local neighborhoods.The tiny neural networkNow let us look at the classic Word2Vec architecture. Suppose our vocabulary size is 9 and embedding size is 3. Then the network looks like:input one-hot vector (size 9) → hidden / projection layer (size 3) → output scores over vocabulary (size 9)At first this looks almost too simple. But the simplicity is the point. The network is small, and yet it learns a useful space.What the first weight matrix really isThe first matrix might have shape:9 × 3That means:one row per wordthree numbers per rowSuppose the row for cat is initially:[0.11, -0.08, 0.05]If the input word is cat, its one-hot vector selects exactly that row. So the hidden layer becomes:[0.11, -0.08, 0.05]That is the current embedding for cat.This is one of the most important truths of Word2Vec:The embedding is not some mysterious object added later. It is literally the learned weight row used for the word.So when people say “the model learns an embedding table,” this is what they mean. The table is just the first matrix becoming meaningful through training.What happens during training: guess, compare, correctLet us walk through one Skip-gram training example.Sentence:the cat drinks milkWindow size = 1Center word = catContext words = the, drinksSo Skip-gram creates two training examples:cat → thecat → drinksTake the first one:Input: catTarget: theNow the training story goes like this.Step 1: Look up the current word vectorThe model takes the one-hot input for cat and retrieves the current hidden vector:cat = [0.11, -0.08, 0.05]Step 2: Produce scores for possible output wordsUsing the output-side weights, the model generates scores for the vocabulary. Maybe the raw scores are:the → 0.12dog → 0.03drinks → 0.10milk → -0.02mouse → 0.01These are just rough numbers, not probabilities yet.Step 3: Turn scores into probabilitiesA softmax turns them into a probability distribution. Maybe:the → 0.20drinks → 0.18dog → 0.16milk → 0.14others → smallerThe correct answer is the. So the model is partly right, but not right enough.Step 4: Measure the errorThe model compares its predicted distribution with the true target. It wants the to be much higher. The gap between what it predicted and what should have been predicted becomes the training error.Step 5: Update the weightsNow the model nudges its parameters so that next time:the vector for cat becomes a little better at predicting thethe output-side representation for the becomes a little more compatible with catwrong alternatives become slightly less attractiveThen the process repeats for:cat → drinksdrinks → catdrinks → milkdog → thedog → chasesand so on, over and over, sentence after sentence.That is training. Not revelation. Not sudden understanding. Just an enormous number of tiny corrections.What those corrections are really doingThis is the deeper picture. When the model repeatedly sees that cat is near:thedrinkschasesmouseand that dog is near:thedrinkschasesballthen the vectors for cat and dog keep getting pulled by similar forces.That matters. Because training is not just “updating weights.” Training is the gradual reshaping of a geometric space so that frequently related words settle into useful positions relative to one another.A compact way to say it is:Similar contexts create similar gradient updates. Similar gradient updates create similar embeddings.That is one of the deepest mechanical truths in Word2Vec. The model is never explicitly told:“cat and dog are semantically related”It does not need to be. The relation emerges because the two words keep participating in similar local worlds.Negative sampling: meaning by attraction and contrastThere is a practical problem with naive training. If the vocabulary is huge, computing probabilities over every possible output word every time becomes expensive.So Word2Vec often uses negative sampling.Suppose the true pair is:cat → drinksInstead of comparing drinks against the entire vocabulary, the model may do something simpler:pull cat closer to drinkspush cat away from a few randomly chosen wrong words, such as:enginebananacloudNow training becomes a contrastive game:true pairs should align morefalse pairs should align lessThis is efficient. But it is also quietly profound.Because a word becomes meaningful not only through what belongs with it, but also through what does not belong with it. cat is shaped by being pulled toward:pet-like contextsaction-animal contextsdomestic-life contextsand pushed away from:engine-like contextsgeological contextsunrelated technical contextsSo the geometry is formed by both affinity and boundary.That is a deep truth about representation itself.What happens during inferenceNow comes an equally important question:Once training is finished, what happens during inference?This is where many people get confused, because Word2Vec is not like ChatGPT. It is not mainly a text generator. Its main job is to learn word vectors. So after training, what we usually keep is the embedding matrix. For example, after training, maybe we have something like:cat → [0.82, 0.21, -0.05]dog → [0.79, 0.25, -0.03]milk → [0.10, 0.88, -0.12]water → [0.07, 0.84, -0.10]chases → [0.66, 0.18, 0.40]These numbers are illustrative, not actual trained outputs. Now during inference, the model typically stops learning and starts using this learned space. That means one of several things.1. Look up a word’s vectorIf you want the embedding for cat, you just retrieve it.2. Compare words by similarityYou can ask:which words are closest to cat?is dog closer to cat than engine is?which words live in similar neighborhoods?3. Use the vectors in another modelYou can feed the embeddings into:classifiersclustering pipelinesrecommendation systemsolder search systemsdownstream NLP tools4. Build simple sentence vectorsA rough trick is to average word vectors. For example, for:the cat drinks milkyou can average the vectors of:thecatdrinksmilkIt is crude, but historically very useful.So inference in Word2Vec is usually not “generate text.” It is more like:Consult the learned geometry.Training vs inference: the deeper feelMechanically, you could say:training = update the weightsinference = use the weightsThat is true, but the deeper view is:During training, the model is still shaping its map of relations. During inference, it is navigating inside the map it has already learned.Or even more simply:training is the making of the mapinference is movement within the mapThat gives the right feel. During training, language is still becoming geometry. During inference, the geometry is already there and can be consulted.Why Word2Vec felt revolutionaryToday, in the age of giant transformers, Word2Vec can look tiny. But historically it was a major turning point.Because it showed that:useful semantic structure can emerge from predictiondense vectors can replace brittle sparse featureslanguage can be organized geometricallyword knowledge can be learned rather than hand-engineeredThat was huge.Instead of telling the model what words mean, we could let meaning emerge from usage. That changed NLP.It also changed how people thought about representation. Meaning no longer had to be imagined as a definition attached to a symbol. It could be imagined as a stable position in a learned relational field.The famous analogy examplesPeople became fascinated by results like:king — man + woman ≈ queenWhy would that happen?Because the space was not random anymore.If many relational patterns repeat in text, then training can organize them into somewhat consistent directions. Examples like male ↔ female, country ↔ capital, and singular ↔ plural can start to show up as geometric regularities.This does not mean the model has full human-like understanding. But it does mean something important:Repeated statistical structure can crystallize into geometric form.That was one of the first moments in modern NLP when learned representations started to feel genuinely deep.What Word2Vec still could not doFor all its power, Word2Vec had a major limitation:Each word gets one main vector.So the word bank gets one embedding, even though it can mean:river bankfinancial bankLikewise:bat can be an animal or sports equipmentlight can mean illumination or low weightcrane can be a bird or a machineWord2Vec was revolutionary, but still static. It treated meaning as relational, but not yet fully situational.That is why later models moved toward contextual embeddings, where the meaning of a word changes depending on the sentence. And that leads naturally toward BERT, GPT, and transformers.So Word2Vec was not the end of the story. But it was the moment the story changed direction.The deeper legacy of Word2VecWord2Vec mattered not only because of one algorithm, but because of the worldview it helped establish.It suggested that:language can be represented continuously, not only symbolicallymeaning can emerge from context predictionwords can be understood by neighborhood rather than only by definitiongeometry can carry semantic structureThat worldview still lives inside modern AI.Even today, the larger idea remains:Meaning is shaped by context, and useful representation is learned through use.Word2Vec was one of the first clean demonstrations of that truth.The calm takeawayHere is the simplest way to hold the whole story.Word2Vec trains on local context.It either:predicts a word from its neighbors (CBOW), orpredicts neighbors from a word (Skip-gram)To solve that task, it learns a compact hidden representation for each word. That compact representation becomes the embedding.At the start, the vectors are random. During training, repeated contextual corrections reshape them into a relational map. During inference, the model no longer reshapes that map; it uses the map it has already learned.Words that live in similar neighborhoods receive similar training pressure. Similar training pressure leads to similar vectors. That is why cat ends up near dog, and far from engine.So Word2Vec did more than learn small vectors.It changed the way NLP could think about meaning. A word was no longer just a label. It became a position in a field of relations. That was the breakthrough.One-line memory hookWord2Vec learns meaning by turning repeated neighborhood patterns into stable positions in a relational space.Word2Vec Explained: The Moment Words Became Relations was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.