---
title: "Train 400x faster Static Embedding Models with Sentence Transformers"
description: "Static embedding models, which replace the attention-based encoder with a token embedding lookup plus mean pooling (an EmbeddingBag), can be trained with modern contrastive losses and Matryoshka Representation Learning to run 100x to 400x faster on CPU than models like all-mpnet-base-v2 and multilingual-e5-small, while keeping at least 85% of their benchmark quality."
url: "https://swe.quest/articles/train-400x-faster-static-embedding-models-with-sentence-transformers-9f174d4b1294477b"
canonical: "https://huggingface.co/blog/static-embeddings"
source: "Hugging Face"
published: "2025-01-15"
difficulty: "hard"
kind: "Research"
reading_minutes: 39
tags: ["model-training","machine-learning","search","python","performance"]
---

# Train 400x faster Static Embedding Models with Sentence Transformers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2025-01-15, 39 min read, Research. Original: [https://huggingface.co/blog/static-embeddings](https://huggingface.co/blog/static-embeddings)

## Summary

Static embedding models, which replace the attention-based encoder with a token embedding lookup plus mean pooling (an EmbeddingBag), can be trained with modern contrastive losses and Matryoshka Representation Learning to run 100x to 400x faster on CPU than models like all-mpnet-base-v2 and multilingual-e5-small, while keeping at least 85% of their benchmark quality. The recipe trains two 1024-dimensional models from randomly initialized weights using BERT tokenizers and Sentence Transformers' StaticEmbedding module: an English retrieval model trained on 13 QA datasets chosen to avoid overlap with BEIR, and a multilingual similarity model trained on parallel-sentence and positive-pair datasets. The post covers dataset selection, loss choice, training arguments, evaluators, NanoBEIR results on CPU and GPU, and Matryoshka truncation tradeoffs. The resulting models suit on-device, in-browser and edge workloads.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- text embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- contrastive learning
- PyTorch basics

## Keywords

Sentence Transformers, Static Embeddings, Matryoshka Representation Learning, Model2Vec, MTEB, NanoBEIR, EmbeddingBag

## Related posts

- [Train a Sentence Embedding Model with 1B Training Pairs](https://swe.quest/articles/train-a-sentence-embedding-model-with-1b-training-pairs-f0642783223f8c14.md): Hugging Face · 2021-10-25 · Hard · 6 min read · Model training, Machine learning, Vector search
  Sentence embedding models trained with a contrastive multiple-negatives ranking loss (InfoNCE) on up to 1 billion sentence pairs, using in-batch negatives, a scaled similarity (C≈20), and cosine vs. dot-product tradeoffs for clustering and ANN search.
- [🪆 Introduction to Matryoshka Embedding Models](https://swe.quest/articles/introduction-to-matryoshka-embedding-models-9d7f30d6250451ff.md): Hugging Face · 2024-02-23 · Medium · 10 min read · Machine learning, Model training, Vector search, Python
  Matryoshka embedding models are trained so that the most important information sits in the earliest dimensions, which lets embeddings be truncated (e.g., 768 down to 64) and still work well for retrieval and similarity.
- [Training and Finetuning Embedding Models with Sentence Transformers](https://swe.quest/articles/training-and-finetuning-embedding-models-with-sentence-transformers-d6dcb3eebe384143.md): Hugging Face · 2024-05-28 · Medium · 14 min read · Model training, Python, Machine learning, Search, Evaluation
  Sentence Transformers v3 trains and finetunes embedding models through a SentenceTransformerTrainer that combines Hugging Face datasets, a loss function, optional training arguments and evaluators.
- [Training and Finetuning Sparse Embedding Models with Sentence Transformers](https://swe.quest/articles/training-and-finetuning-sparse-embedding-models-with-sentence-transformers-bcdd540c54167ab1.md): Hugging Face · 2025-07-01 · Medium · 27 min read · Search, Model training, Python, RAG & retrieval
  Sentence Transformers' SparseEncoder API can train and finetune neural sparse embedding models such as SPLADE, inference-free SPLADE and Contrastive Sparse Representation (CSR).
- [Train and Fine-Tune Sentence Transformers Models](https://swe.quest/articles/train-and-fine-tune-sentence-transformers-models-49bc0c36b2cdc22e.md): Hugging Face · 2022-08-10 · Medium · 11 min read · Model training, Machine learning, Python, Search
  Sentence Transformers models map text to fixed-size embeddings by running a pre-trained Transformer and pooling its token embeddings, and training them depends on matching the dataset format to the right loss.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
