Mid-level interview question
Your vector database only supports dot-product search, but your embedding model's documentation says to compare vectors with cosine similarity. What do you do, and why does it work?
Model answer
Normalize every vector, documents and queries alike, to length 1. Cosine is the dot product divided by both lengths, so on unit vectors the two are the same number.
Without that, the dot product also rewards length, so a long document can outrank a closer short one. Verify rather than assume: for the lesson's sentences, MiniLM's vectors were 4.86 to 6.46 long until its final normalize step.
Practise the rest
17 Embeddings questions, 492 in all, each with a model answer. Free.
More Embeddings interview questions
- What is an embedding table, and what does it mean for two embeddings to be similar?
- People say 'embedding' for three different things. What are they, and why does the difference matter?
- You're building search over medicine leaflets with a small English embedding model, and you plan to reply 'no answer found' whenever the top cosine score is below 0.5. What risks do you raise before this ships?
- Your team switches to a newer embedding model with the same 384 dimensions and starts embedding incoming queries with it. Search quality collapses, but nothing errors. Explain what happened and how you'd run the migration.
- Embedding models return 1,536 or 3,072 numbers per text. What do those sizes mean?
- An input embedding table is too large for one device. Compare sharding it by vocabulary with sharding it by hidden dimension.