Embedding Similarity Playground

Same direction. Different winner.

Edit a query and three candidate vectors. Watch magnitude change dot-product rankings, then normalize the geometry.

Edit all inputs ↓

Explore the mechanism

Change the assumptions

Query Q
Candidate A
Candidate B
Candidate C

Live result

A geometric neighborhood

Scroll the diagram sideways. Exact values appear below.

These are synthetic 2D vectors, not learned language embeddings. Position has no assigned semantic meaning. Cosine and unit normalization are undefined for the zero vector; undefined comparisons are excluded from those rankings.

The explanation

Three metrics ask different questions.

Dot product rewards alignment and magnitude together. Cosine divides magnitude away. Euclidean distance measures the straight-line gap between endpoints. Those are different objectives until vectors are normalized. [E1]

In the default example, Q=(1,0). A=(2,1) wins dot product with 2. B=(0.8,0) wins cosine with 1 and distance with 0.2. B points in exactly the query direction even though A has greater magnitude.

Normalize every nonzero vector and dot product becomes cosine. Squared Euclidean distance then equals 2−2cosine, so all three rankings agree, with distance sorted in the opposite numerical direction. [E2]

A zero vector has no direction. Libraries choose different practical conventions; this teaching model marks cosine and normalization undefined. No diagram here pretends that a two-dimensional location is the meaning of a real sentence.

(Q·X)/(||Q||*||X||), for nonzero vectors

Open Asset Factory

Take the explanation with you.

Three independent diagrams. Editable source and high-resolution PNGs, with assumptions printed on the image.

Sources checked 2026-09-07

Claims you can inspect.

Formula derivations and teaching assumptions are documented separately.

Download claim ledger
E1 · Cosine is normalized dot product

The scikit-learn cosine similarity definition divides dot product by the two L2 norms; it equals the linear kernel on L2-normalized data.

Primary source ↗

This demo uses mathematical undefined for zero vectors rather than the library’s zero-fill convention.

E2 · Unit normalization removes magnitude

L2 normalization rescales each nonzero vector to unit norm.

Primary source ↗

Magnitude may contain useful information in a real model; normalization is not universally appropriate.

Quantization LabLoRA Rank and Adapter AnatomyGPU vs NPU vs TPU vs CPU