Skip to content

Conversation

@dependabot
Copy link
Contributor

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

Bumps sentence-transformers from 2.2.2 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

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.2.2 to 4.0.2.
- [Release notes](https://github.com/UKPLab/sentence-transformers/releases)
- [Commits](huggingface/sentence-transformers@v2.2.2...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
@dependabot @github
Copy link
Contributor Author

dependabot bot commented on behalf of github Apr 21, 2025

Superseded by #64.

@dependabot dependabot bot closed this Apr 21, 2025
@dependabot dependabot bot deleted the dependabot/pip/sentence-transformers-4.0.2 branch April 21, 2025 15:05
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.

1 participant