Embedding Models: Architecture, Pooling & Selection › Summary
Language AI HandbookAll chapters Embedding Models: Architecture, Pooling & Selection › SummaryOne section · Sections in this chapter11 / 12 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
This chapter covered the architecture and design decisions that make embedding models work for retrieval in RAG systems:
-
Embedding models are transformer encoders fine-tuned with contrastive objectives to produce semantically meaningful sentence and passage vectors. The key challenge they solve is distilling a sequence of token-level hidden states into a single vector that captures the overall meaning of the text. Standard pre-trained models like BERT do not do this well without further fine-tuning.
-
Pooling strategies determine how token embeddings are compressed into a single vector. Mean pooling is the most common and effective strategy for encoder models, computing a mask-weighted average of all token hidden states. CLS pooling uses only the first token's hidden state, which is effective after proper contrastive fine-tuning. Last token pooling is the natural choice for decoder-based embedding models where causal attention makes the last position the best-informed one. The pooling strategy must match what the model was trained with.
-
The worked example showed that mean pooling is a simple masked average followed by L2 normalization. The entire operation is differentiable, allowing training to shape the hidden states so they aggregate into a useful representation. The normalization step places all embeddings on the unit hypersphere, simplifying cosine similarity to a dot product at retrieval time.
-
Embedding dimensionality involves a trade-off between representational capacity and computational cost. Most production systems use 384 to 1024 dimensions. Matryoshka representation learning enables flexible dimensionality from a single model by training the loss jointly at multiple truncation lengths, forcing the model to pack the most important semantic content into the earliest dimensions.
-
Model selection should be guided by retrieval performance on your specific data, language requirements, context length needs, and inference cost constraints. MTEB benchmarks provide a useful starting point but should always be supplemented by evaluation on representative samples of your actual domain.
-
Normalization to unit length simplifies cosine similarity to a dot product, letting faster search and compatibility with standard vector index implementations. The geometric intuition is that normalization projects all embeddings onto the surface of a unit hypersphere, so similarity is purely a function of the angle between vectors.
-
Embedding models have important limitations: the information bottleneck from pooling, domain mismatch for specialized content, embedding drift when upgrading models, and inherited biases from training data. Designing RAG systems that account for these limitations, particularly through reranking and domain-specific evaluation, is needed for production deployments.
With embeddings in hand, the next step in a RAG pipeline is storing them in a way that enables fast similarity search. The upcoming chapters on vector similarity search, HNSW, and IVF indices will show how to search over millions of vectors efficiently without resorting to brute-force comparison.