Lesson 6.3core3 h

Word embeddings

Meaning as geometry: word2vec, GloVe and fastText

Word embeddings were the moment the field realized that meaning could be learned as geometry: similar words end up near each other, and directions encode relations. The skip-gram objective you derive here is a tiny neural network trained with the same cross-entropy and gradients as everything in Phase 4, its negative-sampling trick reappears in contrastive learning (5.8 Self-supervised and contrastive learning) and embedding models for RAG (9.2 Embeddings deep dive), and every transformer still begins with an embedding table (7.4 Inside the block: residuals, LayerNorm, FFN and embeddings).

You'll be able to

  • Explain the distributional hypothesis and why dense vectors beat one-hot encodings
  • Derive the skip-gram objective and its negative-sampling approximation, including the gradient for a center vector
  • Describe GloVe's weighted least-squares objective and fastText's subword vectors
  • Evaluate embeddings (analogies, similarity, downstream tasks), recognize their biases, and explain the move to contextual embeddings

Key ideas

  1. Distributional hypothesis: words in similar contexts have similar meanings; embeddings turn contexts into geometry.
  2. One-hot vectors are mutually orthogonal (no similarity); a dense embedding matrix E ∈ ℝ^(V×d) is a learned lookup table, and lookup = multiplying by a one-hot vector.
  3. Skip-gram predicts context words from the center word with a softmax over V; the embedding is the hidden layer of a one-layer network.
Show 4 more key ideas
  1. Negative sampling turns the V-way softmax into binary classification against K noise words (P_n ∝ U^{3/4}): O(Kd) per update, with a pull-positives/push-negatives gradient.
  2. GloVe fits dot products to log co-occurrence counts with weighted least squares; fastText sums character n-gram vectors so unseen and morphologically related words get vectors.
  3. Analogies (king − man + woman ≈ queen) show relational directions but are fragile; evaluate embeddings on your downstream task.
  4. Embeddings inherit corpus bias (programmer:homemaker) and static vectors conflate word senses; contextual embeddings (ELMo, BERT) fix the latter.

Suggested path through this lesson