fastembed-haystack 1.4.1__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/CHANGELOG.md +57 -5
  2. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/PKG-INFO +6 -5
  3. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/pyproject.toml +30 -37
  4. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py +4 -4
  5. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py +2 -2
  6. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_document_embedder.py +2 -2
  7. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_text_embedder.py +1 -1
  8. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_text_embedder.py +1 -1
  9. fastembed_haystack-1.5.0/src/haystack_integrations/components/embedders/py.typed +0 -0
  10. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/rankers/fastembed/ranker.py +3 -3
  11. fastembed_haystack-1.5.0/src/haystack_integrations/components/rankers/py.typed +0 -0
  12. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/.gitignore +0 -0
  13. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/LICENSE.txt +0 -0
  14. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/README.md +0 -0
  15. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/examples/example.py +0 -0
  16. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/examples/ranker_example.py +0 -0
  17. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/examples/sparse_example.py +0 -0
  18. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/pydoc/config.yml +0 -0
  19. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/embedders/fastembed/__init__.py +1 -1
  20. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/embedders/fastembed/embedding_backend/__init__.py +0 -0
  21. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/src/haystack_integrations/components/rankers/fastembed/__init__.py +0 -0
  22. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/tests/__init__.py +0 -0
  23. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/tests/test_fastembed_backend.py +0 -0
  24. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/tests/test_fastembed_document_embedder.py +0 -0
  25. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/tests/test_fastembed_ranker.py +0 -0
  26. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/tests/test_fastembed_sparse_document_embedder.py +0 -0
  27. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/tests/test_fastembed_sparse_text_embedder.py +0 -0
  28. {fastembed_haystack-1.4.1 → fastembed_haystack-1.5.0}/tests/test_fastembed_text_embedder.py +0 -0
@@ -1,11 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/fastembed-v1.4.1] - 2024-11-19
4
+
5
+ ### 🌀 Miscellaneous
6
+
7
+ - Add new example with the ranker and fix the old ones (#1198)
8
+ - Fix: Fastembed - Change default Sparse model as the used one is deprecated due to a typo (#1201)
9
+
3
10
  ## [integrations/fastembed-v1.4.0] - 2024-11-13
4
11
 
5
- ### ⚙️ Miscellaneous Tasks
12
+ ### ⚙️ CI
6
13
 
7
14
  - Adopt uv as installer (#1142)
8
15
 
16
+ ### 🌀 Miscellaneous
17
+
18
+ - Chore: fastembed - pin `onnxruntime<1.20.0` (#1164)
19
+ - Feat: Fastembed - add FastembedRanker (#1178)
20
+
9
21
  ## [integrations/fastembed-v1.3.0] - 2024-10-07
10
22
 
11
23
  ### 🚀 Features
@@ -16,20 +28,35 @@
16
28
 
17
29
  - Do not retry tests in `hatch run test` command (#954)
18
30
 
19
- ### ⚙️ Miscellaneous Tasks
31
+ ### ⚙️ CI
20
32
 
21
33
  - Retry tests to reduce flakyness (#836)
34
+
35
+ ### 🧹 Chores
36
+
22
37
  - Update ruff invocation to include check parameter (#853)
23
38
  - Update ruff linting scripts and settings (#1105)
24
39
 
25
- ### Fix
40
+ ### 🌀 Miscellaneous
26
41
 
42
+ - Ci: install `pytest-rerunfailures` where needed; add retry config to `test-cov` script (#845)
27
43
  - Typo on Sparse embedders. The parameter should be "progress_bar" … (#814)
44
+ - Chore: fastembed - ruff update, don't ruff tests (#997)
28
45
 
29
46
  ## [integrations/fastembed-v1.1.0] - 2024-05-15
30
47
 
48
+ ### 🌀 Miscellaneous
49
+
50
+ - Chore: change the pydoc renderer class (#718)
51
+ - Use the local_files_only option available as of fastembed==0.2.7. It … (#736)
52
+
31
53
  ## [integrations/fastembed-v1.0.0] - 2024-05-06
32
54
 
55
+ ### 🌀 Miscellaneous
56
+
57
+ - Chore: add license classifiers (#680)
58
+ - `FastembedSparseTextEmbedder` - remove `batch_size` (#688)
59
+
33
60
  ## [integrations/fastembed-v0.1.0] - 2024-04-10
34
61
 
35
62
  ### 🚀 Features
@@ -40,6 +67,10 @@
40
67
 
41
68
  - Disable-class-def (#556)
42
69
 
70
+ ### 🌀 Miscellaneous
71
+
72
+ - Remove references to Python 3.7 (#601)
73
+
43
74
  ## [integrations/fastembed-v0.0.6] - 2024-03-07
44
75
 
45
76
  ### 📚 Documentation
@@ -47,20 +78,32 @@
47
78
  - Review and normalize docstrings - `integrations.fastembed` (#519)
48
79
  - Small consistency improvements (#536)
49
80
 
81
+ ### 🌀 Miscellaneous
82
+
83
+ - Docs: Fix `integrations.fastembed` API docs (#540)
84
+ - Improvements to FastEmbed integration (#558)
85
+
50
86
  ## [integrations/fastembed-v0.0.5] - 2024-02-20
51
87
 
52
88
  ### 🐛 Bug Fixes
53
89
 
54
90
  - Fix order of API docs (#447)
55
91
 
56
- This PR will also push the docs to Readme
57
-
58
92
  ### 📚 Documentation
59
93
 
60
94
  - Update category slug (#442)
61
95
 
96
+ ### 🌀 Miscellaneous
97
+
98
+ - Fastembed integration new parameters (#446)
99
+
62
100
  ## [integrations/fastembed-v0.0.4] - 2024-02-16
63
101
 
102
+ ### 🌀 Miscellaneous
103
+
104
+ - Fastembed integration: add example (#401)
105
+ - Fastembed fix: add parallel (#403)
106
+
64
107
  ## [integrations/fastembed-v0.0.3] - 2024-02-12
65
108
 
66
109
  ### 🐛 Bug Fixes
@@ -73,6 +116,15 @@ This PR will also push the docs to Readme
73
116
 
74
117
  ## [integrations/fastembed-v0.0.2] - 2024-02-11
75
118
 
119
+ ### 🌀 Miscellaneous
120
+
121
+ - Updated labeler and readme (#389)
122
+ - Fastembed fix: added prefix and suffix (#390)
123
+
76
124
  ## [integrations/fastembed-v0.0.1] - 2024-02-10
77
125
 
126
+ ### 🌀 Miscellaneous
127
+
128
+ - Add Fastembed Embeddings integration (#383)
129
+
78
130
  <!-- generated by git-cliff -->
@@ -1,23 +1,24 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: fastembed-haystack
3
- Version: 1.4.1
3
+ Version: 1.5.0
4
4
  Summary: Haystack 2.x component to embed strings and Documents using fastembed embedding model
5
5
  Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
6
6
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/fastembed/README.md
7
7
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
8
8
  Author-email: deepset GmbH <info@deepset.ai>
9
- License: Apache-2.0
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE.txt
10
11
  Classifier: Development Status :: 4 - Beta
11
12
  Classifier: License :: OSI Approved :: Apache Software License
12
13
  Classifier: Programming Language :: Python
13
- Classifier: Programming Language :: Python :: 3.8
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
18
19
  Classifier: Programming Language :: Python :: Implementation :: CPython
19
20
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
- Requires-Python: >=3.8
21
+ Requires-Python: >=3.9
21
22
  Requires-Dist: fastembed>=0.4.2
22
23
  Requires-Dist: haystack-ai>=2.0.1
23
24
  Description-Content-Type: text/markdown
@@ -7,7 +7,7 @@ name = "fastembed-haystack"
7
7
  dynamic = ["version"]
8
8
  description = "Haystack 2.x component to embed strings and Documents using fastembed embedding model"
9
9
  readme = "README.md"
10
- requires-python = ">=3.8"
10
+ requires-python = ">=3.9"
11
11
  license = "Apache-2.0"
12
12
  keywords = []
13
13
  authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
@@ -15,11 +15,11 @@ classifiers = [
15
15
  "License :: OSI Approved :: Apache Software License",
16
16
  "Development Status :: 4 - Beta",
17
17
  "Programming Language :: Python",
18
- "Programming Language :: Python :: 3.8",
19
18
  "Programming Language :: Python :: 3.9",
20
19
  "Programming Language :: Python :: 3.10",
21
20
  "Programming Language :: Python :: 3.11",
22
21
  "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
23
  "Programming Language :: Python :: Implementation :: CPython",
24
24
  "Programming Language :: Python :: Implementation :: PyPy",
25
25
  ]
@@ -43,34 +43,36 @@ git_describe_command = 'git describe --tags --match="integrations/fastembed-v[0-
43
43
 
44
44
  [tool.hatch.envs.default]
45
45
  installer = "uv"
46
- dependencies = [
47
- "coverage[toml]>=6.5",
48
- "pytest",
49
- "pytest-rerunfailures",
50
- "ipython",
51
- "haystack-pydoc-tools",
52
- ]
46
+ dependencies = ["haystack-pydoc-tools", "ruff"]
53
47
  [tool.hatch.envs.default.scripts]
54
- test = "pytest {args:tests}"
55
- test-cov = "coverage run -m pytest {args:tests}"
56
- test-cov-retry = "test-cov --reruns 3 --reruns-delay 30 -x"
57
- cov-report = ["- coverage combine", "coverage report"]
58
- cov = ["test-cov", "cov-report"]
59
- cov-retry = ["test-cov-retry", "cov-report"]
60
48
  docs = ["pydoc-markdown pydoc/config.yml"]
49
+ fmt = "ruff check --fix {args} && ruff format {args}"
50
+ fmt-check = "ruff check {args} && ruff format --check {args}"
51
+
52
+ [tool.hatch.envs.test]
53
+ dependencies = [
54
+ "pytest",
55
+ "pytest-asyncio",
56
+ "pytest-cov",
57
+ "pytest-rerunfailures",
58
+ "mypy",
59
+ "pip",
60
+ "ipython"
61
+ ]
61
62
 
62
- [[tool.hatch.envs.all.matrix]]
63
- python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
63
+ [tool.hatch.envs.test.scripts]
64
+ unit = 'pytest -m "not integration" {args:tests}'
65
+ integration = 'pytest -m "integration" {args:tests}'
66
+ all = 'pytest {args:tests}'
67
+ cov-retry = 'all --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x'
68
+ types = """mypy -p haystack_integrations.components.embedders.fastembed \
69
+ -p haystack_integrations.components.rankers.fastembed {args}"""
64
70
 
65
- [tool.hatch.envs.lint]
66
- installer = "uv"
67
- detached = true
68
- dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243", "numpy"]
69
- [tool.hatch.envs.lint.scripts]
70
- typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
71
- style = ["ruff check {args:.}", "black --check --diff {args:.}"]
72
- fmt = ["black {args:.}", "ruff check --fix {args:.}", "style"]
73
- all = ["style", "typing"]
71
+ [tool.mypy]
72
+ install_types = true
73
+ non_interactive = true
74
+ check_untyped_defs = true
75
+ disallow_incomplete_defs = true
74
76
 
75
77
  [tool.black]
76
78
  target-version = ["py38"]
@@ -156,14 +158,5 @@ exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
156
158
 
157
159
  [tool.pytest.ini_options]
158
160
  minversion = "6.0"
159
- markers = ["unit: unit tests", "integration: integration tests"]
160
-
161
- [[tool.mypy.overrides]]
162
- module = [
163
- "haystack.*",
164
- "haystack_integrations.*",
165
- "fastembed.*",
166
- "pytest.*",
167
- "numpy.*",
168
- ]
169
- ignore_missing_imports = true
161
+ markers = ["integration: integration tests"]
162
+
@@ -20,7 +20,7 @@ class _FastembedEmbeddingBackendFactory:
20
20
  cache_dir: Optional[str] = None,
21
21
  threads: Optional[int] = None,
22
22
  local_files_only: bool = False,
23
- ):
23
+ ) -> "_FastembedEmbeddingBackend":
24
24
  embedding_backend_id = f"{model_name}{cache_dir}{threads}"
25
25
 
26
26
  if embedding_backend_id in _FastembedEmbeddingBackendFactory._instances:
@@ -49,7 +49,7 @@ class _FastembedEmbeddingBackend:
49
49
  model_name=model_name, cache_dir=cache_dir, threads=threads, local_files_only=local_files_only
50
50
  )
51
51
 
52
- def embed(self, data: List[str], progress_bar=True, **kwargs) -> List[List[float]]:
52
+ def embed(self, data: List[str], progress_bar: bool = True, **kwargs: Any) -> List[List[float]]:
53
53
  # the embed method returns a Iterable[np.ndarray], so we convert it to a list of lists
54
54
  embeddings = []
55
55
  embeddings_iterable = self.model.embed(data, **kwargs)
@@ -74,7 +74,7 @@ class _FastembedSparseEmbeddingBackendFactory:
74
74
  threads: Optional[int] = None,
75
75
  local_files_only: bool = False,
76
76
  model_kwargs: Optional[Dict[str, Any]] = None,
77
- ):
77
+ ) -> "_FastembedSparseEmbeddingBackend":
78
78
  embedding_backend_id = f"{model_name}{cache_dir}{threads}{local_files_only}{model_kwargs}"
79
79
 
80
80
  if embedding_backend_id in _FastembedSparseEmbeddingBackendFactory._instances:
@@ -114,7 +114,7 @@ class _FastembedSparseEmbeddingBackend:
114
114
  **model_kwargs,
115
115
  )
116
116
 
117
- def embed(self, data: List[List[str]], progress_bar=True, **kwargs) -> List[SparseEmbedding]:
117
+ def embed(self, data: List[str], progress_bar: bool = True, **kwargs: Any) -> List[SparseEmbedding]:
118
118
  # The embed method returns a Iterable[SparseEmbedding], so we convert to Haystack SparseEmbedding type.
119
119
  # Each SparseEmbedding contains an `indices` key containing a list of int and
120
120
  # an `values` key containing a list of floats.
@@ -150,7 +150,7 @@ class FastembedDocumentEmbedder:
150
150
  return texts_to_embed
151
151
 
152
152
  @component.output_types(documents=List[Document])
153
- def run(self, documents: List[Document]):
153
+ def run(self, documents: List[Document]) -> Dict[str, List[Document]]:
154
154
  """
155
155
  Embeds a list of Documents.
156
156
 
@@ -158,7 +158,7 @@ class FastembedDocumentEmbedder:
158
158
  :returns: A dictionary with the following keys:
159
159
  - `documents`: List of Documents with each Document's `embedding` field set to the computed embeddings.
160
160
  """
161
- if not isinstance(documents, list) or documents and not isinstance(documents[0], Document):
161
+ if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)):
162
162
  msg = (
163
163
  "FastembedDocumentEmbedder expects a list of Documents as input. "
164
164
  "In case you want to embed a list of strings, please use the FastembedTextEmbedder."
@@ -141,7 +141,7 @@ class FastembedSparseDocumentEmbedder:
141
141
  return texts_to_embed
142
142
 
143
143
  @component.output_types(documents=List[Document])
144
- def run(self, documents: List[Document]):
144
+ def run(self, documents: List[Document]) -> Dict[str, List[Document]]:
145
145
  """
146
146
  Embeds a list of Documents.
147
147
 
@@ -150,7 +150,7 @@ class FastembedSparseDocumentEmbedder:
150
150
  - `documents`: List of Documents with each Document's `sparse_embedding`
151
151
  field set to the computed embeddings.
152
152
  """
153
- if not isinstance(documents, list) or documents and not isinstance(documents[0], Document):
153
+ if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)):
154
154
  msg = (
155
155
  "FastembedSparseDocumentEmbedder expects a list of Documents as input. "
156
156
  "In case you want to embed a list of strings, please use the FastembedTextEmbedder."
@@ -94,7 +94,7 @@ class FastembedSparseTextEmbedder:
94
94
  )
95
95
 
96
96
  @component.output_types(sparse_embedding=SparseEmbedding)
97
- def run(self, text: str):
97
+ def run(self, text: str) -> Dict[str, SparseEmbedding]:
98
98
  """
99
99
  Embeds text using the Fastembed model.
100
100
 
@@ -96,7 +96,7 @@ class FastembedTextEmbedder:
96
96
  )
97
97
 
98
98
  @component.output_types(embedding=List[float])
99
- def run(self, text: str):
99
+ def run(self, text: str) -> Dict[str, List[float]]:
100
100
  """
101
101
  Embeds text using the Fastembed model.
102
102
 
@@ -76,7 +76,7 @@ class FastembedRanker:
76
76
  self.local_files_only = local_files_only
77
77
  self.meta_fields_to_embed = meta_fields_to_embed or []
78
78
  self.meta_data_separator = meta_data_separator
79
- self._model = None
79
+ self._model: Optional[TextCrossEncoder] = None
80
80
 
81
81
  def to_dict(self) -> Dict[str, Any]:
82
82
  """
@@ -140,7 +140,7 @@ class FastembedRanker:
140
140
  return concatenated_input_list
141
141
 
142
142
  @component.output_types(documents=List[Document])
143
- def run(self, query: str, documents: List[Document], top_k: Optional[int] = None):
143
+ def run(self, query: str, documents: List[Document], top_k: Optional[int] = None) -> Dict[str, List[Document]]:
144
144
  """
145
145
  Returns a list of documents ranked by their similarity to the given query, using FastEmbed.
146
146
 
@@ -157,7 +157,7 @@ class FastembedRanker:
157
157
 
158
158
  :raises ValueError: If `top_k` is not > 0.
159
159
  """
160
- if not isinstance(documents, list) or documents and not isinstance(documents[0], Document):
160
+ if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)):
161
161
  msg = "FastembedRanker expects a list of Documents as input. "
162
162
  raise TypeError(msg)
163
163
  if query == "":
@@ -8,7 +8,7 @@ from .fastembed_text_embedder import FastembedTextEmbedder
8
8
 
9
9
  __all__ = [
10
10
  "FastembedDocumentEmbedder",
11
- "FastembedTextEmbedder",
12
11
  "FastembedSparseDocumentEmbedder",
13
12
  "FastembedSparseTextEmbedder",
13
+ "FastembedTextEmbedder",
14
14
  ]