Visualizers

Learn by moving things

Interactive explainers for the ideas behind retrieval, embeddings, and agents. A formula tells you what is true; dragging a vector shows you why. Each one also appears inside the article it belongs to, and runs entirely in your browser, so drag, poke, and break it.

Portrait of Sachin Gupta rendered in binary

k-nearest-neighbor search

From: Vector Search (kNN)

Documents become points; the query is one more point. Drag it, pick k, and toggle euclidean vs cosine to watch the nearest neighbors change, and to see the two metrics disagree.

k4
query
k nearest so far

Press Step or Run to scan the points one at a time.

Checked 0 of 28. kNN must measure the distance to every point before it can be sure of the true nearest.

How approximate nearest neighbor actually runs. Drag the query and step the greedy walk from the entry node through a navigable graph; it visits a handful of nodes instead of all of them, and sometimes settles on a near-miss.

0 hops
entryquery
Greedy hop from the entry node toward the query. The dashed ring is the true nearest. It visits a handful of nodes, not all 34, which is the whole point, and can settle on a near-miss.
Visualizers — Sachin Gupta