Skip to content

What is an embedding model and how does vector dimension affect search quality?

Beginner · 2 min read · RAG & Vector Databases

Open in study mode to save this question and track progress

Short answer: An embedding model converts unstructured text into dense numerical floating-point vectors (Rd\mathbb{R}^d) capturing semantic meaning; higher embedding dimensions (e.g. 1536 or 3072) store finer semantic granularity but increase vector database storage, memory, and indexing latency.

Detail

Embedding models place text chunks into an NN-dimensional semantic vector space where semantically similar concepts reside physically close to each other.

"Machine learning algorithm" ──► Embedder ──► [0.012, -0.045, 0.891, ... 1536 Dimensions]
"Artificial intelligence code" ──► Embedder ──► [0.015, -0.041, 0.885, ... 1536 Dimensions]

Dimensionality Trade-Offs

Vector Dimensions (dd)Semantic CapacityStorage / RAM per 1M VectorsQuery LatencyTypical Model Examples
384 / 512Moderate~1.5 GBUltra-fastall-MiniLM-L6-v2, bge-small-en
768 / 1024High~3.0 - 4.0 GBFastbge-large-en-v1.5, gte-large
1536 / 3072Very High~6.0 - 12.0 GBModerateOpenAI text-embedding-3-small / large

Matryoshka Representation Learning (MRL)

Modern embedding models support Matryoshka embeddings, allowing developers to truncate 1536-dim vectors down to 256 dimensions with <2%<2\% drop in retrieval accuracy.

Example

Truncating Matryoshka embeddings in Python:

python
import numpy as np

# Simulate a 1536-dimensional L2-normalized vector
full_vector = np.random.randn(1536)
full_vector /= np.linalg.norm(full_vector)

# Truncate to 256 dimensions and re-normalize
truncated_vector = full_vector[:256]
truncated_vector /= np.linalg.norm(truncated_vector)

print("Original Dim:", len(full_vector), "| Truncated Dim:", len(truncated_vector))

Interview tips

  • Explain memory math: 1 million 1536-dim vectors in FP32 require 1,000,000×1536×4 bytes≈6.14 GB1,000,000 \times 1536 \times 4\text{ bytes} \approx 6.14\text{ GB} of raw VRAM/RAM.
  • Discuss scalar quantization (SQ8 / SQ4) to compress vector RAM requirements by 4×4\times.

Related Concepts


⬅ Back to RAG and Vector Databases · All topics