Skip to content
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
c0af86c
Introduce cross-modality and multi-modality support
tomaarsen Oct 20, 2025
2273532
Heavily refactor Router to allow for modality-based routing
tomaarsen Oct 24, 2025
efb36f7
Fix Router docstring examples
tomaarsen Oct 24, 2025
6ae100e
Remove now-removed Transformer types
tomaarsen Oct 24, 2025
b20da09
MLMTransformer just as Transformer with transformer_task="fill-mask"
tomaarsen Oct 24, 2025
cbc7f74
Add TODOs to modality_utils
tomaarsen Oct 24, 2025
0aa54b9
Merge branch 'main' into refactor/multimodal
tomaarsen Nov 25, 2025
0ede385
Rename tokenize to preprocess, soft deprecation
tomaarsen Nov 26, 2025
4c54d2a
Load with string instead of Path
tomaarsen Nov 26, 2025
6c61c1d
Heavily expand on refactor: separate "Base..." classes to act as supe…
tomaarsen Nov 28, 2025
a7abc9e
Avoid ImportError
tomaarsen Nov 28, 2025
8ba0b3b
Work on matching performance of pre-refactor for CrossEncoder
tomaarsen Dec 1, 2025
0df4450
Let's stick with PretrainedConfig instead of PreTrainedConfig for now
tomaarsen Dec 1, 2025
bff6efa
Improve CrossEncoderTrainer; remove router_mapping from CE
tomaarsen Dec 3, 2025
a55f94b
Improve the Router, its tests now pass
tomaarsen Dec 4, 2025
688bbe9
Modernize the CMNRL test: avoid InputExample/smart_batching_collate
tomaarsen Dec 4, 2025
9c47fca
Require v5.0.0 (pre)
tomaarsen Dec 4, 2025
805d11e
Make max_seq_length more robust, update model type default
tomaarsen Dec 4, 2025
2cdb342
Update monkeypatch for hard negatives test
tomaarsen Dec 4, 2025
8df5955
Lower tokenizer model_max_length if needed; fix CE model card test
tomaarsen Dec 4, 2025
9c34b7f
Let's revert to <5 in the CI, just because optimum isn't compatible yet
tomaarsen Dec 4, 2025
aae848e
Move multi-processing functionality to base, fix it for SparseEncoder
tomaarsen Dec 4, 2025
59c39f4
Merge branch 'main' into refactor/multimodal
tomaarsen Dec 15, 2025
aefa87a
Use warmup_steps instead of deprecated warmup_ratio
tomaarsen Dec 15, 2025
64d2b39
Merge branch 'main' into refactor/multimodal
tomaarsen Dec 15, 2025
3062305
Load with fp32 to match existing test expectation
tomaarsen Dec 15, 2025
1b06110
Only run tests for transformers v5+, install accelerate from source
tomaarsen Dec 15, 2025
7331265
Improve prompts support, use chat_template with rerankers
tomaarsen Dec 15, 2025
16804f7
CE: Load prompt and default_prompt_name from config again
tomaarsen Dec 15, 2025
ab4abaa
CE: Correctly grab logits in CausalScoreHead if padding is left
tomaarsen Dec 15, 2025
11480e7
Add some comments to self
tomaarsen Dec 15, 2025
bd5e23b
Add TODO in code
tomaarsen Dec 16, 2025
1439548
Merge branch 'main' into refactor/multimodal
tomaarsen Dec 19, 2025
a91ab2d
Extend "messages" support for all model archetypes, uses chat_template
tomaarsen Dec 19, 2025
181bda8
Update the ruff pre-commit hooks slightly
tomaarsen Dec 19, 2025
31c6e35
Add show-fixes to get an idea of what's meant to be failing in pre-co…
tomaarsen Dec 19, 2025
b3cb2d8
Update the Pooling import
tomaarsen Dec 19, 2025
2422a2d
Formalize deprecated imports
tomaarsen Dec 23, 2025
a5ae50f
Add simple __repr__ to Module superclass
tomaarsen Dec 23, 2025
2d23def
Revert to simply sys.modules aliasing to avoid different instances o…
tomaarsen Dec 23, 2025
ea61bef
Ignore unresolved-attribute with ty
tomaarsen Dec 23, 2025
56ed228
Work towards transformers v4 compatibility as well
tomaarsen Dec 23, 2025
a975121
Patch Asym import
tomaarsen Dec 23, 2025
0425b44
Fix typo in module output name
tomaarsen Dec 23, 2025
1cb7d10
Also use unreleased accelerate for transormers <5
tomaarsen Dec 23, 2025
3c55e8b
Merge branch 'main' into refactor/multimodal
tomaarsen Dec 23, 2025
63eefee
Update typings/type hints
tomaarsen Dec 29, 2025
0d2ffed
Update import etc. paths in documentation;
tomaarsen Dec 29, 2025
9479037
Resolve dozens of documentation warnings and issues
tomaarsen Dec 29, 2025
4cdbd83
Add 'base' to API Reference
tomaarsen Dec 29, 2025
30508ba
Move LoggingHandler to util
tomaarsen Dec 29, 2025
6084653
Update CrossEncoder training_overview docs, add cross_encoder/models …
tomaarsen Dec 29, 2025
880469e
Fix various links in training_overview for all 3 architectures, remov…
tomaarsen Dec 29, 2025
6ecba84
Simplify ONNX/OV optimization by using 'model.transformers_model'
tomaarsen Dec 30, 2025
3997067
Add is_singular_input, disallow singular inputs in preprocess
tomaarsen Dec 30, 2025
6b47d31
Improve typings for preprocess, encode, predict, etc. w. multimodality
tomaarsen Dec 30, 2025
5eb13a8
Update typings with model loading
tomaarsen Dec 30, 2025
fac2e26
Remove last Modality.all()
tomaarsen Dec 30, 2025
488e7b6
Merge branch 'main' into refactor/multimodal
tomaarsen Feb 5, 2026
c8a3ee9
Heavily refactor multimodality further; focus on message and tests
tomaarsen Feb 13, 2026
6e90205
Add query/document style message format for rerankers
tomaarsen Feb 16, 2026
7cef666
Merge branch 'main' into refactor/multimodal
tomaarsen Feb 16, 2026
5e5619b
Fix some updated imports
tomaarsen Feb 16, 2026
003fb7f
If model.forward can't be inspected, assume model.forward is fine
tomaarsen Feb 16, 2026
9034b5c
Replace prajjwal1/bert-tiny due to issues loading with AutoConfig
tomaarsen Feb 16, 2026
fe59c13
Allow for pairs of inputs a bit easier
tomaarsen Feb 16, 2026
342416e
Add torchcodec to test suite
tomaarsen Feb 16, 2026
f5db2ed
Expand on test suite even further, discover more issues
tomaarsen Feb 16, 2026
21088fc
Link directly to transformers issue explaining why try-except exists
tomaarsen Feb 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ jobs:
# The --break-system-packages flag is used to allow pip to upgrade or install packages
# even in environments where system-managed packages might otherwise block such operations.
python -m pip install --upgrade pip --break-system-packages
python -m pip install '.[train, onnx, openvino, dev]' 'transformers<5.0.0'
# We require the not-yet-released https://github.com/huggingface/accelerate/pull/3850, so install from GitHub for now
python -m pip install '.[train, onnx, openvino, dev]' 'transformers<5.0.0' 'git+https://github.com/huggingface/accelerate'

- name: Install dependencies (transformers >= 5.0.0)
if: ${{ matrix.transformers-version == '>=5.0.0' }}
run: |
# The --break-system-packages flag is used to allow pip to upgrade or install packages
# even in environments where system-managed packages might otherwise block such operations.
python -m pip install --upgrade pip --break-system-packages
python -m pip install '.[train, dev]' 'transformers>=5.0.0rc0'
# We require the not-yet-released https://github.com/huggingface/accelerate/pull/3850, so install from GitHub for now
python -m pip install '.[train, dev]' 'transformers>=5.0.0rc0' 'git+https://github.com/huggingface/accelerate'

- name: Install model2vec
run: python -m pip install model2vec
Expand Down
15 changes: 9 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.5
hooks:
- id: ruff
args: [--exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.10
hooks:
# Run the linter.
- id: ruff-check
args: [ --fix, --show-fixes ]
# Run the formatter.
- id: ruff-format
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ print(scores)
# => [8.607139 5.506266 6.352977]
```

And we're good to go. You can also use [`model.rank`](https://sbert.net/docs/package_reference/cross_encoder/cross_encoder.html#sentence_transformers.cross_encoder.CrossEncoder.rank) to avoid having to perform the reranking manually:
And we're good to go. You can also use [`model.rank`](https://sbert.net/docs/package_reference/cross_encoder/cross_encoder.html#sentence_transformers.cross_encoder.model.CrossEncoder.rank) to avoid having to perform the reranking manually:

```python
# 2b. Rank a list of passages for a query
Expand Down
4 changes: 4 additions & 0 deletions docs/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Redirect 301 /examples/unsupervised_learning/README.html /examples/sentence_tran
Redirect 301 /examples/unsupervised_learning/SimCSE/README.html /examples/sentence_transformer/unsupervised_learning/SimCSE/README.html
Redirect 301 /examples/unsupervised_learning/TSDAE/README.html /examples/sentence_transformer/unsupervised_learning/TSDAE/README.html

# Moved API Reference pages for v5.3.0
Redirect 301 /docs/package_reference/sentence_transformer/quantization.html /docs/package_reference/util/quantization.html
Redirect 301 /docs/package_reference/util.html /docs/package_reference/util/index.html

# Redirect to index.html when request file does not exist
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
Expand Down
2 changes: 1 addition & 1 deletion docs/cross_encoder/pretrained_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ These models have been trained on the [Quora duplicate questions dataset](https:

```{eval-rst}
.. note::
The model don't work for question similarity. The question "How to learn Java?" and "How to learn Python?" will get a low score, as these questions are not duplicates. For question similarity, a :class:`~sentence_transformers.SentenceTransformer` trained on the Quora dataset will yield much more meaningful results.
The model don't work for question similarity. The question "How to learn Java?" and "How to learn Python?" will get a low score, as these questions are not duplicates. For question similarity, a :class:`~sentence_transformers.model.SentenceTransformer` trained on the Quora dataset will yield much more meaningful results.
```

## NLI
Expand Down
60 changes: 30 additions & 30 deletions docs/cross_encoder/training_overview.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/cross_encoder/usage/backend_export_sidebar.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. sidebar:: Export, Optimize, and Quantize Hugging Face models

This Hugging Face Space provides a user interface for exporting, optimizing, and quantizing models for either ONNX or OpenVINO:

- `sentence-transformers/backend-export <https://huggingface.co/spaces/sentence-transformers/backend-export>`_
8 changes: 4 additions & 4 deletions docs/cross_encoder/usage/efficiency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ All keyword arguments passed via ``model_kwargs`` will be passed on to :meth:`OR

.. tip::

It's heavily recommended to save the exported model to prevent having to re-export it every time you run your code. You can do this by calling :meth:`model.save_pretrained() <sentence_transformers.cross_encoder.CrossEncoder.save_pretrained>` if your model was local:
It's heavily recommended to save the exported model to prevent having to re-export it every time you run your code. You can do this by calling :meth:`model.save_pretrained() <sentence_transformers.cross_encoder.model.CrossEncoder.save_pretrained>` if your model was local:

.. code-block:: python

model = CrossEncoder("path/to/my/model", backend="onnx")
model.save_pretrained("path/to/my/model")

or with :meth:`model.push_to_hub() <sentence_transformers.cross_encoder.CrossEncoder.push_to_hub>` if your model was from the Hugging Face Hub:
or with :meth:`model.push_to_hub() <sentence_transformers.cross_encoder.model.CrossEncoder.push_to_hub>` if your model was from the Hugging Face Hub:

.. code-block:: python

Expand Down Expand Up @@ -354,14 +354,14 @@ If the model path or repository already contains a model in OpenVINO format, Sen

.. tip::

It's heavily recommended to save the exported model to prevent having to re-export it every time you run your code. You can do this by calling :meth:`model.save_pretrained() <sentence_transformers.cross_encoder.CrossEncoder.save_pretrained>` if your model was local:
It's heavily recommended to save the exported model to prevent having to re-export it every time you run your code. You can do this by calling :meth:`model.save_pretrained() <sentence_transformers.cross_encoder.model.CrossEncoder.save_pretrained>` if your model was local:

.. code-block:: python

model = CrossEncoder("path/to/my/model", backend="openvino")
model.save_pretrained("path/to/my/model")

or with :meth:`model.push_to_hub() <sentence_transformers.cross_encoder.CrossEncoder.push_to_hub>` if your model was from the Hugging Face Hub:
or with :meth:`model.push_to_hub() <sentence_transformers.cross_encoder.model.CrossEncoder.push_to_hub>` if your model was from the Hugging Face Hub:

.. code-block:: python

Expand Down
8 changes: 4 additions & 4 deletions docs/cross_encoder/usage/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Once you have `installed <../../installation.html>`_ Sentence Transformers, you

.. sidebar:: Documentation

1. :class:`~sentence_transformers.cross_encoder.CrossEncoder`
2. :meth:`CrossEncoder.predict <sentence_transformers.cross_encoder.CrossEncoder.predict>`
3. :meth:`CrossEncoder.rank <sentence_transformers.cross_encoder.CrossEncoder.rank>`
1. :class:`~sentence_transformers.cross_encoder.model.CrossEncoder`
2. :meth:`CrossEncoder.predict <sentence_transformers.cross_encoder.model.CrossEncoder.predict>`
3. :meth:`CrossEncoder.rank <sentence_transformers.cross_encoder.model.CrossEncoder.rank>`

.. note::
MS Marco models return logits rather than scores between 0 and 1. Load the :class:`~sentence_transformers.cross_encoder.CrossEncoder` with ``activation_fn=torch.nn.Sigmoid()`` to get scores between 0 and 1. This does not affect the ranking.
MS Marco models return logits rather than scores between 0 and 1. Load the :class:`~sentence_transformers.cross_encoder.model.CrossEncoder` with ``activation_fn=torch.nn.Sigmoid()`` to get scores between 0 and 1. This does not affect the ranking.

::

Expand Down
Loading