An "Embedding" is a dense, high-dimensional vector representation (\mathbb{R}^d) that captures semantic relationships in a continuous space. For Retrieval-Augmented Generation (RAG), the choice of embedding model and distance metric is as critical as the LLM itself.
The performance of your vector search depends on matching the search metric to the model's training objective.
Storing raw float32 vectors is memory-intensive (e.g., 1 million 1536-dim vectors take ~6GB). Databases use quantization to reduce this footprint:
int8). Reduces memory by 4x with minimal accuracy loss (~1-2%).Recent models (like OpenAI text-embedding-3-large or nomic-embed-text) are trained with Matryoshka Representation Learning. This allows you to truncate the vector dimensions (e.g., from 3072 down to 256) without a catastrophic loss in performance.
| Dimensions | MTEB Score (Retrieval) | Storage (1M vectors) |
|---|---|---|
| 3072 | 54.9 | 12.0 GB |
| 1024 | 54.1 | 4.0 GB |
| 256 | 52.0 | 1.0 GB |
Practical Rule: Use 256 or 512 dimensions for initial retrieval to save memory, then use the full vector (if needed) only for the top 50 results.
Concrete Tip: Always use a dedicated embedding model (e.g., BAAI/bge-m3 or nomic-embed-text) rather than trying to extract hidden states from a generative model like Llama. Generative models are optimized for prediction, not vector space alignment.
Cluster Hub: Agentic AI Hub: Cognitive Architectures, Orchestration, and Autonomous Systems (agentic-ai)