LLM Learning Hub

workspace/llm-course/home

Vector Index

A vector index is the data structure (e.g., HNSW, IVF, PQ) used inside a vector database to organise vectors for sub-linear-time approximate nearest-neighbour search.

What is Vector Index?

A vector index is the data structure (e.g., HNSW, IVF, PQ) used inside a vector database to organise vectors for sub-linear-time approximate nearest-neighbour search.

A vector index is the data structure (e.g., HNSW, IVF, PQ) used inside a vector database to organise vectors for sub-linear-time approximate nearest-neighbour search.

Where is it used?

FAISS `IndexHNSWFlat` and `IndexIVFPQ`, Qdrant's HNSW, and Milvus's IVF_FLAT are common indexes; the index type trades recall, latency, and memory.

How to build it

Build `faiss.IndexHNSWFlat(d, 32)` with `efConstruction=40`, add vectors, set `index.hnsw.efSearch=64`, call `.search(q, k)`, and compare recall against a brute-force `IndexFlatL2`.