Skip to content

Vector Databases Ann

PART 16 — Vector Databases & ANN

To find the documents for RAG, we don't scan all 1 million vectors (O(N) time). We use an ANN (Approximate Nearest Neighbor) index, usually an HNSW Graph.

Example (HNSW Graph Traversal): Think of it like an Express Train network. 1. Top Layer (Express): Has only 10 nodes (broad categories). We start here. We find the node "E-commerce Policies". 2. Drop Down: We move down a layer to the nodes connected to "E-commerce Policies". 3. Bottom Layer (Local): We traverse locally to find the exact vector for "Refund Policy". Result: We found the nearest vector in O(log N) steps instead of O(N).