Start with the interactive overview above to build the mental model. Then continue below into the existing detailed explanations, visualizers, calculations, experiments, and lesson links. The original material has been preserved.
Embeddings: The Scholar's Memory Drawers of Pure Meaning
Tokens give the Wise Scholar a numbered index catalog. Embeddings are the velvet drawers behind each number. When the scholar reads token #4127 ("cat"), opening drawer #4127 yields 4,096 continuous coordinates encoding feline traits, softness, pets, and biology. Years of reading have organized these drawers so that pulling the vector difference $\vec{\text{King}} - \vec{\text{Man}} + \vec{\text{Woman}}$ lands the scholar's hand directly at drawer $\vec{\text{Queen}}$!
๐ค Layman Curiosity Hook
"How does an AI model understand that 'king' is related to 'queen' in the exact same way that 'man' is related to 'woman'? Where does that conceptual intelligence of analogies actually live?"
We know vectors are just rows of coordinate floats. But how do floating-point values align themselves so perfectly that they capture complex linguistic concepts and cultural relationships?
๐ก This is how it happens: Through the magic of the Embedding Matrix! Pretraining forces the weights of token vectors to shift based on how words co-occur, aligning their coordinates so perfectly that you can literally do algebra on ideas: 'king' - 'man' + 'woman' = 'queen'! Conceptual meaning is transformed into relative geometric vector alignments.
๐ World-Class Embedding Visualizer Hub
Interactive 3D Embedding Spaces & Concept Arithmetic
Explore live high-dimensional vector spaces, see Word2Vec neuron firing in real-time, and run vector algebra (King - Man + Woman = Queen) on interactive visualizers.
๐ช TensorFlow Embedding Projector
3D PCA, UMAP, and t-SNE projection of 10,000+ words with neighbor isolation and cosine distance spheres.
In-House Live Vector Arithmetic & Embedding Matrix Simulator
Interactive In-Page Tool
Perform algebraic vector operations directly on learned token representations. Pick an equation or build your own to see how word vectors combine across continuous dimensions and discover the nearest semantic neighbor!
๐ Behind-the-Scenes: Step-by-Step Mathematical TraceClick to expand / collapse
Step 1 (Token ID Lookup): The token IDs are looked up in the embedding matrix $W_e \in \mathbb{R}^{V \times d}$. Each row is retrieved as a $d$-dimensional coordinate vector.
Step 2 (Vector Subtraction): $\vec{v}_{\text{diff}} = \vec{v}_A - \vec{v}_B$. This operation isolates the conceptual difference vector (e.g. subtracting "man" from "king" removes the male gender component, leaving pure "royalty").
Step 3 (Vector Addition): $\vec{v}_{\text{target}} = \vec{v}_{\text{diff}} + \vec{v}_C$. Adding "woman" combines the royalty vector with the female gender coordinates.
Step 4 (Nearest Neighbor Search): Cosine similarity is computed between $\vec{v}_{\text{target}}$ and every vector in vocabulary. The closest row in space is selected as the answer (e.g., "queen").
โ What does "close" mean in embedding space?
Close means two vectors point in a similar direction, or sit near each other. The model has learned that those two tokens are used in similar ways, so it treats them as similar in meaning.
Cosine similarity โ the angle between the vectors. Close = value near 1.
Euclidean distance โ the straight-line gap between the points. Close = small number.
Dot product โ direction and length together. Close = large number.
king and queen end up close because they appear in similar contexts; cat and carburetor end up far apart. Close means "used in similar ways", which is not always "means the same" โ opposites like hot and cold can end up close. A static embedding gives bank one position for both meanings; a contextual embedding moves it nearer to money or nearer to river, depending on the sentence.
One dimension on its own has no human-readable meaning. Closeness only makes sense when you compare whole vectors.