Update dependency sentence-transformers to v2.3.0#28
Open
mend-for-github-com[bot] wants to merge 1 commit intomainfrom
Open
Update dependency sentence-transformers to v2.3.0#28mend-for-github-com[bot] wants to merge 1 commit intomainfrom
mend-for-github-com[bot] wants to merge 1 commit intomainfrom
Conversation
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:
==2.2.2→==2.3.0By merging this PR, the issue #13 will be automatically resolved and closed:
Release Notes
huggingface/sentence-transformers (sentence-transformers)
v2.3.0: - Bug fixes, improved model loading & Cached MNRLCompare Source
This release focuses on various bug fixes & improvements to keep up with adjacent works like
transformersandhuggingface_hub. These are the key changes in the release:Pushing models to the Hugging Face Hub (#2376)
Prior to Sentence Transformers v2.3.0, saving models to the Hugging Face Hub may have resulted in various errors depending on the versions of the dependencies. Sentence Transformers v2.3.0 introduces a refactor to
save_to_hubto resolve these issues.Model Loading
Efficient model loading (#2345)
Recently,
transformershas shifted towards usingsafetensorsfiles as their primary model file formats. Additionally, various other file formats are commonly used, such as PyTorch (pytorch_model.bin), Rust (rust_model.ot), Tensorflow (tf_model.h5) and ONNX (model.onnx).Prior to Sentence Transformers v2.3.0, almost all files of a repository would be downloaded, even if theye are not strictly required. Since v2.3.0, only the strictly required files will be downloaded. For example, when loading sentence-transformers/all-MiniLM-L6-v2 which has its model weights in three formats (
pytorch_model.bin,rust_model.ot,tf_model.h5), onlypytorch_model.binwill be downloaded. Additionally, when downloadingintfloat/multilingual-e5-smallwith two formats (model.safetensors,pytorch_model.bin), onlymodel.safetensorswill be downloaded.Loading custom models (#2398)
This release brings models with custom code to Sentence Transformers through
trust_remote_code, such asjinaai/jina-embeddings-v2-base-en.Loading specific revisions (#2419)
If an embedding model is ever updated, it would invalidate all of the embeddings that you have created with the prior version of that model. We promise to never update the weights of any
sentence-transformers/...model, but we cannot offer this guarantee for models by the community.That is why this version introduces a
revisionkeyword, allowing you to specify exactly which revision or branch you'd like to load:Soft deprecation of
use_auth_token, usetokeninstead (#2376)Following updates from
transformers&huggingface_hub, Sentence Transformers now recommends that you use thetokenargument to provide your Hugging Face authentication token to download private models.Device patch (#2351)
Prior to this release,
SentenceTransformers.devicewould not always correspond to the device on which embeddings were computed, or on which a model gets trained. This release brings a few fixes:SentenceTransformers.devicenow always corresponds to the device that the model is on, and on which it will do its computations.SentenceTransformers.to(...),SentenceTransformers.cpu(),SentenceTransformers.cuda(), etc. will now work as expected, rather than being ignored.Cached Multiple Negatives Ranking Loss (CMNRL) (#1759)
MultipleNegativesRankingLoss (MNRL) is a powerful loss function that is commonly applied to train embedding models. It uses in-batch negative sampling to produce a large number of negative pairs, allowing the model to receive a training signal to push the embeddings of this pair apart. It is commonly shown that a larger batch size results in better performing models (Qu et al., 2021, Li et al., 2023), but a larger batch size requires more VRAM in practice.
To counteract that, @kwang2049 has implemented a slightly modified GradCache technique that is able to separate the batch computation into mini-batches without any reduction in training quality. This allows the common practitioner to train with competitive batch sizes, e.g. 65536!
The downside is that training with Cached MNRL (CMNRL) is roughly 2 to 2.4 times slower than using normal MNRL.
CachedMultipleNegativesRankingLossis a drop-in replacement forMultipleNegativesRankingLoss, but with a newmini_batch_sizeargument. I recommend trying out CMNRL with a large batch size and a fairly smallmini_batch_size- the larger mini batch size that will fit into memory.Community Detection (#1879, #2277, #2381)
This release updates the
community_detectionfunction in various ways. Notably:d8982c9).show_progress_baroption has been added (#1879)In the below graph,

masterrefers to Sentence Transformers v2.2.2 andrefactorrefers to v2.3.0. On GPU, the computation time was heavily reduced.Updated Dependencies (#2376, #2432)
Sentence Transformers has deprecated Python 3.7 following its end of security support. Additionally, various dependencies have been updated to prevent functionality from breaking. In particular:
torch >= 1.11.0transformers>= 4.32.0huggingface_hub>=0.15.1Lastly,
torchvisionhas been removed as a dependency.Additional Highlights
See the following for a list of release highlights:
community_detectionfrom running forever by @nreimers (d8982c9)db34d38)tofrom getting ignored, replace._target_devicewith.deviceby @tomaarsen (#2351)normalize_embeddingssupport to multi-process encoding by @tomaarsen (#2377)save_to_hub, remotegitdependency, addtokenargument by @tomaarsen (#2376)transformers>=4.32.0andhuggingface_hub>=0.15.1by @tomaarsen (#2376)community_detectionby @dyaaalbakour (#2277)tokenandtrust_remote_codetotokenizer_argstoo by @tomaarsen (#2411)cache_foldernorSENTENCE_TRANSFORMERS_HOMEare set, use HF default cache by @tomaarsen (#2412)@kat the end of csv file name for RerankingEvaluator by @milistu (#2427)