LearnThatStack Ace your next interview
Embeddings & Vector Databases · question
Question 1 of 56

What is an embedding, and why are embeddings useful for search applications?

beginner
← All Embeddings & Vector Databases questions
Re-explain

An embedding is a vector, a list of numbers that a model produces from a piece of content. The model places similar meanings close together in that space, so the distance between two vectors stands in for similarity of meaning. A typical text model returns a few hundred to a few thousand numbers per input.

curl https://api.openai.com/v1/embeddings \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "text-embedding-3-small", "input": "How do I reset my password?"}'
# -> {"data": [{"embedding": [0.021, -0.043, 0.017, ...]}]}

For search, you embed each document once at write time and store the vector. You embed the query the same way, then return the closest document vectors. Wording no longer has to match, so a query about resetting a password can retrieve "recover account access". Keep the original text beside each vector, because the search hands back ids and scores, and your app needs the text itself.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for Embeddings & Vector Databases One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. An embedding is a vector, a list of numbers a model produces from a piece of content, and the model puts similar meanings close together.
  2. So the distance between two vectors stands in for similarity of meaning. A typical text model gives you a few hundred to a few thousand numbers per input.
  3. For search, I embed each document once when it's written and store that vector.
  4. At query time I embed the query the same way and return the documents whose vectors are closest.
  5. The win is that wording no longer has to match, so a query about resetting a password can pull up text about recovering account access.
  6. One catch is that the search only hands back ids and scores, so I keep the original text stored beside each vector for the app to use.

Weak answers to avoid

  • Stops at "it's a vector of numbers" That's the format, not the point. Say the model puts similar meanings close together, so distance between vectors measures similarity of meaning.
  • Embeds the whole corpus at query time You embed documents once at write time and store the vectors. Only the query gets embedded per search, otherwise every search pays to embed the whole corpus.
  • Never says the query goes through the same model Distances only mean something between vectors from the same model. Say you embed the query exactly the way you embedded the documents.
  • Assumes the vector index returns the text Vector search hands back ids and scores. A strong answer keeps the original text beside each vector so the app can show it.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Embeddings & Vector Databases cheatsheet.

← Back to all Embeddings & Vector Databases questions
Pro · $10/mo

49 of 56 Embeddings & Vector Databases answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime