Vector Indexes (ANN) Questions with Answers

19 practice questions on Vector Indexes (ANN) (AI Engineering (LLM Apps)) with answers and step-by-step solutions. Try 10 samples below, then practise all 19 free in the AptiNest app.

Sample questions

Question 1Easy

pgvector is:

  1. A Python library that trains new embedding models from scratch on your data
  2. A file format for storing vectors on disk
  3. An extension that adds vector types and similarity search to PostgreSQL
  4. A cloud service for GPU rentals

Answer: C. An extension that adds vector types and similarity search to PostgreSQL

Explanation

It lets teams keep vectors next to relational data and query them with SQL.

Step-by-step solution

  1. Pgvector is an extension for PostgreSQL.
  2. It adds a vector column type and similarity search.
  3. Teams can keep embeddings next to relational data and query them with SQL.
  4. So option C, an extension that adds vector types and similarity search to PostgreSQL, is correct.

Why the other options are wrong

  • A. Pgvector stores and searches vectors; it does not train embedding models.
  • B. Pgvector is not a file format for vectors on disk.
  • D. Pgvector is not a GPU rental or cloud service.

Tip: Pgvector means vectors inside PostgreSQL.

Question 2Easy

Which similarity metric should a vector index be configured with?

  1. The one the embedding model was trained for
  2. Whichever metric is fastest, regardless of the model
  3. Manhattan distance, since it suits every embedding
  4. A different metric for queries than for documents

Answer: A. The one the embedding model was trained for

Explanation

Embedding models are trained with a particular similarity (often cosine or dot product); using another can degrade ranking.

Step-by-step solution

  1. Embedding models use specific similarity metrics like cosine or dot product.
  2. Changing the metric may reduce model effectiveness.
  3. Using the training metric ensures best results.
  4. So, choose the metric the embedding model was trained for.
  5. Final answer: The one the embedding model was trained for.

Why the other options are wrong

  • B. The fastest metric may not match how the vectors were trained, so search quality can get worse.
  • C. Manhattan distance does not suit every embedding; most models are trained for cosine or dot product.
  • D. Queries and documents must use the same metric, or their scores cannot be compared fairly.

Tip: Match metric with model training for best performance.

Question 3Easy

Which is an example of a dedicated open-source ANN library rather than a database?

  1. FAISS
  2. Redis Streams
  3. PostgreSQL
  4. Apache Kafka

Answer: A. FAISS

Explanation

FAISS is a library of index types (flat, IVF, PQ, HNSW); databases add storage, filtering and APIs around such indexes.

Step-by-step solution

  1. FAISS is an open-source library of index types such as flat, IVF, PQ and HNSW.
  2. A library provides index code; a database adds storage, filtering and APIs around it.
  3. Redis Streams, PostgreSQL and Apache Kafka are not ANN libraries.
  4. So option A, FAISS, is the dedicated ANN library.

Why the other options are wrong

  • B. Redis Streams is a stream feature inside Redis, not an ANN library.
  • C. PostgreSQL is a database, not an ANN library.
  • D. Apache Kafka is a messaging system, not an ANN library.

Tip: A library is index code; a database is storage plus queries around it.

Question 4Medium

Applying a strict metadata filter (for example tenant_id = 42) after ANN search can return too few results because:

  1. ANN indexes cannot store any metadata alongside the vectors at all
  2. Most of the top candidates may be filtered out afterwards
  3. Filters change the embedding of the query
  4. Metadata filters always crash vector indexes

Answer: B. Most of the top candidates may be filtered out afterwards

Explanation

Post-filtering discards candidates after retrieval; pre-filtering or filter-aware search avoids empty results.

Step-by-step solution

  1. Post-filtering applies after top-k.
  2. Many top results may belong to other tenants.
  3. Few remain.

Why the other options are wrong

  • A. ANN can store metadata.
  • C. Filters don't change embeddings.
  • D. They don't crash.

Question 5Medium

Deleting vectors from an HNSW graph is often handled by:

  1. Deleting the whole index each time
  2. Marking them deleted and rebuilding or compacting later
  3. Re-embedding every remaining document after each single deletion
  4. Shrinking the embedding dimension

Answer: B. Marking them deleted and rebuilding or compacting later

Explanation

Removing graph nodes in place can hurt connectivity, so many systems use tombstones plus periodic rebuilds.

Step-by-step solution

  1. HNSW graphs link nodes; removing one breaks paths.
  2. Common practice is to mark vectors as deleted.
  3. Rebuild or compact periodically.

Why the other options are wrong

  • A. Deleting the index each time is wasteful.
  • C. Re-embedding is unnecessary.
  • D. Dimension is unrelated.

Question 6Medium

Locality-sensitive hashing (LSH) for vector search relies on:

  1. Exact comparison of the query against every single stored vector in the whole collection
  2. Hash functions that put similar vectors in the same bucket with high probability
  3. Sorting vectors by their L2 norm
  4. Cryptographic hashes that never collide

Answer: B. Hash functions that put similar vectors in the same bucket with high probability

Explanation

LSH deliberately makes close vectors collide, so only matching buckets are scanned.

Step-by-step solution

  1. LSH uses hash functions designed so that similar vectors tend to fall in the same bucket.
  2. A query only compares against vectors in matching buckets.
  3. This avoids comparing the query with every stored vector.
  4. So option B, hash functions that put similar vectors in the same bucket, is correct.

Why the other options are wrong

  • A. Exact comparison with every vector is brute force, which LSH is designed to avoid.
  • C. Sorting by L2 norm is not what LSH relies on.
  • D. Cryptographic hashes avoid collisions, the opposite of what LSH needs.

Tip: In LSH, close vectors collide on purpose, so only matching buckets are scanned.

Question 7Medium

Recall@10 of an ANN index (compared with exact search) is 0.95. This means:

  1. 10% of results are wrong 95% of the time
  2. On average 95% of the true top-10 neighbours are returned
  3. The index uses 95% less memory than an exact brute-force search would
  4. 95% of queries take under 10 milliseconds

Answer: B. On average 95% of the true top-10 neighbours are returned

Explanation

ANN recall measures overlap with the exact top-k.

Step-by-step solution

  1. Recall@10 compares the approximate index results with the exact top 10.
  2. Recall 0.95 means about 95 of every 100 true neighbours are returned, on average.
  3. Recall measures overlap in results, not speed or memory.
  4. So option B is correct.

Why the other options are wrong

  • A. Recall 0.95 means about 5% of true neighbours are missed, not 10% of results being wrong.
  • C. Memory use is not what recall measures.
  • D. Query latency is not what recall measures.

Tip: Recall@k is the share of the exact top-k that the approximate index finds.

Question 8Medium

An IVF index has nlist = 1,000 clusters of roughly equal size, and queries use nprobe = 10. About what fraction of vectors does each query scan?

  1. 0.1%
  2. 1%
  3. 100%
  4. 10%

Answer: B. 1%

Explanation

10 of 1,000 lists are scanned: 10/1000 = 1% of the vectors, assuming balanced clusters.

Step-by-step solution

  1. nprobe = 10 means 10 clusters are checked.
  2. Total clusters = 1,000 so fraction scanned is 10/1000.
  3. 10 divided by 1000 equals 0.01.
  4. Convert to percentage: 0.01 * 100 = 1%.
  5. Each query scans about 1% of the vectors.

Why the other options are wrong

  • A. 0.1% would need nprobe of 1 out of 1,000; with 10 probes the fraction is 10 out of 1,000, which is 1%.
  • C. 100% would mean a full scan; nprobe of 10 out of 1,000 clusters only checks about 1% of vectors.
  • D. 10% would need 100 probes out of 1,000; with nprobe 10 the fraction is 10 out of 1,000, so 1%.

Tip: Use nprobe / total clusters * 100 for quick percentage calculation.

Question 9Hard

Vector search over a corpus that grows by 1% per day uses IVF with centroids trained once at launch. After a year, quality drops. The most likely cause is:

  1. nprobe automatically resets to 1 over time
  2. IVF indexes are designed to expire automatically 365 days after they were first built
  3. Embeddings lose precision as they age
  4. The data distribution drifted, leaving clusters unbalanced; retrain centroids

Answer: D. The data distribution drifted, leaving clusters unbalanced; retrain centroids

Explanation

Centroids fitted on old data no longer partition new data well, so lists become skewed and recall falls.

Step-by-step solution

  1. Centroids are trained once at launch.
  2. New data grows by 1% daily.
  3. Old centroids fail to capture new data distribution.
  4. Clusters become unbalanced with time.
  5. Recall drops due to poor partitioning of new data.
  6. The data distribution drifted, leaving clusters unbalanced; retrain centroids.

Why the other options are wrong

  • A. nprobe is a query setting that stays fixed unless someone changes it; it does not reset itself over time.
  • B. IVF indexes have no built-in expiry; nothing deletes them after 365 days.
  • C. Embeddings do not lose precision with age; the problem is that the old centroids no longer fit the data.

Tip: Retrain models when data evolves to maintain accuracy.

Question 10Hard

Two HNSW configurations on the same data give: A recall@10 0.99 at 9 ms, B recall@10 0.93 at 2 ms. The app's SLA is p95 under 5 ms. Which is the right next step?

  1. Lower embedding dimension to 2 and retest
  2. Switch to brute force for guaranteed recall
  3. Choose B and tune ef upward until latency nears the SLA
  4. Choose A, because recall always matters more than any latency SLA

Answer: C. Choose B and tune ef upward until latency nears the SLA

Explanation

A breaks the latency budget; raising ef on B buys recall while staying under 5 ms.

Step-by-step solution

  1. A misses the SLA (9 ms > 5 ms).
  2. B meets latency but has lower recall.
  3. Increase ef gradually to trade latency for recall.

Why the other options are wrong

  • A. Dimension 2 destroys quality.
  • B. Brute force is slower.
  • D. SLA is a requirement.

Practise all 19 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all AI Engineering (LLM Apps) topics · All topics