Update dependency sentence-transformers to v3.4.1#160
Closed
renovate[bot] wants to merge 1 commit intomasterfrom
Closed
Update dependency sentence-transformers to v3.4.1#160renovate[bot] wants to merge 1 commit intomasterfrom
renovate[bot] wants to merge 1 commit intomasterfrom
Conversation
thypon
previously approved these changes
Jun 6, 2025
fc090de to
abea65e
Compare
Contributor
Author
Renovate Ignore NotificationBecause you closed this PR without merging, Renovate will ignore this update ( If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==3.0.1->==3.4.1Release Notes
UKPLab/sentence-transformers (sentence-transformers)
v3.4.1: - Model2Vec compatibility & offline model fixCompare Source
This release introduces a convenient compatibility with Model2Vec models, and fixes a bug that caused an outgoing request even when using a local model.
Install this version with
Full Model2Vec integration
This release introduces support to load an efficient Model2Vec embedding model directly in Sentence Transformers:
Previously, loading a Model2Vec model required you to load a `StaticEmbedding` module.
Model2Vec was the inspiration of the recent Static Embedding work; all of these models can be used to approach the performance of normal transformer-based embedding models at a fraction of the latency. For example, both Model2Vec and Static Embedding models are ~25x faster than tiny embedding models on a GPU and ~400x faster than those models on a CPU.
Bug Fix
local_files_only=Truestill triggered a request to Hugging Face for the model card metadata; this has been resolved in (#3202).All Changes
StaticEmbedding.__init__by @altescy in https://github.com/UKPLab/sentence-transformers/pull/3196integration] Work towards full model2vec integration by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3182set_base_modelwhenlocal_files_only=Trueby @Davidyz in https://github.com/UKPLab/sentence-transformers/pull/3202New Contributors
Full Changelog: huggingface/sentence-transformers@v3.4.0...v3.4.1
v3.4.0: - Resolved memory leak when deleting a model & trainer; add Matryoshka & Cached loss compatibility; small features & bug fixesCompare Source
This release resolves a memory leak when deleting a model & trainer, adds compatibility between the Cached... losses and the Matryoshka loss modifier, resolves numerous bugs, and adds several small features.
Install this version with
Matryoshka & Cached loss compatibility (#3068, #3107)
It is now possible to combine the strong Cached losses (CachedMultipleNegativesRankingLoss, CachedGISTEmbedLoss, CachedMultipleNegativesSymmetricRankingLoss) with the Matryoshka loss modifier:
See for example tomaarsen/mpnet-base-gooaq-cmnrl-mrl which was trained with CachedMultipleNegativesRankingLoss (CMNRL) with the Matryoshka loss modifier (MRL).
Resolve memory leak when Model and Trainer are reinitialized (#3144)
Due to a circular dependency in the
SentenceTransformerTrainer->SentenceTransformer->SentenceTransformerModelCardData->SentenceTransformerTrainer, deleting the trainer and model still doesn't clear them up via garbage disposal. I've moved a lot of components around, and nowSentenceTransformerModelCardDatadoes not need to store theSentenceTransformerTrainer, breaking the cycle.We ran the seed optimization script (which frequently creates and deletes models and trainers):
16332MiB / 24576MiB
8222MiB / 24576MiB
Small Features
marginparameter to the TripletEvaluator in #2862.mine_hard_negativesin #2967.Notable Bug Fixes
no_duplicatesBatch Sampler (#3069). This has been resolved in #3073model.fit()training withwrite_csvon an evaluator would crash (#3062). This has been resolved in #3066.np.floatinstead offloat(#3075). This has been resolved in #3076 and #3096.revisionorcache_dirwhen loading a PEFT Adapter model (#3061). This has been resolved in #3079 and #3174.model.to(#3078). This has been resolved in #3104.kwargskeys were not saved inmodules.jsoncorrectly, e.g. relevant for jina-embeddings-v3 (#3111). This has been resolved in #3112.HfArgumentParser(SentenceTransformerTrainingArguments)would crash due topromptstyping (#3090). This has been resolved in #3178.Example Updates
Documentation Updates
All Changes
training] Passsteps/epoch/output_pathto Evaluator during training by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3066examples] Update the quantization script by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3070fix] Fix different batches per epoch in NoDuplicatesBatchSampler by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3073docs] Add links to backend-export in Speeding up Inference by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3071model_card] Keep the model card readable even with many datasets by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3088docs] Add NanoBEIR to the Training Overview evaluators by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3089docs] Update from Sphinx==3.5.4 to 8.1.3, recommonmark -> myst-parser by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3099docs] List 'prompts' as a key training argument by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3101enhancement] Make MultipleNegativesRankingLoss easier to understand by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3100fix] Fix breaking change in PyLate when loading modules by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3110typo] Add missing space between sentences in error message by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3125fix] Save custom modulekwargsif specified by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3112memory] Avoid storing trainer in ModelCardCallback and SentenceTransformerModelCardData by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3144docs] Update the Static Embedding example snippet by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3177fix] Use HfArgumentParser-compatible typing for prompts by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3178docs] Add PEFT documentation + training example by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3180tests] Make TripletEvaluator test more consistent by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3183deprecation] Clarify that datasets and readers are deprecated since v3 by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3184New Contributors
An explicit thanks to @JINO-ROHIT who has made a large amount of contributions in this release.
Full Changelog: huggingface/sentence-transformers@v3.3.1...v3.4.0
v3.3.1: - Patch private model loading without environment variableCompare Source
This patch release fixes a small issue with loading private models from Hugging Face using the
tokenargument.Install this version with
Details
If you're loading model under this scenario:
HF_TOKENenvironment variable viahuggingface-cli loginor some other approach.tokenargument toSentenceTransformerto load the model.Then you may have encountered a crash in v3.3.0. This should be resolved now.
All Changes
docs] Fix the prompt link to the training script by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3060Full Changelog: huggingface/sentence-transformers@v3.3.0...v3.3.1
v3.3.0: - Massive CPU speedup with OpenVINO int8 quantization; Training with Prompts for stronger models; NanoBEIR IR evaluation; PEFT compatibility; Transformers v4.46.0 compatibilityCompare Source
4x speedup for CPU with OpenVINO int8 static quantization, training with prompts for a free performance boost, convenient evaluation on NanoBEIR: a subset of a strong Information Retrieval benchmark, PEFT compatibility by easily adding/loading adapters, Transformers v4.46.0 compatibility, and Python 3.8 deprecation.
Install this version with:
OpenVINO int8 static quantization (https://github.com/UKPLab/sentence-transformers/pull/3025)
We introduce int8 static quantization using OpenVINO, a highly performant solution that outperforms all other current backends by a mile, at a minimal loss in performance. Here are the updated benchmarks:
Quantizing directly to the Hugging Face Hub
You can immediately use the model, even before it's merged, by using the
revisionargument:And once it's merged:
Quantizing locally
You can also quantize a model and save it locally:
And after quantizing, you can load it like so:
All original Sentence Transformer models already have these new
openvino_model_qint8_quantized.xmlfiles, so you can load them without exporting directly! I would recommend making pull requests for other models on Hugging Face that you'd like to see quantized.Learn more about how to Speed up Inference in the documentation: https://sbert.net/docs/sentence_transformer/usage/efficiency.html
Training with Prompts (https://github.com/UKPLab/sentence-transformers/pull/2964)
Many modern embedding models are trained with “instructions” or “prompts” following the INSTRUCTOR paper. These prompts are strings, prefixed to each text to be embedded, allowing the model to distinguish between different types of text.
For example, the mixedbread-ai/mxbai-embed-large-v1 model was trained with Represent this sentence for searching relevant passages: as the prompt for all queries. This prompt is stored in the model configuration under the prompt name "query", so users can specify that prompt_name in model.encode:
Various papers (INSTRUCTOR, BGE) show that including prompts or instructions both during training and inference results in stronger performance. As of this release, it's now possible to easily train with prompts in Sentence Transformers with just one extra training argument:
prompts. There are 4 accepted formats for it:str: A single prompt to use for all columns in all datasets. For example:Dict[str, str]: A dictionary mapping column names to prompts, applied to all datasets. For example:Dict[str, str]: A dictionary mapping dataset names to prompts. This should only be used if your training/evaluation/test datasets are aDatasetDictor a dictionary ofDataset. For example:Dict[str, Dict[str, str]]: A dictionary mapping dataset names to dictionaries mapping column names to prompts. This should only be used if your training/evaluation/test datasets are aDatasetDictor a dictionary ofDataset. For example:I've trained models with and without prompts for 2 base models: mpnet-base and bert-base-uncased:
For both base models, the model with prompts consistently outperformed the baseline model. After training, the models with prompts resulted in a 0.66% and 0.90% relative improvement on NDCG@10 at no extra cost.
mpnet-basetestsbert-base-uncasedtestsNanoBEIR Evaluator integration (https://github.com/UKPLab/sentence-transformers/pull/2966)
This update introduced a new simple
NanoBEIREvaluator, evaluating your model against NanoBEIR: a collection of subsets of the 13 BEIR datasets. BEIR corresponds to the retrieval tab of MTEB, and is commonly seen as a valuable indicator of general-purpose information retrieval performance.With the
NanoBEIREvaluator, you can easily evaluate your models on a much faster benchmark that should give similar insights in performance as BEIR. You can use it like so:Advanced Usage
You can also specify a subset of datasets, and you can specify query and/or corpus prompts, if your model uses them. For example:
NanoBEIREvaluatorPEFT compatibility (https://github.com/UKPLab/sentence-transformers/pull/3000, https://github.com/UKPLab/sentence-transformers/pull/2980, https://github.com/UKPLab/sentence-transformers/pull/3046)
Sentence Transformers has been integrated much more closely with PEFT. Notably, we introduce new methods:
These methods allow you to add new PEFT adapters or load pretrained ones, for example:
Adding a adapter
Loading a pretrained adapter
Given sentence-transformers-testing/stsb-bert-tiny-lora as a small adapter model (the
adapter_model.safetensorsfile is only 33.8kB!) on top of sentence-transformers-testing/stsb-bert-tiny-safetensors, you can either load this adapter directly:Or you can load the original model and load the adapter into it:
Transformers v4.46.0 compatibility (https://github.com/UKPLab/sentence-transformers/pull/3026, https://github.com/UKPLab/sentence-transformers/pull/3035, https://github.com/UKPLab/sentence-transformers/pull/3037, https://github.com/UKPLab/sentence-transformers/pull/3038)
The recent
transformersv4.46.0 update introduced a few changes that were incompatible with Sentence Transformers. For example:num_items_in_batchargument to thecompute_lossmethod in the TrainerValueErrorifeval_datasetis None whileeval_strategyis not"no"(this should be possible in Sentence Transformers, as we accept evaluating with just anevaluatoras well)These issues and deprecation warnings have been resolved.
Drop Python 3.8 support (https://github.com/UKPLab/sentence-transformers/pull/3033)
Given that Python 3.8 has now reached it's end of life, Sentence Transformers will no longer support it.
All Changes
peft] If AutoModel is wrapped with PEFT for prompt learning, then extend the attention mask by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3000integration] Add support for Transformers v4.46.0 by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3026datasetsmust be install to fit a model by @h4c5 in https://github.com/UKPLab/sentence-transformers/pull/3020feat] Integrate NanoBeIR datasets; usemodel.similarityby default in evaluators by @ArthurCamara in https://github.com/UKPLab/sentence-transformers/pull/2966fix] Avoid passing eval_dataset=None to transformers due to >=v4.46.0 crash by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3035docs] Update the dated example in the NanoBEIREvaluator by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3034deprecate] Drop Python 3.8 support due to EOL by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3033tests] Remove evaluation_steps from model.fit test without evaluator by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3037fix] Fix loading pre-exported OV/ONNX model if export=False by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3036chore] If Transformers 4.46.0, use processing_class instead of tokenizer when saving by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3038docs] Add some missing docs for include_prompt in Pooling by @tomaarsen in https://github.com/UKPLab/sentence-transformers/pull/3042feat] Trainer with prompts and prompt masking by @ArthurCamara in https://github.com/UKPLab/sentence-transformers/pull/2964enh] Add Support for multiple adapters on Transformers-based models by @carlesonielfa in https://github.com/UKPLab/sentence-transformers/pull/3046 & https://github.com/UKPLab/sentence-transformers/pull/2993New Contributors
Special Thanks
Big thanks to @ArthurCamara for leading the work on both 1) training with prompts and 2) NanoBEIR.
Full Changelog: huggingface/sentence-transformers@v3.2.1...v3.3.0
v3.2.1: - Patch CLIP loading, small ONNX fix, compatibility with other librariesCompare Source
This patch release fixes some small bugs, such as related to loading CLIP models, automatic model card generation issues, and ensuring compatibility with third party libraries.
Install this version with
Fixing Loading non-Transformer models
In v3.2.0, a non-Transformer based model (e.g. CLIP) would not load correctly if the model was saved in the root of the model repository/directory. This has been resolved in #3007.
Throw error if
StaticEmbedding-based model is finetuned with incompatible lossesThe following losses are not compatible with
StaticEmbedding-based models:An error is now thrown when one of these are used with a
StaticEmbedding-based model. I recommend using MultipleNegativesRankingLoss to finetune these models, e.g. as in https://huggingface.co/tomaarsen/static-bert-uncased-gooaq.Note: to get good performance, you must use much higher learning rates than otherwise. In my experiments, 2e-1 worked well.
Patch ONNX model when the model uses
output_hidden_statesFor example, this script used to fail, but passes now: