Flashcard: what is an embedding in a RAG pipeline, and what role does it play?
An embedding is a fixed-length vector that places text at a point in high dimensional space, so semantic similarity becomes vector distance.
Imagine every sentence in the world gets a numeric address, like coordinates on a giant map. Sentences with similar meaning live close together, even when they use different words. 'Cancel my subscription' and 'how do I quit my plan' end up as next door neighbors, while 'best pasta recipes' lives in a completely different neighborhood. A special address maker computer reads each sentence and writes down its address. In RAG, you give every chunk of your documents an address ahead of time and store all the addresses. When a user asks something, you compute the address of their question, then look up which document chunks live nearest. You are no longer searching for matching words. You are searching for matching meaning, which is the whole reason RAG can answer paraphrased questions at all.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: define embedding as a vector address for meaning, walk through index-time and query-time encoding, name 2026-current models, and call out the same model and re-index rules.
Real products, models, and research that use this idea.
- OpenAI text-embedding-3-large producing 3072-dimensional vectors for RAG corpora over private documents and knowledge bases.
- Voyage Embed v3 asymmetric models offering separate query and document encoders tuned for retrieval, used inside Anthropic's RAG stack.
- Cohere Embed v4 multilingual embeddings powering retrieval across mixed language enterprise knowledge bases in production.
- pgvector storing OpenAI or Voyage embedding outputs in Postgres for teams that want retrieval without a dedicated vector database.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy must query embeddings and document embeddings come from the same model?
QHow would you decide between 1024-dim and 3072-dim embeddings for a million chunk corpus?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating an embedding as part of the LLM's weights. It is a separate artifact computed by a separate model and stored ahead of time, not something the chat model produces during generation.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.