Skip to content

Bump sentence-transformers from 2.7.0 to 4.0.2 #1097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Apr 7, 2025

Bumps sentence-transformers from 2.7.0 to 4.0.2.

Release notes

Sourced from sentence-transformers's releases.

v4.0.2 - Safer reranker max sequence length logic, typing issues, FSDP & device placement

This patch release updates some logic for maximum sequence lengths, typing issues, FSDP training, and distributed training device placement.

Install this version with

# Training + Inference
pip install sentence-transformers[train]==4.0.2
Inference only, use one of:
pip install sentence-transformers==4.0.2
pip install sentence-transformers[onnx-gpu]==4.0.2
pip install sentence-transformers[onnx]==4.0.2
pip install sentence-transformers[openvino]==4.0.2

Safer CrossEncoder (reranker) maximum sequence length

When loading CrossEncoder models, we now rely on the minimum of the tokenizer model_max_length and the config max_position_embeddings (if they exist), rather than only relying on the latter if it exists. This previously resulted in the maximum sequence length of BAAI/bge-reranker-base being 514, whereas it can only handle sequences up to 512 tokens.

from sentence_transformers import CrossEncoder
model = CrossEncoder("BAAI/bge-reranker-base")
print(model.max_length)
=> 512
The texts for which to predict similarity scores
query = "How many people live in Berlin?"
passages = [
"Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers.",
"In 2013 around 600,000 Berliners were registered in one of the more than 2,300 sport and fitness clubs.",
]
scores = model.predict([(query, passage) for passage in passages])
print(scores)
=> [0.99953485 0.01062613]
Or test really long inputs to ensure that there's no crash:
score = model.predict([["one " * 1000, "two " * 1000]])
print(score)
=> [0.95482624]

Note that you can use the activation_fn option with torch.nn.Identity() to avoid the default Sigmoid that maps everything to [0, 1]:

from sentence_transformers import CrossEncoder
import torch
model = CrossEncoder("BAAI/bge-reranker-base", activation_fn=torch.nn.Identity())
The texts for which to predict similarity scores
query = "How many people live in Berlin?"
</tr></table>

... (truncated)

Commits
  • 6d48aee Release v4.0.2
  • c9b87ac Merge branch 'master' into v4.0-release
  • 8d73d4f Specify that exported ONNX/OpenVINO models don't include pooling/normalizatio...
  • a51d9c9 Add missing docstring for push_to_hub (#3306)
  • 07f53c5 Update default device assignment in get_device_name for distributed trainin...
  • 9b9856e Attempt to fix CI (#3305)
  • 5aa7f93 [cross-encoder] Set the tokenizer model_max_length to the min. of model_max...
  • b9e3257 Avoid "Only if model is wrapped" check which is faulty for FSDP (#3295)
  • b3512bc Move encode typings back to .py from .pyi (#3297)
  • e33f278 Fix some broken docs redirects (#3296)
  • Additional commits viewable in compare view

Most Recent Ignore Conditions Applied to This Pull Request
Dependency Name Ignore Conditions
sentence-transformers [>= 3.3.dev0, < 3.4]
sentence-transformers [>= 3.dev0, < 4]

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [sentence-transformers](https://github.com/UKPLab/sentence-transformers) from 2.7.0 to 4.0.2.
- [Release notes](https://github.com/UKPLab/sentence-transformers/releases)
- [Commits](UKPLab/sentence-transformers@v2.7.0...v4.0.2)

---
updated-dependencies:
- dependency-name: sentence-transformers
  dependency-version: 4.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file python Pull requests that update Python code labels Apr 7, 2025
Copy link

sonarqubecloud bot commented Apr 7, 2025

@coveralls
Copy link

Coverage Status

coverage: 53.053% (-0.04%) from 53.092%
when pulling 15ae5bb on dependabot/pip/sentence-transformers-4.0.2
into 7a6920a on dev.

@bact bact closed this Apr 21, 2025
Copy link
Contributor Author

dependabot bot commented on behalf of github Apr 21, 2025

OK, I won't notify you again about this release, but will get in touch when a new version is available. If you'd rather skip all updates until the next major or minor version, let me know by commenting @dependabot ignore this major version or @dependabot ignore this minor version. You can also ignore all major, minor, or patch releases for a dependency by adding an ignore condition with the desired update_types to your config file.

If you change your mind, just re-open this PR and I'll resolve any conflicts on it.

@dependabot dependabot bot deleted the dependabot/pip/sentence-transformers-4.0.2 branch April 21, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants