This patch celebrates the transition of Sentence Transformers to Hugging Face, and improves model saving, loading defaults, and loss compatibilities.
Install this version with
# Training + Inference
pip install sentence-transformers[train]==5.1.2
# Inference only, use one of:
pip install sentence-transformers==5.1.2
pip install sentence-transformers[onnx-gpu]==5.1.2
pip install sentence-transformers[onnx]==5.1.2
pip install sentence-transformers[openvino]==5.1.2
Sentence Transformers is joining Hugging Face!
Today, Sentence Transformers is moving from the Ubiquitous Knowledge Processing (UKP) Lab at Technische Universität Darmstadt to Hugging Face. This formalizes the existing maintenance structure, as Tom Aarsen (that's me!) from Hugging Face has been maintaining the project for the past two years. The project's development roadmap, license, support, and commitment to the community remain unchanged. Read the full announcement for more details!

Minor changes re. saving and loading
- Improve saving models with StaticEmbedding (#3524) and Dense (#3528) modules.
- Fix training with CPU when "stronger" devices (CUDA, MPS) are available (#3525)
- Default to 'xpu' device over 'cpu' if the former is available (#3537)
Minor changes re. losses
- Change errors/warnings for MatryoshkaLoss to prevent easy-to-make mistakes, e.g. forgetting to use the original dimension (#3530)
- Introduce compatibility between MSELoss and MatryoshkaLoss (#3538)
- Also use mini-batches for positives with MegaBatchMarginLoss (#3550)
All Changes
- fix: static model saving fails because weights are not contiguous by @stephantul in #3524
- bug: fix state bug in trainer by @stephantul in #3525
- [
fix
] Patch Router training with Cached losses by @tomaarsen in #3527 - [
fix
] Allow loading Dense modules not saved in fp32 by @tomaarsen in #3528 - [
tests
] Patch Regex expected output for Python 3.9 by @tomaarsen in #3529 - Future-proof tests for upcoming transformers version by @tomaarsen in #3533
- feat: matryoshka dims bounds checks and warning by @stephantul in #3530
- Performance table format and Few markdownlint error correction by @kaushikacharya in #3534
- fix typos: inaccuracte -> inaccurate by @whybe-choi in #3542
- [
fix
] correct dataset link in training scripts by @thomasht86 in #3543 - [
fix
] Allow MatryoshkaLoss with MSELoss by @tomaarsen in #3538 - [
docs
] Format all markdown using mdformat by @tomaarsen in #3539 - feat: provide support for python 3.13 by @lordoffreaks in #3551
- Update MTEB docs to v2 by @KennethEnevoldsen in #3548
- Add support for Intel 'xpu' device in environment.py by @domschl in #3537
- docs: Update project metadata by @tomaarsen in #3553
- MegaBatchMarginLoss use mini batches for positives too by @benHeid in #3550
New Contributors
- @kaushikacharya made their first contribution in #3534
- @whybe-choi made their first contribution in #3542
- @thomasht86 made their first contribution in #3543
- @lordoffreaks made their first contribution in #3551
- @KennethEnevoldsen made their first contribution in #3548
- @domschl made their first contribution in #3537
- @benHeid made their first contribution in #3550
Full Changelog: v5.1.1...v5.1.2