Question presented to candidate:
"You keep hearing that our search and our RAG feature run on embeddings. Explain what an embedding actually is, how one gets made, and what kinds of product features you can build with them."
What a strong answer should cover:
An embedding is a fixed-length list of numbers (a dense vector) produced by an embedding model, arranged so that texts with similar meaning get vectors that point in similar directions
It is produced by a dedicated encoder model trained (usually contrastively) on pairs of related and unrelated texts, not by the chat model generating tokens; documents are embedded once at index time, the query at request time
Similarity becomes arithmetic (cosine or dot product), which powers semantic search and RAG retrieval, deduplication, clustering, classification by nearest labelled example, recommendations and anomaly detection
Embeddings find meaning without shared words, but they miss exact identifiers (error codes, SKUs, names), which is why keyword search is often combined with them
Vectors from different models (or versions) live in different spaces and cannot be compared; switching model means re-embedding everything, so the model name and version are stored with the index
Code / implementation expected: Optional โ embedding a few sentences and ranking them by cosine similarity, or explaining that call, is enough.
embeddings
vectors
semantic-search
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers who keep hearing "it runs on embeddings" (search, RAG, recommendations) and want to know what an embedding actually is before building with one.
Difficulty: Easy
Verified with: Node 22.22.0 and Python 3.12.3 (the toy embedding program below; its 6-number word vectors are hand-written stand-ins for a learned model). Product facts are cited inline with the date they were checked (October 2026).
How to read this doc: Every idea is explained in plain language first, then tagged with ๐ Interview term: so you also learn the words an interviewer expects. All program output shown was produced by actually running the example; the Verified section quotes it in full.
1. Why This Even Matters โ A Story First
Picture a huge library with no catalogue. A librarian decides to give every book a position on a giant map: cookbooks in the north-east,
The solution is hidden so you can try first
15 min read ยท 11 sections
4
Read the code
Toy embedding model: semantic search, dedup, classification and the model-mismatch trap