What matters in AI.

Subscribe

Learn / AI basics

Definition · AI basics

Embedding model

An embedding model is a neural network that changes text into a fixed-length list of numbers. This list is a vector, or embedding. Texts with almost the same meaning get vectors near each other. Search tools and retrieval-augmented generation use embedding models to find related text by meaning, not by the same words.

Last reviewed

Key points

  • An embedding model gives one vector of fixed length for each text, for example 384, 1,536 or 3,072 numbers.
  • Vectors from two different embedding models are not compatible. A new model must make new vectors for all documents.
  • No single embedding model is best at all tasks, as the MTEB benchmark found in 2022.
  • An embedding model is part of the supply chain. Researchers put a backdoor in one in 2022.

How it works: from text to one vector

  1. A neural network, such as a transformer, reads the tokens of a text.
  2. The model gives one fixed-length vector for the full text.
  3. Software compares two vectors with a score, usually cosine similarity.

In contrastive training, the model sees pairs of related texts. It moves each pair near each other and moves unrelated texts apart.

One embedding model makes vectors for the documents and for the question.
One embedding model makes vectors for the documents and for the question.

Why it matters

The embedding model decides what retrieval augmented generation finds. Three points for security teams:

  • One model for each index. A vector database cannot mix vectors from two models.
  • A supply chain item. A backdoor in the model can send chosen inputs to an attacker target.
  • Vectors hold data. Stored vectors can leak data about their text, as the embedding page shows.

In practice: the security research

  • Not compatible. Jha and colleagues (2025) write that different models make “completely different and incompatible vector spaces”.
  • Backdoor. BadCSE (Chen and colleagues, 2022) put a backdoor in sentence embedding models. Inputs with the secret pattern went to the target vector of the attacker 97.70% of the time. Usual use stayed good.
  • Translation of vectors. The vec2vec method translates unknown vectors into a known space with no paired data. For some model pairs, it got information about as many as 80% of 50 test emails.

In practice: three example models

Specifications as the publishers give them. OpenAI data read on 22 October 2026.

Model Vector dimension Max input Access
all-MiniLM-L6-v2 384 256 word pieces Open weights, Apache-2.0
text-embedding-3-small 1,536 8,192 tokens OpenAI API, about 62,500 pages for each dollar
text-embedding-3-large 3,072 8,192 tokens OpenAI API, about 9,615 pages for each dollar

The OpenAI data is from its documentation, read on 22 October 2026. OpenAI counts a page as about 800 tokens. Its third-generation models have no knowledge of “events that occurred after September 2021”.

all-MiniLM-L6-v2 cuts off text longer than 256 word pieces. It learned with a contrastive objective on more than 1 billion sentence pairs.

The MTEB benchmark compares embedding models. The 2022 paper covers 8 task types, 58 datasets and 112 languages. Its primary result: “no particular text embedding method dominates across all tasks.”

Trade-offs: 3 selections to make

1. Bi-encoder or cross-encoder. A bi-encoder is an embedding model: it gives each text its own vector. A cross-encoder reads the query and the document together and gives only a score. The Sentence Transformers documentation says cross-encoders are more accurate but slower.

Task Bi-encoder Cross-encoder
Find the two nearest of 10,000 sentences about 5 seconds about 65 hours
Gives a vector to keep yes no

The 10,000 sentence numbers come from the Sentence-BERT paper (2019). The documentation suggests the two together. The bi-encoder finds the top 100 hits, and the cross-encoder gives them a new sequence.

2. Large vectors or small vectors. Each number in a vector is more data to keep for each document. Matryoshka Representation Learning (2022) trains a model to put information at different granularities in one vector. OpenAI says its 3-large vectors, cut to 256 numbers, continue to score better than full ada-002 vectors on MTEB.

3. Hosted API or open weights. A hosted API sends each document to the provider. An open-weight model runs on your own servers, but you must examine where the weights came from.

Questions and answers

What is the difference between an embedding and an embedding model?

An embedding model is the neural network. An embedding is its output, a fixed list of numbers for one piece of text. Two different embedding models give two vectors for the same text. These two vectors cannot be compared, because each model has its own vector space.

Can a RAG system change its embedding model and keep the vectors it has?

Not in the usual procedure. Jha and colleagues (2025) write that different models make "completely different and incompatible vector spaces". Thus the new model must make new vectors for the documents. Their vec2vec method can translate between spaces, but it is a research method.

Which embedding model is the best?

No single model. The MTEB benchmark of 2022 tested 33 models on 8 task types. No method was best at all of them. Test some models on your own documents and questions. Compare vector dimension, input length, license and price.

Sources

  1. Sentence-BERT: Sentence Embeddings using Siamese BERT-NetworksarXiv (Reimers and Gurevych, EMNLP 2019), 27 Aug 2019
  2. Cross-Encoders, Sentence Transformers documentationSentence Transformers (SBERT.net)
  3. Text and Code Embeddings by Contrastive Pre-TrainingarXiv (Neelakantan et al., OpenAI), 24 Jan 2022
  4. sentence-transformers/all-MiniLM-L6-v2 model cardHugging Face (Sentence Transformers)
  5. Vector embeddings (OpenAI API documentation)OpenAI
  6. Matryoshka Representation LearningarXiv (Kusupati et al., NeurIPS 2022), 26 May 2022
  7. MTEB: Massive Text Embedding BenchmarkarXiv (Muennighoff et al., EACL 2023), 13 Oct 2022
  8. Harnessing the Universal Geometry of EmbeddingsarXiv (Jha, Zhang, Shmatikov and Morris), 18 May 2025
  9. Apple of Sodom: Hidden Backdoors in Superior Sentence Embeddings via Contrastive LearningarXiv (Chen et al.), 20 Oct 2022

In the news