Choosing an Embedding Model

📌 The MTEB Leaderboard

In a previous lesson, we learned how to evaluate LLMs using the Chatbot Arena. But how do you evaluate the AI models that generate Vector Embeddings? How do you know which model is the most accurate at mapping meaning?

Engineers use the MTEB (Massive Text Embedding Benchmark) leaderboard on HuggingFace. It ranks every embedding model in the world across hundreds of tasks (like clustering, retrieval, and summarization). If you are building a RAG pipeline, the MTEB leaderboard is the very first place you should look.

📌 Dimensionality (The Size of the Vector)

When you choose an embedding model, the most critical specification to look at is its Dimensionality. This simply means: "How many numbers are in the mathematical list used to describe this text?"

Diagram showing a massive 1536-number list compared to a tiny 384-number list
Diagram showing a massive 1536-number list compared to a tiny 384-number list
  • High Dimensionality (e.g., OpenAI's ada-002): Outputs a vector with exactly 1,536 dimensions. Because it uses 1,536 decimal numbers to describe a single chunk of text, it captures incredible semantic nuance. The downside? Storing millions of these massive vectors in a Vector Database is incredibly expensive and slow to search.
  • Low Dimensionality (e.g., open-source MiniLM): Outputs a vector with only 384 dimensions. This is 4x smaller! It is incredibly cheap to store and lightning-fast to search, but you lose a slight amount of semantic accuracy.

📌 The Engineering Trade-Off

If you are building a small RAG app for your personal notes, you can use OpenAI's massive 1536-d embeddings because storage costs won't matter.

However, if you are an enterprise AI Engineer tasked with indexing 5 million legal PDFs, using a 1536-d model will explode your AWS hosting costs. In the enterprise world, engineers almost always choose highly optimized, smaller open-source models (like 384d or 768d) to save thousands of dollars a month, accepting a tiny hit to search accuracy in exchange for massive speed and cost savings.

📌 The Future: Matryoshka Embeddings

Recently, a mathematical breakthrough called Matryoshka Representation Learning (MRL) has taken over the industry.

Diagram showing a Russian nesting doll where a large vector can be chopped in half without losing its core meaning
Diagram showing a Russian nesting doll where a large vector can be chopped in half without losing its core meaning

Named after Russian nesting dolls, an MRL embedding model packs all the most important semantic meaning into the very front of the mathematical list. This allows engineers to literally "chop off" the back half of a 1536-dimension vector, shrinking it down to 256 dimensions, without breaking the math! The truncated vector still retains over 90% of its original search accuracy, but costs a fraction of the price to store.