▶ Interactive Lab

Embedding Similarity (2D)

Place words in 2D embedding space; compute cosine similarity.

Drag a word with mouse or touch, or use the coordinate controls.

What you're seeing

These coordinates are invented, not embeddings from a language model or a dimensionality-reduction algorithm. Real embedding dimensions vary by model. A two-dimensional projection need not preserve the original cosine similarities.

Cosine similarity measures angle between nonzero vectors from the central origin, not the distance between their endpoints. Moving a word along the same ray preserves its cosine similarity. At the origin its norm is zero and cosine is undefined; such pairs are excluded rather than assigned a misleading score.

★ KEY TAKEAWAY
Cosine similarity = dot product of unit vectors = cosine of angle. Foundation of semantic search.
▶ WHAT TO TRY
  • Drag word vectors closer/farther.
  • Watch top-5 similar pairs change.
  • Normalizing makes magnitude irrelevant; only direction matters.

Angles, not endpoint distance

Each named point defines a vector from the central crosshair. The names are memorable labels only: their coordinates were chosen by hand, and moving king does not retrain a language model. The drawing ranks all defined pairwise cosine similarities and displays the five largest, along with their values in the text output. Cosine is the dot product divided by the two vector lengths. Parallel vectors score one, perpendicular vectors score zero, and opposite vectors score minus one.

Use every input

Select Word to choose which point the coordinate controls edit. X coordinate is the horizontal displacement from the origin; Y coordinate is positive upward. Adjust either slider using a finger, mouse, or keyboard arrows. The adjacent outputs show the current values. You may also drag the named points directly with a mouse or touch; the selected word and coordinate values follow the drag. Reset to defaults restores all eight starting positions. This is an immediate geometry experiment, so it does not need an artificial timed animation to make an input affect the result.

Run three comparisons

Select king and set X coordinate to 100 and Y coordinate to 0. Set queen to X 200 and Y 0. Their cosine is one even though their endpoints are far apart. Move queen to X 0 and Y 100: the pair is perpendicular and no longer necessarily belongs in the top five. Move queen to X -100 and Y 0 to make it opposite to king. Finally set both queen coordinates to zero. Its cosine is undefined because its length is zero, and the text explicitly reports that exclusion. A missing pair in the top-five list is not a claim that its score is zero.

Avoid an interpretation trap

The green connections are ranking aids, not semantic relations inferred from a corpus. They show only five pairs, not all twenty-eight possible pairs. High-dimensional embedding systems may use cosine, Euclidean distance or an unnormalized dot product depending on training and retrieval conventions. A two-dimensional projection can distort angles, so these invented points cannot validate real semantic search quality. Evaluate actual retrieval with relevant documents, representative queries and a stated metric; use this lab to understand the geometry behind one possible scoring rule.

Views are my own and do not represent any employer, past or present.