Embeddings & Vector Search

What embeddings are and how similarity is measured, the storage math, ANN indexes (HNSW, IVF, PQ) and their recall and latency knobs, pgvector vs dedicated vector databases, metadata filtering and re-embedding migrations.

Overview

Why this topic

Every RAG system, semantic cache, recommendation feed and duplicate detector is a nearest-neighbor search over embeddings. The questions that come up in design reviews are concrete: how many bytes does a vector cost, why did recall drop after we added a filter, what does ef_search do, and how do we change embedding models without a day of bad search.

Interview questions

  • Size a vector search tier for 50 million chunks at 1536 dimensions. What does it cost in memory and what would you do about it?
  • Explain HNSW parameters M, efConstruction and efSearch, and how you would tune them.
  • Compare HNSW, IVF and PQ. When would you pick each?
  • Your filtered vector queries return too few results or miss obvious matches. What is happening and how do you fix it?
  • You need to move from one embedding model to a better one. Plan the migration.
  • When is pgvector enough, and when do you need a dedicated vector database?

Sign up free to read the full topic

More Agentic AI topics

Start free on Cariara · Coding problems · System design studio