Closed movchan74 closed 2 months ago
Thank you @movchan74 for bringing this to our attention! We will discuss it in our team in the next sprint planning.
I would say that sentence-transformers
is not a core dependency of haystack-ai
(we wrap imports in a lazy import block).
Instead, it is a test dependency (part of the [tool.hatch.envs.test]
block in pyproject.toml
).
For this reason, we can't force users to install a specific version. However, we should
LazyImport
message to reflect that
Describe the bug Haystack 2.4.0 specifies a dependency on
sentence-transformers
version>=2.3.0
. However, theSentenceTransformersTextEmbedder
component uses themodel_kwargs
argument, which is not supported insentence-transformers
versions below 3.0. As a result, initializing theSentenceTransformersTextEmbedder
withsentence-transformers
2.x (e.g., 2.7.0) leads to aTypeError
.Error message
Expected behavior The
SentenceTransformersTextEmbedder
should initialize correctly without raising an exception. The dependency onsentence-transformers
should either be fixed to ensure compatibility with themodel_kwargs
argument (i.e.,sentence-transformers>=3.0.0
) or the code should be adjusted to work withsentence-transformers
2.x.Additional context This issue occurs because the current dependency in the
pyproject.toml
file allows the installation ofsentence-transformers
versions that do not support themodel_kwargs
argument. This bug can be resolved by either upgrading the dependency tosentence-transformers>=3.0.0
or removing the use ofmodel_kwargs
in Haystack 2.4.0.To Reproduce
sentence-transformers
version 2.x (e.g., 2.7.0) andhaystack-ai
version 2.4.0:TypeError
due to the unsupportedmodel_kwargs
argument.FAQ Check
System:
sentence-transformers
version: 2.7.0Suggested Fix Update the
pyproject.toml
to requiresentence-transformers>=3.0.0
to ensure compatibility with themodel_kwargs
argument. Alternatively, modify the code in Haystack 2.4.0 to avoid usingmodel_kwargs
when working withsentence-transformers
versions below 3.0.