Repository navigation
feat: add Sentence Transformers multivector embedders - #4208
Conversation
Coverage report (sentence_transformers)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||
bogdankostic
left a comment
There was a problem hiding this comment.
Looks good overall, just minor comments.
The main thing left is reusing the ONNX session options handling from #4211 in the new backend.
| trust_remote_code=trust_remote_code, | ||
| revision=revision, | ||
| local_files_only=local_files_only, | ||
| model_kwargs=model_kwargs, |
There was a problem hiding this comment.
The dense and sparse backends turn a session_options dict in model_kwargs into an onnxruntime.SessionOptions object (added in #4211).
Let's import _resolve_onnx_session_options from backend.py and reuse it:
| model_kwargs=model_kwargs, | |
| model_kwargs=_resolve_onnx_session_options(model_kwargs=model_kwargs) | |
| if backend == "onnx" | |
| else model_kwargs, |
Let's also copy the session_options sentence from the sparse embedders into the model_kwargs docstrings of both components.
| texts_to_embed.append(text_to_embed) | ||
|
|
||
| # mypy doesn't know this is set in warm_up | ||
| embeddings = self.embedding_backend.embed( # type: ignore[union-attr] |
There was a problem hiding this comment.
What do you think about adding encode_kwargs like SentenceTransformersDocumentEmbedder has?
| "haystack_integrations.components.embedders.sentence_transformers.embedding_backend.multivector_backend.MultiVectorEncoder" | ||
| ) | ||
| @pytest.mark.parametrize("is_query", [True, False]) | ||
| def test_embedding_function_with_kwargs(mock_multivector_encoder, is_query): |
There was a problem hiding this comment.
I think the name is a bit misleading, as we're not really testing kwargs that are further passed on to encode_query (like normalize_embeddings) here.
There was a problem hiding this comment.
now that we have encode_kwargs, the name is more appropriate
Co-authored-by: bogdankostic <[email protected]>
Related Issues
Proposed Changes:
How did you test it?
CI, new tests
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.