All lessons · 44
Path 3 · AI Engineer Roadmap·Lesson 12 of 33

Embedding Models and Providers

OpenAI, Cohere, Gemini, Jina, or open-source Sentence Transformers? Dimensions, cost, multilinguality — and a practical way to choose an embedding model.

LevelIntermediateTime~10 min

One idea, many models

An embedding is just a vector of numbers — but which numbers a text gets depends entirely on the model you embed it with. And there are many. They differ in quality, price, language coverage, vector size, and where they run. Picking one is one of the first real decisions in any semantic search or RAG project.

If you’re completely new here: an embedding is a list of numbers that stands in for the meaning of a text — coordinates on a map of meaning. Similar meanings, similar numbers. Read What Are Embeddings? first if that still feels like magic. It matters here because a bad model puts your texts in the wrong places, and no amount of clever code downstream fixes that.

The one rule

Embeddings are only comparable within a single model. Pick a model first, embed everything with it, and re-embed your whole collection if you ever switch. No mixing.

The main options

Model / provider Type Typical dimensions Price Multilingual
OpenAI text-embedding-3-small / -large API 1536 / 3072 low / moderate good
Cohere embed-v3 / embed-v4 API 1024 / up to 1536 moderate strong, 100+ languages
Gemini embedding (gemini-embedding-001) API 3072 (downsizeable) generous free tier strong
Jina embeddings v3 API 1024 moderate strong, long context
Sentence Transformers open source, local 384–1024 free, your hardware depends on the model

Two columns worth decoding:

  • Type. “API” means the model runs on the provider’s computers: you send your text over the internet and get numbers back — no setup, but your text leaves your infrastructure, and you pay per use. “Open source, local” means the model runs on your own machine: nothing leaves, no per-use bill, but you provide the hardware.
  • Dimensions. The only column that looks scary, and it isn’t: a dimension is just one number in the list. A 1024-dimensional embedding is a list of 1024 numbers describing one text. More numbers means more room for nuance; fewer numbers means less storage and faster search. Nothing else about your code changes — the model, not you, decides what the numbers mean.

A quick tour:

  • OpenAI Embeddings API is the default choice for many teams: two lines of code, solid quality, pay per token. The small model is cheap enough that re-embedding an entire knowledge base costs cents.
  • Cohere focuses on search and retrieval specifically, with strong multilingual support and dedicated modes for search, classification and reranking (taking a shortlist of candidate results and re-scoring them so the best ones float to the top).
  • Gemini Embedding offers top-tier quality with a generous free tier — great for prototypes and side projects.
  • Jina is a strong independent option, popular for long documents.
  • Sentence Transformers is an open-source Python library. Models run locally — your laptop or your server. No API bills, no data leaving your infrastructure, and for many classic tasks (short-text similarity, clustering) quality is entirely sufficient.

Same meaning, different languages

Here’s the property that makes multilingual embeddings special: the model was trained so that the same meaning lands in the same place, regardless of language. Hover around the map — each cluster holds one concept in four languages, and the query “merci” finds its cluster even though nothing in the data is French:

One meaning, four languages — one cluster
? merci
hover any item to see its closest neighbors — this is how semantic search finds related things
greetingfarewellgratitude

Try hovering “hello” and then “thank you”: the neighbors stay inside the cluster, in every language at once. That’s the whole feature in one picture.

This means a multilingual model lets you search an English knowledge base with a Russian query — or build one index for users in three countries. That alone is worth checking before anything else if your product is not English-only.

Check this first

If your content is not English, test the model on your actual languages before committing. Multilingual claims vary a lot in practice, and “supports 100 languages” rarely means “equally well”.

How to actually choose

Don’t overthink it — this is a two-hour decision, not a two-week one:

  1. Data sensitivity first. If text cannot leave your infrastructure, you’re already down to Sentence Transformers or a self-hosted model.
  2. Then languages. Non-English content? Shortlist Cohere, Gemini, Jina, or a multilingual open model — and test on your real data.
  3. Then cost at your scale. Estimate tokens: a 10k-document knowledge base embedded with a cheap API model is a rounding error. Huge corpora tip you toward local models.
  4. Then dimensions. Bigger vectors are slightly more expressive but cost more to store and search. For most projects 384–1536 is plenty.
  5. Finally, benchmark on your task. Take 20 real queries, embed your docs, eyeball the top results. Ten minutes of this beats any leaderboard.

And remember: the choice is reversible. Since switching models means re-embedding everything, wrap embedding in one function in your codebase — then the model is a config value, not an architectural commitment:

One function, one switch
# embed.py — the ONLY place that knows which model you use
MODEL = "text-embedding-3-small"

def embed(texts: list[str]) -> list[list[float]]:
  """Turn texts into vectors. Swap the provider here, nowhere else."""
  response = client.embeddings.create(model=MODEL, input=texts)
  return [item.embedding for item in response.data]

# Switching to a local model? Change the body, keep the signature:
#
# from sentence_transformers import SentenceTransformer
# _m = SentenceTransformer("all-MiniLM-L6-v2")
# def embed(texts): return _m.encode(texts).tolist()

Where the vectors then live — and how you search millions of them — is the next article. And the reason any of this is worth setting up is RAG: handing the right chunks to an LLM at the moment it needs them.

Check yourself

You are choosing an embedding model for a hospital: patient records may never leave the company network. What comes first?

You switch your project from OpenAI embeddings to an open-source model. What has to happen?

What does a multilingual embedding model give you?

What is a "dimension" of an embedding?