Robots Atlas>ROBOTS ATLAS
Retrieval

Embedding model

2019ActivePublished: 16 October 2026Updated: 16 October 2026Published
Key innovation
Carving out a dedicated class of models whose sole job is to map an input to a dense vector in a shared space where geometric distance reflects semantic similarity — enabling search and comparison by meaning rather than keyword matching.
Category
Retrieval
Abstraction level
Building block
Operation level
ModelDataRetrieval
Use cases
Semantic searchRetrieval-augmented generation (RAG)Text classificationClusteringRecommendation systemsDeduplication and near-duplicate detectionMultimodal (text-image) search

How it works

1) The input is tokenized and passed through an encoder (usually a Transformer) that produces contextual token vectors. 2) A pooling layer (mean pooling, CLS pooling or last-token pooling) aggregates those vectors into a single fixed-length vector. 3) The vector is optionally projected and L2-normalized so that cosine similarity equals the dot product. 4) The model is trained contrastively on pairs/triplets (positives pulled together, negatives pushed apart), often with hard negatives and query/document distinguishing prefixes. At inference, queries and documents are encoded into vectors and search becomes nearest-neighbor retrieval (ANN) in a vector database.

Problem solved

Classic lexical search (keyword matching) fails to capture synonyms, paraphrases or meaning and is hard to transfer across modalities. Embedding models solve this by mapping heterogeneous data into a shared vector space where proximity means semantic similarity, enabling fast, scalable comparison, retrieval and grouping by meaning.

Components

EncoderTransforms input tokens into contextual vector representations.

Usually a Transformer encoder (e.g. BERT) producing a context-aware vector for each token across the whole sequence.

INBatch of input tokens.
OUTContextual token vectors.

Official

Pooling layerReduces the sequence of token vectors into a single fixed-length vector.

Typically mean pooling (attention-masked average), CLS-token pooling or last-token pooling.

INContextual token vectors.
OUTSingle embedding vector.
Mean poolingAttention-masked average of token vectors.
CLS poolingUsing the [CLS] token vector as the sequence representation.
Last-token poolingUsing the last-token vector (common for decoder-style encoders).

Official

Normalization / projectionReduces cosine similarity to a dot product; optionally projects to a smaller dimension.

L2 normalization of the output vector, sometimes with an extra linear layer or Matryoshka (MRL) support for dimension truncation.

Official

Contrastive training objectiveShapes the vector space so similar pairs are close and dissimilar pairs far apart.

Usually an InfoNCE or triplet loss with hard negatives; often multi-stage (contrastive pre-training plus supervised pair fine-tuning).

Official

Implementation

Implementation pitfalls
Not normalizing before cosine similarityMedium

If vectors are not L2-normalized, the dot product does not equal cosine similarity, which skews ranking.

Fix:L2-normalize the vectors or use the cosine metric in the vector database.
Omitting query/document prefixes or instructionsHigh

Many models (E5, BGE, EmbeddingGemma) require distinct query vs document prefixes; omitting them degrades retrieval quality.

Fix:Apply the exact prefixes/instructions as specified in the model card.
Truncating Matryoshka dimensions without re-normalizingMedium

After truncating a vector to a smaller dimension (MRL) it must be re-normalized, otherwise similarities are distorted.

Fix:Re-normalize the vector after truncating the dimension.
Mismatched pooling strategyMedium

Using CLS pooling for a model trained with mean pooling (or vice versa) yields poor representations.

Fix:Use the pooling that matches the model's training configuration.

Evolution

Original paper · 2019 · EMNLP 2019 · Nils Reimers
Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Nils Reimers, Iryna Gurevych
2013
Word2Vec
Inflection point

Mikolov et al. introduce efficient learning of dense, distributed word representations via a dedicated network model.

2014
GloVe

Pennington, Socher and Manning (Stanford) propose global word vectors based on co-occurrence statistics.

2019
Sentence-BERT
Inflection point

A siamese BERT model with pooling produces comparable sentence vectors, making semantic comparison fast and scalable.

2022
E5

Microsoft introduces general text embeddings via weakly-supervised contrastive pre-training.

2023
BGE (C-Pack)

BAAI releases open embedding resources and models (BGE) reaching top retrieval-benchmark results.

2024
OpenAI text-embedding-3

OpenAI ships text-embedding-3-small (1536-dim) and -large (3072-dim) with support for shortening the dimension.

2025
Google EmbeddingGemma

An open, multilingual (100+ languages) ~308M-parameter embedding model, 768-dim with Matryoshka (512/256/128) and a 2048-token context, optimized for on-device use.

Hyperparameters (configurable axes)

Embedding dimensionCritical

Length of the output vector; trades off quality, memory cost and search speed. Matryoshka models allow truncating the dimension.

384
768
1536
3072
Maximum context lengthHigh

Maximum number of input tokens the model can encode into a single vector.

512
2048
8192
Pooling strategyHigh

How token vectors are aggregated into one vector (mean, CLS, last-token).

Similarity metricMedium

Measure used to compare vectors; most often cosine similarity or dot product.

Computational complexity

Time complexity: O(n^2 * d). Space complexity: O(n^2 + n * d).

Execution paradigm

Primary mode
Dense

The encoder activates all parameters for every input; no sparse routing (unlike MoE).

Activation pattern
All paths active

Parallelism

Parallelism level
Fully parallel

A Transformer encoder processes all tokens in parallel; encoding many documents is embarrassingly parallel.

Scope
TrainingInferenceAcross tokens

Hardware requirements

Primary

The Transformer encoder's dense matrix multiplications and large-corpus encoding benefit from tensor cores.

Good fit

Small models (e.g. all-MiniLM, EmbeddingGemma) encode single queries with acceptable latency on CPU, including on-device/edge.