Vector DBs & RAG (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is the difference between Exact k-Nearest Neighbors (kNN) and Approximate Nearest Neighbors (ANN)?
junior LevelHTTP & REST APIs
In Simple Words:
- Exact kNN (Brute Force / Flat): Compares the query vector against every single stored vector in the dataset. Provides 100% recall, but has O(N * D) time complexity. Unusable for millions of vectors in interactive apps.
- Approximate Nearest Neighbors (ANN): Uses graph or clustering data structures (HNSW, IVFFlat) to search only a tiny candidate fraction. Trades a negligible ~1-3% accuracy drop for 100x to 1000x faster search speeds (O(log N) latency).