fastembed-haystack 0.1.0__tar.gz → 1.0.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.
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/PKG-INFO +2 -1
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/pyproject.toml +1 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py +7 -3
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_document_embedder.py +12 -11
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_text_embedder.py +6 -13
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/src/haystack_integrations/components/embedders/fastembed/fastembed_text_embedder.py +3 -5
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/test_fastembed_sparse_text_embedder.py +0 -10
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/.gitignore +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/LICENSE.txt +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/README.md +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/examples/example.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/examples/sparse_example.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/pydoc/config.yml +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/src/haystack_integrations/components/embedders/fastembed/__init__.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/src/haystack_integrations/components/embedders/fastembed/embedding_backend/__init__.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/__init__.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/test_fastembed_backend.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/test_fastembed_document_embedder.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/test_fastembed_sparse_document_embedder.py +0 -0
- {fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/test_fastembed_text_embedder.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: fastembed-haystack
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.0.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
|
|
@@ -9,6 +9,7 @@ Author-email: deepset GmbH <info@deepset.ai>
|
|
|
9
9
|
License-Expression: Apache-2.0
|
|
10
10
|
License-File: LICENSE.txt
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
13
|
Classifier: Programming Language :: Python
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.8
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -14,6 +14,7 @@ authors = [
|
|
|
14
14
|
{ name = "deepset GmbH", email = "info@deepset.ai" },
|
|
15
15
|
]
|
|
16
16
|
classifiers = [
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
18
|
"Development Status :: 4 - Beta",
|
|
18
19
|
"Programming Language :: Python",
|
|
19
20
|
"Programming Language :: Python :: 3.8",
|
|
@@ -29,14 +29,18 @@ class FastembedDocumentEmbedder:
|
|
|
29
29
|
# Text taken from PubMed QA Dataset (https://huggingface.co/datasets/pubmed_qa)
|
|
30
30
|
document_list = [
|
|
31
31
|
Document(
|
|
32
|
-
content="Oxidative stress generated within inflammatory joints can produce autoimmune phenomena and joint
|
|
32
|
+
content=("Oxidative stress generated within inflammatory joints can produce autoimmune phenomena and joint "
|
|
33
|
+
"destruction. Radical species with oxidative activity, including reactive nitrogen species, "
|
|
34
|
+
"represent mediators of inflammation and cartilage damage."),
|
|
33
35
|
meta={
|
|
34
36
|
"pubid": "25,445,628",
|
|
35
37
|
"long_answer": "yes",
|
|
36
38
|
},
|
|
37
39
|
),
|
|
38
40
|
Document(
|
|
39
|
-
content="Plasma levels of pancreatic polypeptide (PP) rise upon food intake. Although other pancreatic
|
|
41
|
+
content=("Plasma levels of pancreatic polypeptide (PP) rise upon food intake. Although other pancreatic "
|
|
42
|
+
"islet hormones, such as insulin and glucagon, have been extensively investigated, PP secretion "
|
|
43
|
+
"and actions are still poorly understood."),
|
|
40
44
|
meta={
|
|
41
45
|
"pubid": "25,445,712",
|
|
42
46
|
"long_answer": "yes",
|
|
@@ -49,7 +53,7 @@ class FastembedDocumentEmbedder:
|
|
|
49
53
|
print(f"Document Embedding: {result['documents'][0].embedding}")
|
|
50
54
|
print(f"Embedding Dimension: {len(result['documents'][0].embedding)}")
|
|
51
55
|
```
|
|
52
|
-
"""
|
|
56
|
+
"""
|
|
53
57
|
|
|
54
58
|
def __init__(
|
|
55
59
|
self,
|
|
@@ -12,30 +12,31 @@ class FastembedSparseDocumentEmbedder:
|
|
|
12
12
|
|
|
13
13
|
Usage example:
|
|
14
14
|
```python
|
|
15
|
-
# To use this component, install the "fastembed-haystack" package.
|
|
16
|
-
# pip install fastembed-haystack
|
|
17
|
-
|
|
18
15
|
from haystack_integrations.components.embedders.fastembed import FastembedSparseDocumentEmbedder
|
|
19
16
|
from haystack.dataclasses import Document
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
sparse_doc_embedder = FastembedSparseDocumentEmbedder(
|
|
22
19
|
model="prithvida/Splade_PP_en_v1",
|
|
23
20
|
batch_size=32,
|
|
24
21
|
)
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
sparse_doc_embedder.warm_up()
|
|
27
24
|
|
|
28
25
|
# Text taken from PubMed QA Dataset (https://huggingface.co/datasets/pubmed_qa)
|
|
29
26
|
document_list = [
|
|
30
27
|
Document(
|
|
31
|
-
content="Oxidative stress generated within inflammatory joints can produce autoimmune phenomena and joint
|
|
28
|
+
content=("Oxidative stress generated within inflammatory joints can produce autoimmune phenomena and joint "
|
|
29
|
+
"destruction. Radical species with oxidative activity, including reactive nitrogen species, "
|
|
30
|
+
"represent mediators of inflammation and cartilage damage."),
|
|
32
31
|
meta={
|
|
33
32
|
"pubid": "25,445,628",
|
|
34
33
|
"long_answer": "yes",
|
|
35
34
|
},
|
|
36
35
|
),
|
|
37
36
|
Document(
|
|
38
|
-
content="Plasma levels of pancreatic polypeptide (PP) rise upon food intake. Although other pancreatic
|
|
37
|
+
content=("Plasma levels of pancreatic polypeptide (PP) rise upon food intake. Although other pancreatic "
|
|
38
|
+
"islet hormones, such as insulin and glucagon, have been extensively investigated, PP secretion "
|
|
39
|
+
"and actions are still poorly understood."),
|
|
39
40
|
meta={
|
|
40
41
|
"pubid": "25,445,712",
|
|
41
42
|
"long_answer": "yes",
|
|
@@ -43,12 +44,12 @@ class FastembedSparseDocumentEmbedder:
|
|
|
43
44
|
),
|
|
44
45
|
]
|
|
45
46
|
|
|
46
|
-
result =
|
|
47
|
+
result = sparse_doc_embedder.run(document_list)
|
|
47
48
|
print(f"Document Text: {result['documents'][0].content}")
|
|
48
|
-
print(f"Document Embedding: {result['documents'][0].sparse_embedding}")
|
|
49
|
-
print(f"Embedding Dimension: {len(result['documents'][0].sparse_embedding)}")
|
|
49
|
+
print(f"Document Sparse Embedding: {result['documents'][0].sparse_embedding}")
|
|
50
|
+
print(f"Sparse Embedding Dimension: {len(result['documents'][0].sparse_embedding)}")
|
|
50
51
|
```
|
|
51
|
-
"""
|
|
52
|
+
"""
|
|
52
53
|
|
|
53
54
|
def __init__(
|
|
54
55
|
self,
|
|
@@ -13,28 +13,25 @@ class FastembedSparseTextEmbedder:
|
|
|
13
13
|
|
|
14
14
|
Usage example:
|
|
15
15
|
```python
|
|
16
|
-
# To use this component, install the "fastembed-haystack" package.
|
|
17
|
-
# pip install fastembed-haystack
|
|
18
|
-
|
|
19
16
|
from haystack_integrations.components.embedders.fastembed import FastembedSparseTextEmbedder
|
|
20
17
|
|
|
21
|
-
text = "It clearly says online this will work on a Mac OS system.
|
|
18
|
+
text = ("It clearly says online this will work on a Mac OS system. "
|
|
19
|
+
"The disk comes and it does not, only Windows. Do Not order this if you have a Mac!!")
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
sparse_text_embedder = FastembedSparseTextEmbedder(
|
|
24
22
|
model="prithvida/Splade_PP_en_v1"
|
|
25
23
|
)
|
|
26
|
-
|
|
24
|
+
sparse_text_embedder.warm_up()
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
sparse_embedding = sparse_text_embedder.run(text)["sparse_embedding"]
|
|
29
27
|
```
|
|
30
|
-
"""
|
|
28
|
+
"""
|
|
31
29
|
|
|
32
30
|
def __init__(
|
|
33
31
|
self,
|
|
34
32
|
model: str = "prithvida/Splade_PP_en_v1",
|
|
35
33
|
cache_dir: Optional[str] = None,
|
|
36
34
|
threads: Optional[int] = None,
|
|
37
|
-
batch_size: int = 32,
|
|
38
35
|
progress_bar: bool = True,
|
|
39
36
|
parallel: Optional[int] = None,
|
|
40
37
|
):
|
|
@@ -46,7 +43,6 @@ class FastembedSparseTextEmbedder:
|
|
|
46
43
|
Can be set using the `FASTEMBED_CACHE_PATH` env variable.
|
|
47
44
|
Defaults to `fastembed_cache` in the system's temp directory.
|
|
48
45
|
:param threads: The number of threads single onnxruntime session can use. Defaults to None.
|
|
49
|
-
:param batch_size: Number of strings to encode at once.
|
|
50
46
|
:param progress_bar: If true, displays progress bar during embedding.
|
|
51
47
|
:param parallel:
|
|
52
48
|
If > 1, data-parallel encoding will be used, recommended for offline encoding of large datasets.
|
|
@@ -57,7 +53,6 @@ class FastembedSparseTextEmbedder:
|
|
|
57
53
|
self.model_name = model
|
|
58
54
|
self.cache_dir = cache_dir
|
|
59
55
|
self.threads = threads
|
|
60
|
-
self.batch_size = batch_size
|
|
61
56
|
self.progress_bar = progress_bar
|
|
62
57
|
self.parallel = parallel
|
|
63
58
|
|
|
@@ -73,7 +68,6 @@ class FastembedSparseTextEmbedder:
|
|
|
73
68
|
model=self.model_name,
|
|
74
69
|
cache_dir=self.cache_dir,
|
|
75
70
|
threads=self.threads,
|
|
76
|
-
batch_size=self.batch_size,
|
|
77
71
|
progress_bar=self.progress_bar,
|
|
78
72
|
parallel=self.parallel,
|
|
79
73
|
)
|
|
@@ -110,7 +104,6 @@ class FastembedSparseTextEmbedder:
|
|
|
110
104
|
|
|
111
105
|
embedding = self.embedding_backend.embed(
|
|
112
106
|
[text],
|
|
113
|
-
batch_size=self.batch_size,
|
|
114
107
|
show_progress_bar=self.progress_bar,
|
|
115
108
|
parallel=self.parallel,
|
|
116
109
|
)[0]
|
|
@@ -12,12 +12,10 @@ class FastembedTextEmbedder:
|
|
|
12
12
|
|
|
13
13
|
Usage example:
|
|
14
14
|
```python
|
|
15
|
-
# To use this component, install the "fastembed-haystack" package.
|
|
16
|
-
# pip install fastembed-haystack
|
|
17
|
-
|
|
18
15
|
from haystack_integrations.components.embedders.fastembed import FastembedTextEmbedder
|
|
19
16
|
|
|
20
|
-
text = "It clearly says online this will work on a Mac OS system.
|
|
17
|
+
text = ("It clearly says online this will work on a Mac OS system. "
|
|
18
|
+
"The disk comes and it does not, only Windows. Do Not order this if you have a Mac!!")
|
|
21
19
|
|
|
22
20
|
text_embedder = FastembedTextEmbedder(
|
|
23
21
|
model="BAAI/bge-small-en-v1.5"
|
|
@@ -26,7 +24,7 @@ class FastembedTextEmbedder:
|
|
|
26
24
|
|
|
27
25
|
embedding = text_embedder.run(text)["embedding"]
|
|
28
26
|
```
|
|
29
|
-
"""
|
|
27
|
+
"""
|
|
30
28
|
|
|
31
29
|
def __init__(
|
|
32
30
|
self,
|
{fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/test_fastembed_sparse_text_embedder.py
RENAMED
|
@@ -18,7 +18,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
18
18
|
assert embedder.model_name == "prithvida/Splade_PP_en_v1"
|
|
19
19
|
assert embedder.cache_dir is None
|
|
20
20
|
assert embedder.threads is None
|
|
21
|
-
assert embedder.batch_size == 32
|
|
22
21
|
assert embedder.progress_bar is True
|
|
23
22
|
assert embedder.parallel is None
|
|
24
23
|
|
|
@@ -30,14 +29,12 @@ class TestFastembedSparseTextEmbedder:
|
|
|
30
29
|
model="prithvida/Splade_PP_en_v1",
|
|
31
30
|
cache_dir="fake_dir",
|
|
32
31
|
threads=2,
|
|
33
|
-
batch_size=64,
|
|
34
32
|
progress_bar=False,
|
|
35
33
|
parallel=1,
|
|
36
34
|
)
|
|
37
35
|
assert embedder.model_name == "prithvida/Splade_PP_en_v1"
|
|
38
36
|
assert embedder.cache_dir == "fake_dir"
|
|
39
37
|
assert embedder.threads == 2
|
|
40
|
-
assert embedder.batch_size == 64
|
|
41
38
|
assert embedder.progress_bar is False
|
|
42
39
|
assert embedder.parallel == 1
|
|
43
40
|
|
|
@@ -53,7 +50,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
53
50
|
"model": "prithvida/Splade_PP_en_v1",
|
|
54
51
|
"cache_dir": None,
|
|
55
52
|
"threads": None,
|
|
56
|
-
"batch_size": 32,
|
|
57
53
|
"progress_bar": True,
|
|
58
54
|
"parallel": None,
|
|
59
55
|
},
|
|
@@ -67,7 +63,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
67
63
|
model="prithvida/Splade_PP_en_v1",
|
|
68
64
|
cache_dir="fake_dir",
|
|
69
65
|
threads=2,
|
|
70
|
-
batch_size=64,
|
|
71
66
|
progress_bar=False,
|
|
72
67
|
parallel=1,
|
|
73
68
|
)
|
|
@@ -78,7 +73,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
78
73
|
"model": "prithvida/Splade_PP_en_v1",
|
|
79
74
|
"cache_dir": "fake_dir",
|
|
80
75
|
"threads": 2,
|
|
81
|
-
"batch_size": 64,
|
|
82
76
|
"progress_bar": False,
|
|
83
77
|
"parallel": 1,
|
|
84
78
|
},
|
|
@@ -94,7 +88,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
94
88
|
"model": "prithvida/Splade_PP_en_v1",
|
|
95
89
|
"cache_dir": None,
|
|
96
90
|
"threads": None,
|
|
97
|
-
"batch_size": 32,
|
|
98
91
|
"progress_bar": True,
|
|
99
92
|
"parallel": None,
|
|
100
93
|
},
|
|
@@ -103,7 +96,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
103
96
|
assert embedder.model_name == "prithvida/Splade_PP_en_v1"
|
|
104
97
|
assert embedder.cache_dir is None
|
|
105
98
|
assert embedder.threads is None
|
|
106
|
-
assert embedder.batch_size == 32
|
|
107
99
|
assert embedder.progress_bar is True
|
|
108
100
|
assert embedder.parallel is None
|
|
109
101
|
|
|
@@ -117,7 +109,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
117
109
|
"model": "prithvida/Splade_PP_en_v1",
|
|
118
110
|
"cache_dir": "fake_dir",
|
|
119
111
|
"threads": 2,
|
|
120
|
-
"batch_size": 64,
|
|
121
112
|
"progress_bar": False,
|
|
122
113
|
"parallel": 1,
|
|
123
114
|
},
|
|
@@ -126,7 +117,6 @@ class TestFastembedSparseTextEmbedder:
|
|
|
126
117
|
assert embedder.model_name == "prithvida/Splade_PP_en_v1"
|
|
127
118
|
assert embedder.cache_dir == "fake_dir"
|
|
128
119
|
assert embedder.threads == 2
|
|
129
|
-
assert embedder.batch_size == 64
|
|
130
120
|
assert embedder.progress_bar is False
|
|
131
121
|
assert embedder.parallel == 1
|
|
132
122
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastembed_haystack-0.1.0 → fastembed_haystack-1.0.0}/tests/test_fastembed_document_embedder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|