Practise Embeddings & Vector Databases one question at a time. Answer out loud or in writing, get graded, and see exactly what you missed.
What is an embedding, and why are embeddings useful for search applications?
An embedding is a vector, a list of numbers that a model produces from a piece of content. The model places similar meanings close together in that space, so the distance between two vectors stands in for similarity of meaning. A typical text model returns a few hundred to a few thousand numbers per input.
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": "How do I reset my password?"}'
# -> {"data": [{"embedding": [0.021, -0.043, 0.017, ...]}]}
For search, you embed each document once at write time and store the vector. You embed the query the same way, then return the closest document vectors. Wording no longer has to match, so a query about resetting a password can retrieve "recover account access". Keep the original text beside each vector, because the search hands back ids and scores, and your app needs the text itself.
Missed:
“So the way I think about it, the difference is whether a vector's length counts. Cosine only cares about direction, so two vectors pointing the same way score 1 however big they are. Dot product multiplies the lengths in, so if your documents have different norms, a long one that's only loosely related can outrank a short one that's spot on. Euclidean is just the distance between the two points, lower is better, and length affects that too. They give the same ranking once all the stored vectors have the same length, which in practice means you normalize everything to unit length at ingest. Then the dot product is literally the cosine, and for Euclidean, if you expand the squared distance you get two minus two times the dot product, so the closest point is also the one with the highest dot product.”
Knew itThey have it: correctly link magnitude to each metric's behavior and derive the unit-vector identity themselves. Worth adding: matching stored norms alone gives matching rank, since the query's own norm scales all candidates equally.
Missed: Doesn't mention that once document norms match, the query vector's own norm doesn't affect ranking since it scales every candidate equally.
Get your own answers graded
Sign up free. Your account comes with 50 credits for grading, and it remembers what you missed.
What it covers
All 56 questions
Embedding fundamentals
What embeddings are, how semantic search differs from keyword search, static vs contextual embeddings, dimensionality and uses beyond search.
- What is an embedding, and why are embeddings useful for search applications?
- How does semantic search with embeddings differ from keyword search like BM25?
- What does the dimensionality of an embedding mean, and what are the tradeoffs of higher-dimensional embeddings?
- Besides search, what else can embeddings be used for? Pro
- What is the difference between static word embeddings like Word2Vec and contextual embeddings? Pro
Similarity metrics and scores
Cosine, dot product and Euclidean distance, normalization pitfalls, and why raw similarity scores are not calibrated relevance.
- Compare cosine similarity, dot product, and Euclidean distance. When do they produce the same rankings?
- What normalization pitfalls arise with dot product versus cosine, and how does a model's training constrain your metric choice? Pro
- Why can't you use a fixed similarity score threshold to decide whether a result is relevant, and what should you do instead? Pro
Embedding models and training
The model landscape, contrastive training, query vs document encoding, Matryoshka and multimodal models, choosing and fine-tuning a model.
- What happens if you embed queries with a different model than the one used to embed your documents? Pro
- What are the main commercial and open-source embedding model options? Pro
- How are modern text embedding models trained? Explain contrastive learning at a high level. Pro
- What are Matryoshka embeddings and why are they useful? Pro
- Why do some embedding models require different handling for queries versus documents? Pro
- How do you choose an embedding model for a new project, and how much should you trust MTEB scores? Pro
- How do multimodal embeddings work, and what should you watch out for when using them? Pro
- When should you fine-tune an embedding model on your own data instead of using an off-the-shelf one? Pro
Chunking and document context
Why documents are chunked, how chunk size and overlap affect retrieval, and techniques that restore context lost at chunk boundaries.
ANN indexes
Exact vs approximate nearest neighbor search, how HNSW, IVF and DiskANN work, and tuning HNSW for recall under a latency budget.
- Explain k-nearest-neighbor search and the difference between exact and approximate nearest neighbor search.
- How does the HNSW algorithm work, and what do its main parameters control? Pro
- How does IVF indexing work, and how does it compare to HNSW? Pro
- How would you tune HNSW parameters to hit a recall target under a latency budget? Pro
- When would you use a disk-based ANN index like DiskANN, and how does it work? Pro
Quantization and memory
Estimating index memory and shrinking vectors with scalar, product and binary quantization, including rescoring to recover recall.
Choosing a vector database
What a vector database is, pgvector setup and trade-offs, dedicated engines, Elasticsearch/OpenSearch, and picking a stack under constraints.
- What is a vector database, and why can't you just use a regular relational database for similarity search?
- Walk me through setting up semantic search in Postgres with pgvector. Pro
- When would you choose pgvector over a dedicated vector database, and when would you not? Pro
- How would you compare the major vector databases, and what criteria would you use to choose one? Pro
- When does it make sense to use Elasticsearch or OpenSearch for vector search? Pro
- An enterprise needs vector search with strict data-residency compliance, 50 million vectors, complex metadata filters, and a two-person platform team. How do you choose the stack? Pro
Filtering, multitenancy and security
Metadata filtering, pre vs post filtering and selective-filter recall collapse, tenant isolation, and protecting embeddings from leaks.
- What is metadata filtering in vector search, and why is it important in real applications? Pro
- Explain pre-filtering versus post-filtering in vector search. Why is filtering hard for ANN indexes? Pro
- Your users apply highly selective metadata filters and ANN recall collapses. What is happening and how do you fix it? Pro
- How would you design multitenancy in a vector database? Pro
- How can embeddings leak sensitive data, and how would you secure a vector store? Pro
Hybrid search and reranking
Combining BM25 with dense retrieval, RRF and its tuning, sparse and late-interaction models, cross-encoder reranking and result diversity.
- What is the difference between a bi-encoder and a cross-encoder, and how do rerankers fit into a retrieval pipeline? Pro
- What is hybrid search, and why do production systems combine BM25 with dense retrieval? Pro
- How does Reciprocal Rank Fusion work, and why is it often preferred over score-based merging? Pro
- How do you handle near-duplicate results and result diversity in retrieval, for example with MMR? Pro
- Compare single-vector dense retrieval with learned sparse (SPLADE) and late-interaction (ColBERT) approaches. Pro
- Your hybrid search uses RRF but underperforms on your evaluation set. How would you tune fusion in a large-scale system? Pro
Retrieval evaluation and debugging
Measuring retrieval quality with recall@k, building an evaluation harness, and systematically debugging a production quality drop.
Production pipelines and scaling
Keeping embeddings in sync, large update pipelines, model migrations, index degradation over time, sharding, and controlling cost.
- How do you keep embeddings in sync when source documents change? Pro
- Your embedding provider deprecates your model. Walk me through a zero-downtime migration to a new embedding model. Pro
- How do you shard and scale a vector search system beyond a single node? Pro
- Walk me through the cost drivers of an embedding-based search system and how you would reduce them. Pro
- Design an embedding pipeline for a corpus of 100 million documents that receives continuous updates. Pro
- How does ANN index quality degrade over the lifetime of a heavily updated production system, and what practices counter it? Pro
More questions
All questions
Showing of 56What is an embedding, and why are embeddings useful for search applications?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
An embedding is a vector, a list of numbers that a model produces from a piece of content. The model places similar meanings close together in that space, so the distance between two vectors stands in for similarity of meaning. A typical text model returns a few hundred to a few thousand numbers per input.
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": "How do I reset my password?"}'
# -> {"data": [{"embedding": [0.021, -0.043, 0.017, ...]}]}
For search, you embed each document once at write time and store the vector. You embed the query the same way, then return the closest document vectors. Wording no longer has to match, so a query about resetting a password can retrieve "recover account access". Keep the original text beside each vector, because the search hands back ids and scores, and your app needs the text itself.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How does semantic search with embeddings differ from keyword search like BM25?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Keyword search like BM25 ranks documents by the words they share with the query, while semantic search ranks them by meaning. The keyword score counts how often the query's words appear in a document, and it favors rare words. Semantic search compares embeddings, vectors that capture meaning, so a query can match a passage that shares no words with it.
A search for "car won't start" can return "vehicle ignition failure": close in meaning, zero shared terms.
| Aspect | BM25 | Semantic |
|---|---|---|
| Matches on | shared words | meaning |
| Synonyms, paraphrase | misses them | handles them |
| Rare IDs, names, codes | strong | often weak |
| Per-query cost | cheap text scoring | embed the query first |
BM25 needs no model at query time. It indexes new words the moment you add them. An embedding model only knows the vocabulary it was trained on, so a fresh product code means little to it. Most production systems run both.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Compare cosine similarity, dot product, and Euclidean distance. When do they produce the same rankings?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
All three rank by closeness, but they differ in how they treat a vector's magnitude, its length. Cosine similarity looks only at the angle, dot product also rewards longer vectors, and Euclidean distance measures the straight-line gap.
| Metric | Formula | Uses length? | Best score |
|---|---|---|---|
| Cosine | a·b / (|a| |b|) |
no | highest |
| Dot product | a·b |
yes | highest |
| Euclidean (L2) | |a - b| |
yes | lowest |
They produce the same ranking when every stored vector has the same norm, which in practice means embeddings normalized to length 1. Then cosine equals the dot product, and this identity ties in the third:
|a - b|^2 = 2 - 2 * (a·b) # for unit vectors
Distance falls as the dot product rises, so the order matches.
Once the stored norms match, the query's own norm never changes the order, because it scales every candidate's dot product equally. If document norms vary, dot product can push a long, loosely related vector above a short, on-topic one.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a vector database, and why can't you just use a regular relational database for similarity search?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A vector database stores embeddings and returns the vectors closest to a query vector. It does this with an approximate nearest neighbor (ANN) index, which finds close vectors without scoring every row.
A relational database indexes for exact matches and ranges. A B-tree keeps values in one sorted order. Similarity has no such order, because closeness depends on every dimension at once. So plain SQL scores every row against the query.
-- no ordinary index helps: every row gets a distance
SELECT id FROM docs
ORDER BY embedding <-> :query_vector
LIMIT 10;
That is fine for 10,000 rows and painful for 10 million. A vector database adds the ANN index, metadata filters in the same query, and storage sized for large vectors. Extensions like pgvector bring those indexes into Postgres, which blurs the line.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What does the dimensionality of an embedding mean, and what are the tradeoffs of higher-dimensional embeddings?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The dimensionality of an embedding is how many numbers each vector holds. The model fixes it, so you rarely choose it yourself. No single number means anything on its own. Meaning comes from all the numbers together.
More dimensions give the model room to record finer distinctions, so quality usually improves. The gains shrink fast, while the costs grow in a straight line. Doubling the dimensions doubles storage and index memory, and roughly doubles the work per distance comparison. Stored as float32, each dimension takes 4 bytes:
- 384 dimensions: 1,536 bytes, about 1.5 GB per million vectors
- 1,536 dimensions: 6,144 bytes, about 6.1 GB
- 3,072 dimensions: 12,288 bytes, about 12.3 GB
A small, well-trained model often beats a weaker model with more dimensions. Judge models on your own data, not on dimension count.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain k-nearest-neighbor search and the difference between exact and approximate nearest neighbor search.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
k-nearest-neighbor search, or k-NN, takes a query vector and returns the k stored vectors closest to it under a distance metric. It ranks by closeness, it does not look for an exact match.
Exact search compares the query against every stored vector. It always returns the true top k, but the work grows linearly with the collection size.
scores = corpus @ query # touches every vector, every query
top_k = np.argsort(-scores)[:k]
Approximate nearest neighbor (ANN) search skips most of the collection by using an index built ahead of time. It is much faster, but it can miss some true neighbors.
| Aspect | Exact | Approximate |
|---|---|---|
| Result | always the true top k | usually close to it |
| Query cost | scales with collection size | roughly sub-linear |
| Extra memory | none | index structure |
| Tuning | nothing to tune | speed versus recall |
Exact search is fine for small collections. Once you reach millions of vectors, ANN is the practical default.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What happens if you embed queries with a different model than the one used to embed your documents?
Why do we chunk documents before embedding them, and what are typical chunking parameters?
What are the main commercial and open-source embedding model options?
What is metadata filtering in vector search, and why is it important in real applications?
How would you measure whether your vector search is returning good results? Explain recall@k.
Besides search, what else can embeddings be used for?
What is the difference between static word embeddings like Word2Vec and contextual embeddings?
What is cosine similarity, and why is it the most common metric for comparing embeddings?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Cosine similarity measures the angle between two vectors. It divides their dot product by the product of their lengths, producing a high score when the vectors point in similar directions.
It is common because direction often captures semantic information while vector magnitude may be unrelated to relevance. If all vectors are normalized to length one, cosine similarity and dot product produce the same ranking and can be computed efficiently.
Use the metric recommended for the embedding model. Some models are trained for dot product or Euclidean distance, and changing the metric can hurt quality. A high cosine score is not a universal proof of relevance, so select thresholds with labeled data.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How are modern text embedding models trained? Explain contrastive learning at a high level.
What is the difference between a bi-encoder and a cross-encoder, and how do rerankers fit into a retrieval pipeline?
What are Matryoshka embeddings and why are they useful?
How does the HNSW algorithm work, and what do its main parameters control?
How does IVF indexing work, and how does it compare to HNSW?
Explain product quantization, scalar quantization, and binary quantization. What are the memory and recall tradeoffs?
Walk me through setting up semantic search in Postgres with pgvector.
When would you choose pgvector over a dedicated vector database, and when would you not?
How would you compare the major vector databases, and what criteria would you use to choose one?
When does it make sense to use Elasticsearch or OpenSearch for vector search?
Explain pre-filtering versus post-filtering in vector search. Why is filtering hard for ANN indexes?
What is hybrid search, and why do production systems combine BM25 with dense retrieval?
How does Reciprocal Rank Fusion work, and why is it often preferred over score-based merging?
Why do some embedding models require different handling for queries versus documents?
How would you estimate the memory footprint of an HNSW index?
How do chunk size and overlap affect retrieval quality, and how do you choose them?
How do you keep embeddings in sync when source documents change?
How would you build an evaluation harness for retrieval quality?
How do you handle near-duplicate results and result diversity in retrieval, for example with MMR?
How do you choose an embedding model for a new project, and how much should you trust MTEB scores?
Your users apply highly selective metadata filters and ANN recall collapses. What is happening and how do you fix it?
Your embedding provider deprecates your model. Walk me through a zero-downtime migration to a new embedding model.
How do you shard and scale a vector search system beyond a single node?
Explain binary quantization with rescoring as used in modern vector search engines.
How do multimodal embeddings work, and what should you watch out for when using them?
What normalization pitfalls arise with dot product versus cosine, and how does a model's training constrain your metric choice?
How would you tune HNSW parameters to hit a recall target under a latency budget?
When would you use a disk-based ANN index like DiskANN, and how does it work?
Compare single-vector dense retrieval with learned sparse (SPLADE) and late-interaction (ColBERT) approaches.
Walk me through the cost drivers of an embedding-based search system and how you would reduce them.
How would you design multitenancy in a vector database?
Chunk embeddings lose surrounding document context. What techniques address this?
Design an embedding pipeline for a corpus of 100 million documents that receives continuous updates.
How does ANN index quality degrade over the lifetime of a heavily updated production system, and what practices counter it?
Why can't you use a fixed similarity score threshold to decide whether a result is relevant, and what should you do instead?
Retrieval quality has degraded in production but nothing obvious changed. How do you debug it systematically?
Your hybrid search uses RRF but underperforms on your evaluation set. How would you tune fusion in a large-scale system?
An enterprise needs vector search with strict data-residency compliance, 50 million vectors, complex metadata filters, and a two-person platform team. How do you choose the stack?
When should you fine-tune an embedding model on your own data instead of using an off-the-shelf one?
How can embeddings leak sensitive data, and how would you secure a vector store?
How do deletions work in HNSW-based indexes, and what problems do they cause over time?
How do you scale a vector search system to high query throughput?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Embeddings & Vector Databases in pictures.
A quick recap of Embeddings & Vector Databases in 42 short animated pictures, one idea at a time. About 10 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 37 pictures come with Pro.
Embeddings & Vector Databases cheatsheet
- Embeddings & similarity01
- Embedding models02
- ANN indexes03
- Vector databases04
- Memory & compression05
- Chunking06
- Filters & multitenancy07
- Hybrid search & reranking08
- Measure & debug retrieval09
- Production & scale10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 37 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in49 of 56 Embeddings & Vector Databases answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.