Embedding
Also called embeddings
A vector of numbers that represents a token or a text, arranged so that similar meanings end up close together.
Interview questions about Embedding
- What is an embedding table, and what does it mean for two embeddings to be similar?
It's a learned matrix with one row per vocabulary entry, and embedding a token just reads its row.
- People say 'embedding' for three different things. What are they, and why does the difference matter?
Only the last two change with context: - Static token embedding: a table row, identical in every sentence: river "bank" and money "bank" score cosine exactly 1.
- 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?
Normalize every vector, documents and queries alike, to length 1.
- 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?
Three risks. First, similarity tracks topic, not truth: in our MiniLM data, "This medicine is safe for children." and its negation scored 0.936, far above the…
- 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.
Each model arranges its own space, so matching dimensions only means the dot product can be computed.
- Embedding models return 1,536 or 3,072 numbers per text. What do those sizes mean?
That's the vector's dimension: each text becomes a point with that many coordinates.
- An input embedding table is too large for one device. Compare sharding it by vocabulary with sharding it by hidden dimension.
By vocabulary, each device owns a range of rows, looks up the tokens it owns, writes zeros for the rest, and an all-reduce sum assembles full vectors.
- Your assistant's semantic search over user content is slow and expensive. How do you optimise it: embedding choice, ANN indexing and sharding?
Embeddings: shortlist models on public retrieval benchmarks, then pick on your own queries; smaller dimensions or int8 vectors cut memory and latency.