AI Engineering · LLM applications that ship

How do embeddings and similarity search work?

Mediumembeddingssemantic searchvectorsUpdated Oct 2026
Quiz this track

Short answer

An embedding model maps text to a vector so semantically similar text lands close together. Retrieval ranks chunks by vector similarity, which captures meaning but not exact keywords or freshness.

Embeddings turn text into fixed-length vectors trained so that related meaning produces related directions. At ingest you embed every chunk. At query time you embed the question and search for the nearest chunk vectors using cosine similarity or dot product, depending on how the index was built.

  • Use the same embedding model for documents and queries, at the same version.
  • Semantic similarity misses exact identifiers, error codes and rare names that keyword search handles well.
  • Re-embedding the whole corpus is required when you change models, so version the index alongside the model.
  • Similarity is not relevance: a close vector can still fail to answer the question.
Normalise vectors when the index expects unit length, and confirm whether the store uses cosine, inner product or Euclidean distance. Mixing conventions produces quietly bad rankings.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1When would keyword search beat embeddings?
  2. 2How do you migrate to a new embedding model without downtime?
  3. 3What would you check if retrieval quality suddenly dropped?

Say it in the interview

Embeddings represent meaning as vectors, so retrieval finds passages that are semantically close to the question even when the words differ. The trade-off is that exact codes, names and identifiers can be missed. I pair embeddings with keyword search and reranking for that reason. I also version the embedding model with the index, because a mismatch between document and query embeddings ruins the rankings.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live AI Engineering mock interview and get scored feedback on depth, clarity and confidence.