This NLP & Speech concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
NLP & Speech
Word2Vec, GloVe, and Subword Embeddings
See how context windows, global co-occurrence counts, and character n-grams shape word vectors, and why nearest-neighbor semantics can mislead.
Concept Structure
Word2Vec, GloVe, and Subword Embeddings
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
4 prerequisites listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
3/3 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
A word embedding is not the meaning of a word written down by hand. It is a learned vector whose geometry comes from a training signal.
The distributional idea is simple: words that appear in similar contexts should become useful neighbors. If river often appears near stream, water, and flow, while money appears near loan, cash, and bank, a training objective can push the vectors into different regions of space.
Word2Vec makes this local. In skip-gram, a center word predicts words in a small context window. A positive pair such as (river, stream) should get a larger dot product; sampled negative words such as money should get a smaller dot product.
GloVe makes the global count table visible. Instead of only looking at one window at a time, it fits vector dot products to the logarithm of corpus co-occurrence counts, with a weighting function so common and rare events do not dominate in the same way.
Subword embeddings repair a different failure. A pure word lookup has no vector for a word it has never seen. fastText-style models build a word vector from character n-gram vectors, so riverbank can receive a composed vector from pieces such as riv, iver, ban, and ank.
The caveat is part of the concept: nearest neighbors are evidence, not truth. Static word vectors usually give one vector per word type, so bank has to share space between river-bank and money-bank contexts. Subword pieces help with rare forms, but spelling is not meaning.
Source spine: Stanford CS224N Word Vectors I and Word Vectors II; Jurafsky and Martin, SLP3 Chapter 6; Mikolov et al., Efficient Estimation of Word Representations and Distributed Representations of Words and Phrases; Pennington et al., GloVe; Bojanowski et al., Subword Information; D2L, The Word2Vec Dataset.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be a vocabulary and let be the target embedding for word . Let be the context embedding for context word .
For a skip-gram positive pair with negative samples , the negative-sampling objective for one training example is:
where .
The first term raises the dot product for the observed center-context pair. The negative terms lower dot products for sampled words that did not appear as the context in this example.
GloVe starts from a global co-occurrence matrix , where counts how often word appears in the context of word . It fits:
Only nonzero co-occurrences enter this log-count form. The weighting function controls how strongly each count matters.
For fastText-style subword embeddings, let be the set of character n-grams for word . A simplified composed word vector is:
The important distinction is:
- Word2Vec: local context prediction updates vectors.
- GloVe: global co-occurrence counts become log-count targets.
- Subword embeddings: character n-gram vectors compose a word vector, including for rare or unseen forms.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
This small script mirrors the lab: one skip-gram update, one GloVe log-count table, and one subword composition.
import math
import numpy as np
river = np.array([0.20, 0.40])
stream = np.array([0.50, 0.20])
money = np.array([-0.40, -0.30])
lr = 0.35
def sigmoid(x): return 1 / (1 + math.exp(-x))
def cosine(a, b): return float(a @ b / (np.linalg.norm(a) * np.linalg.norm(b)))
positive_grad = (1 - sigmoid(river @ stream)) * stream
negative_grad = -sigmoid(river @ money) * money
river_after = river + lr * (positive_grad + negative_grad)
print("cos(river, stream):", round(cosine(river, stream), 3), "->", round(cosine(river_after, stream), 3))
print("cos(river, money):", round(cosine(river, money), 3), "->", round(cosine(river_after, money), 3))
counts = np.array([[6, 5, 2, 0], [5, 4, 1, 0], [1, 0, 3, 4], [0, 0, 0, 6]])
log_targets = np.full_like(counts, np.nan, dtype=float)
log_targets[counts > 0] = np.log(counts[counts > 0])
print("GloVe log-count target river-flow:", round(log_targets[0, 1], 3))
ngrams = {
"riv": [0.28, 0.62], "ive": [0.18, 0.55], "ver": [0.15, 0.50],
"erb": [0.05, 0.32], "rba": [0.00, 0.20], "ban": [-0.12, 0.05], "ank": [-0.10, 0.02],
}
riverbank = np.mean(np.array(list(ngrams.values())), axis=0)
bank = np.array([0.00, 0.18])
print("subword riverbank vector:", np.round(riverbank, 3))
print("closest demo neighbors:", sorted(
{"river": river, "stream": stream, "bank": bank, "money": money}.items(),
key=lambda item: -cosine(riverbank, item[1])
)[:2])
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Prediction check: inspect the context window, qualitative vector map, co-occurrence table, and subword pieces. Then predict which pair should move closer after a skip-gram update and which mechanism can create a vector for unseen riverbank before revealing the exact movement, log-count targets, and nearest-neighbor caveat.
The lab hides cosine values, update arrows, GloVe log-count targets, and the subword-composed vector until you commit. The goal is to connect the map to the training signal instead of treating an embedding map as magic semantics.
Live Concept Demo
Explore Word2Vec, GloVe, and Subword Embeddings
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Word2Vec, GloVe, and Subword Embeddings should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
See how context windows, global co-occurrence counts, and character n-grams shape word vectors, and why nearest-neighbor semantics can mislead.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Word2Vec, GloVe, and Subword Embeddings should make visible.
Visual Inquiry
Make the image answer a mathematical question
See how context windows, global co-occurrence counts, and character n-grams shape word vectors, and why nearest-neighbor semantics can mislead.
Which visible object should carry the first intuition?
Pick the cue that should make Word2Vec, GloVe, and Subword Embeddings easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Course source for distributional semantics, co-occurrence matrices, cosine similarity, and Word2Vec skip-gram framing.
Open sourceCourse source for negative sampling, GloVe, analogy structure, and word-vector evaluation caveats.
Open sourceBook source for vector semantics, distributional similarity, embeddings, Word2Vec, and GloVe context.
Open sourcePrimary source for CBOW and skip-gram architectures for learning continuous word representations from local context.
Open sourcePrimary source for negative sampling, subsampling frequent words, phrase vectors, and analogy behavior in Word2Vec-style embeddings.
Open sourcePrimary source for the GloVe weighted least-squares objective over log global co-occurrence counts.
Open sourceClaim Review
See how context windows, global co-occurrence counts, and character n-grams shape word vectors, and why nearest-neighbor semantics can mislead.
Claims without a substantive review badge still need exact source-support review.
cs224n-2019-word-vectors-1, cs224n-2019-word-vectors-2, jurafsky-martin-slp3-vector-semantics, mikolov-2013-efficient-word-representations, mikolov-2013-distributed-representations-phrases, pennington-2014-glove
Use equations, runnable code, and demos to check whether the source support is operational.
CS224N and Mikolov et al. support CBOW/skip-gram framing and efficient objectives; the second Mikolov paper supports negative sampling and analogy behavior; D2L supports center/context/negative-example construction for implementation.
Sources: CS224N Lecture Notes Part I: Word Vectors I, CS224N Lecture Notes Part II: Word Vectors II, Efficient Estimation of Word Representations in Vector Space, Distributed Representations of Words and Phrases and their Compositionality, d2l-word2vecThe demo uses a two-dimensional hand-computable projection and one positive/negative update; real Word2Vec trains high-dimensional target and context matrices over large corpora.A bounded review summary is present; still check caveats and exact reference scope.Checked CS224N word-vector notes, Mikolov Word2Vec papers, and D2L Word2Vec data-preparation material for local context-prediction mechanics and negative-sampling scope.
Reviewer: codex-local-primary-source-audit; reviewed 2026-07-03Pennington et al. support the weighted log-co-occurrence objective; CS224N and SLP3 support the pedagogical connection between co-occurrence matrices, distributional similarity, and embedding geometry.
Sources: CS224N Lecture Notes Part II: Word Vectors II, Speech and Language Processing, Chapter 6: Vector Semantics and Embeddings, GloVe: Global Vectors for Word RepresentationThe demo uses a tiny count table and log-count target cells; it does not train a full GloVe model, tune the weighting function, or evaluate downstream quality.A bounded review summary is present; still check caveats and exact reference scope.Checked the GloVe paper, CS224N Word Vectors II, and SLP3 vector semantics for global co-occurrence objective support and log-count caveats.
Reviewer: codex-local-primary-source-audit; reviewed 2026-07-03Bojanowski et al. support character n-gram summation and rare/unseen word handling; SLP3 supports subword embeddings in the broader vector-semantics context.
Sources: bojanowski-2017-fasttext-subword, Speech and Language Processing, Chapter 6: Vector Semantics and EmbeddingsSubword composition captures morphology and spelling evidence, not guaranteed meaning; a composed vector can be plausible and still wrong for polysemy, idioms, names, or corpus bias.A bounded review summary is present; still check caveats and exact reference scope.Checked fastText subword paper and SLP3 vector semantics for character n-gram representation scope and caveats.
Reviewer: codex-local-primary-source-audit; reviewed 2026-07-03Source support candidates
course-notes 2025CS224N Lecture Notes Part I: Word Vectors ICourse source for distributional semantics, co-occurrence matrices, cosine similarity, and Word2Vec skip-gram framing.
course-notes 2025CS224N Lecture Notes Part II: Word Vectors IICourse source for negative sampling, GloVe, analogy structure, and word-vector evaluation caveats.
book 2026Speech and Language Processing, Chapter 6: Vector Semantics and EmbeddingsBook source for vector semantics, distributional similarity, embeddings, Word2Vec, and GloVe context.
paper 2013Efficient Estimation of Word Representations in Vector SpacePrimary source for CBOW and skip-gram architectures for learning continuous word representations from local context.
Practice Loop
Try the idea before it explains itself
See how context windows, global co-occurrence counts, and character n-grams shape word vectors, and why nearest-neighbor semantics can mislead.
Before touching the demo, predict one visible change that should happen in Word2Vec, GloVe, and Subword Embeddings.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
Word2Vec, GloVe, and Subword Embeddings
What is the smallest example that makes Word2Vec, GloVe, and Subword Embeddings click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Word2Vec, GloVe, and Subword Embeddings Selected item key: recorded for copy. Context: NLP & Speech Page anchor: recorded for copy. Open question: What is the smallest example that makes Word2Vec, GloVe, and Subword Embeddings click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/nlp-speech/word2vec-glove-subword-embeddings
concept:nlp-speech/word2vec-glove-subword-embeddings