Embeddings: Turning Documents Into Searchable Vectors
See how whole documents and questions become vectors on one shared map of meaning.
Track 2 showed embeddings for single tokens: a word becomes a vector whose direction encodes its meaning. Meaning search needs the same thing for whole sentences, paragraphs and documents. That is the job of an embedding model.
An embedding model is a cousin of the LLMs you know: a transformer that reads a whole passage, but instead of predicting the next token it outputs one vector summarising what the passage is about. Typical sizes are a few hundred to a few thousand numbers. It is trained on huge numbers of matching pairs, such as questions and their answers or titles and their articles, nudged so that matching pairs end up close together and unrelated ones far apart.
Using one has two halves:
- Ahead of time, every document (or piece of one) is embedded once, and the vectors are stored.
- At question time, the question is embedded with the same model, and lands on the same map, near the documents that discuss the same thing.
That “same model” rule matters. Vectors from two different embedding models live in different maps, like coordinates from two different atlases, and comparing them is meaningless. Switch models and you must re-embed everything.
Embeddings also tell you when there’s no good answer. If even the closest document is only weakly similar, your collection probably doesn’t cover the question, and a good system says so rather than handing the model something irrelevant.
Key takeaways
- An embedding model turns a whole passage into one vector that captures what it is about.
- Documents are embedded once ahead of time; questions are embedded at search time.
- Questions and documents must be embedded with the same model to be comparable.
- Low similarity to everything is a useful signal that the answer isn’t in your documents.
Check your understanding
Go deeper (more technical)
Sentence-embedding models were popularised by Sentence-BERT (2019). Today they are often trained with contrastive learning: in each batch, every question should be closer to its own answer than to all the other answers. Public leaderboards such as MTEB compare embedding models across many retrieval tasks.
Common vector sizes are 384, 768, 1,024, 1,536 or 3,072 numbers. Bigger vectors can capture more nuance but take more storage and search time; some models let you shorten the vector with a small loss in quality.
The simulation’s map is a hand-made 2-D illustration.