Word Embeddings & Word2Vec
NLP
Chapter 5 · Word Embeddings & Word2Vec
nlp1-4 diagnosed Problem 2: every word is its own isolated, unrelated dimension. This chapter fixes it — and reveals that the tool doing the fixing is something you already know how to build.
Word Embeddings — The Core Idea
Instead of a huge, sparse vector with one arbitrary dimension per vocabulary word, represent each word as a small, dense vector — commonly 100–300 numbers — learned so that semantically similar words end up genuinely close together in that vector space. nlp1-4's own example, resolved directly: in embedding space, "good" and "great" sit near each other; "good" and "car" sit far apart. A real, learned, geometrically meaningful relationship — not an arbitrary one.
Word2Vec — Learning This From Raw Text Alone
Word2vec learns embeddings self-supervised — no manual labeling at all, purely from patterns in how words co-occur across a huge corpus of ordinary, unlabeled text. Two real training setups:
| Approach | Predicts |
|---|---|
| CBOW | The target word, from its surrounding context words |
| Skip-gram | The surrounding context words, from the target word |
llm1 covers for large language models. Word2vec is a genuine, small-scale ancestor of that approach, not an unrelated technique.
Word2Vec Is Literally nn1-1's Own Neuron, Generalized
Word2vec's own architecture is a small feedforward network, built entirely from nn1-1's own vocabulary: an input layer (a one-hot encoded word), a single hidden layer, and an output layer predicting the context or target word.
nn1-5's own backpropagation. Nothing new was needed to build word2vec — it's nn1-1's own generalized layer stack, applied to exactly this self-supervised prediction task.
The Geometric Payoff — Honestly Framed
Trained on a large enough corpus, the resulting embedding space captures genuine semantic and syntactic relationships well enough that vector arithmetic becomes meaningful: the famous king − man + woman ≈ queen.
In Practice — Pretrained, Not Trained From Scratch
Training word2vec from scratch needs a genuinely large corpus. In practice, pretrained embeddings — trained once, on massive text collections, by someone else — are typically used directly rather than retrained per project. nlp1-9 covers this properly; for now, know that it's the normal way embeddings actually get used.
What's Still Broken
nlp1-4's meaning problem is solved. Its other diagnosed problem — word order — is completely untouched by anything in this chapter. Averaging or otherwise combining word embeddings without regard to their sequence still loses order entirely. nlp1-6 is where that gets fixed.
Hands-On Exercises
Explain the difference between CBOW and skip-gram, and explain why both count as genuinely self-supervised despite requiring no human-provided labels at all.
📄 View solutionUsing this chapter's own finding-box, explain precisely what a word's embedding actually is inside word2vec's own network, and explain why this chapter calls it "nn1-1's own generalized layer stack" rather than a new kind of model.
📄 View solutionExplain why this chapter presents "king − man + woman ≈ queen" with an explicit caveat rather than as unqualified proof that embeddings perfectly capture all semantic relationships.
📄 View solutionChapter 5 Quick Reference
- Word embeddings — dense, small vectors where semantic closeness becomes geometric closeness, fixing nlp1-4's meaning problem
- Word2vec — self-supervised: CBOW predicts a word from context, skip-gram predicts context from a word; no manual labeling — a genuine small-scale ancestor of llm1's own next-token pretraining
- The embedding is the hidden layer's own weight matrix — word2vec is literally nn1-1's own neuron/layer stack, generalized
- "king − man + woman ≈ queen" is real but illustrative — not a guarantee of perfectly clean arithmetic everywhere
- Pretrained embeddings are the normal path in practice — full coverage in nlp1-9
- Meaning: solved. Order: still completely unaddressed — Next chapter: Sequence Models for Text