What is an embedding, and why do we use vector similarity instead of keyword matching to find related text?
technical-conceptual · Junior level · data-ml
What the interviewer is really asking
Assess whether the candidate understands that embeddings encode meaning as vectors and that similarity search captures semantic relatedness that exact keyword matching misses.
What to say
- Define an embedding: a model maps a piece of text (or an image, etc.) to a fixed-length vector of numbers that encodes its meaning, so that texts with similar meaning land close together in that vector space.
- Explain the similarity measure: you compare two embeddings with a distance/similarity metric — cosine similarity is the common one — and a small distance means the texts are semantically related, even if they share no words.
- Contrast with keyword matching: keyword search only matches on shared literal terms, so it misses paraphrases and synonyms ('car' vs 'automobile', 'how do I reset my password' vs 'forgot login credentials'); embeddings capture that semantic relatedness, which is what powers semantic search and RAG retrieval.
What to avoid
- Saying an embedding is just a hash or a unique ID for the text — it's a dense vector that places similar meanings near each other, the opposite of a hash that scatters similar inputs.
- Claiming embeddings make keyword search obsolete — exact-term matching still wins for codes, names, and rare tokens, which is why hybrid approaches exist.
- Confusing cosine similarity with simple word overlap — cosine compares the geometry of the vectors, not the shared tokens.
Example answers
Strong: For a semantic search feature I embedded every support article and the user's query with the same embedding model, then ranked articles by cosine similarity to the query vector. A question phrased as 'my card was declined' surfaced the 'payment failed' article even though they share almost no words, which keyword search never managed.
Weak: An embedding is basically a compressed or hashed version of the text so you can store it more cheaply.
Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.