Embedding
Also known as: vector embedding, text embedding
An embedding is a dense vector representation of text, an image or other content, positioned so that semantically similar items sit close together under a distance measure such as cosine similarity. Embeddings are what make semantic search, clustering and retrieval possible without exact keyword matches.
Last reviewed · Part of the Architecture Glossary
In practice
Operational properties that decide designs:
- Embeddings are model-specific. Vectors from two different models are not comparable, so changing the embedding model means re-embedding the entire corpus. Store the model name and version alongside every vector, or the migration becomes archaeology.
- Dimensionality is a cost. 1,536 dimensions at 4 bytes is 6 KB per vector; ten million chunks is 60 GB before the index structure. Matryoshka-style truncation and quantisation to int8 cut this substantially with modest recall loss.
- Asymmetry. Query text and document text have different shapes. Models trained for retrieval expect a query prefix and a document prefix; using the wrong one silently degrades recall.
- Similarity is not relevance. Cosine similarity finds text about the same topic, which includes the document that contradicts the answer you want. Reranking exists for this reason.
When it matters
Semantic search, RAG, deduplication, clustering support tickets, recommendation, and classification with a small labelled set.
Common mistake
Embedding whole documents. A 20-page PDF as one vector averages away everything specific in it, so it matches everything weakly and nothing strongly. Chunk first, and keep the parent document as metadata for context expansion at read time.
See also
- Vector Index (ANN)A vector index accelerates nearest-neighbour search over high-dimensional embeddings by trading exactness for speed.
- RAG (Retrieval-Augmented Generation)RAG is the pattern of retrieving relevant documents at query time and placing them in the model's context so the answer is grounded in your data rather than in the model's parameters.
- Context WindowThe context window is the maximum number of tokens a model can attend to in one request — system prompt, conversation history, retrieved documents, tool definitions, tool results and the response combined.