Demo

Embedding neighborhoods

Embeddings turn tokens or phrases into points. Nearby points are often used as a proxy for related meaning, and directions can carry rough relationships. This page uses a hand-built 2D toy dataset so the geometry is visible.

Toy space

Click a point to inspect its neighborhood.

hand-placed 2D coordinates
not model output
Nearest neighbors

What is closest to king?

Distance is ordinary 2D Euclidean distance here. Real embedding search commonly uses cosine or dot-product similarity in a much higher-dimensional space.

  1. 1. princed=11.0

    royal term aligned near man

  2. 2. monarchd=15.2

    close to king and queen because it names the shared role

  3. 3. crownd=17.5

    near royalty because it is part of the same concept neighborhood

  4. 4. warrantyd=18.4

    adjacent business concept, not identical to refund

  5. 5. return policyd=27.6

    business rule phrase related to refund decisions

Vector direction

Directions can encode a relationship.

The classic intuition is king - man + woman. In this toy space, that arithmetic lands near queen because the points were arranged to make the relationship legible.

Result

Predicted point: (63, 59). Expected neighbor: queen. Distance: 0.0.

Take the royalty direction from man to king, then apply it to woman.

man
king
woman
queen
predicted = queen