Hugging Face released two new static embedding models that run 100‑to‑400‑times faster on CPUs than popular state‑of‑the‑art models while keeping at least 85 % of their performance. The models, sentence‑transformers/static‑retrieval‑mrl‑en‑v1 for English retrieval and sentence‑transformers/static‑similarity‑mrl‑multilingual‑v1 for multilingual similarity, are trained with contrastive learning and optional Matryoshka Representation Learning to keep speed gains with minimal quality loss.
This blog post introduces a method to train static embedding models that run 100x to 400x faster on CPU than state-of-the-art embedding models, while retaining most of the quality. This unlocks a lot of exciting use cases, including on-device and in-browser execution, edge computing, low power and embedded applications.
We apply this recipe to train two extremely efficient embedding models: sentence-transformers/static-retrieval-mrl-en-v1 for English Retrieval, and sentence-transformers/static-similarity-mrl-multilingual-v1 for Multilingual Similarity tasks. These models are 100x to 400x faster on CPU than common counterparts like all-mpnet-base-v2 and multilingual-e5-small , while reaching at least 85% of their performance on various benchmarks.
We also discuss potential enhancements, and encourage the community to explore them and build on this work!
Static Embeddings refers to a group of Encoder models that don't use large and slow attention-based models, but instead rely on pre-computed token embeddings. Static embeddings were used years before the transformer architecture was developed. Common examples include GLoVe and word2vec . Recently, Model2Vec has been used to convert pre-trained embedding models into Static Embedding models.
We can initialize it in a few ways: StaticEmbedding.from_model2vec to load a Model2Vec model , StaticEmbedding.from_distillation to perform Model2Vec-style distillation, or initializing it with a Tokenizer and an embedding dimension to get random weights.
Alongside dozens of Sentence Transformer models, the Sentence Transformers organization on Hugging Face also hosts 70+ datasets (at the time of writing):
GISTEmbedLoss (GIST) : This is also an extension of MNRL, it uses a guide Sentence Transformer model to remove potential false negatives from the list of options that the model must "pick" the correct positive from.
This has a large amount of use cases, and serves as the backbone for recommendation systems, retrieval, outlier detection, one-shot or few-shot learning, similarity search, clustering, paraphrase detection, classification, and much more.
Within Sentence Transformers, your loss model must match your training data format. The Loss Overview is designed as an overview of which losses are compatible with which formats.
The usage of these models is very straightforward, identical to the normal Sentence Transformers flow:
Embeddings are one of the most versatile tools in natural language processing, enabling practitioners to solve a large variety of tasks. In essence, an embedding is a numerical representation of a more complex object, like text, images, audio, etc.
The embedding model will always produce embeddings of the same fixed size. You can then compute the similarity of complex objects by computing the similarity of the respective embeddings.
Train 400x faster Static Embedding Models with Sentence Transformers. Covered by Hugging Face on January 15, 2025.