sie-haystack 0.1.7__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.
- sie_haystack-0.1.7/.gitignore +256 -0
- sie_haystack-0.1.7/PKG-INFO +57 -0
- sie_haystack-0.1.7/README.md +35 -0
- sie_haystack-0.1.7/pyproject.toml +41 -0
- sie_haystack-0.1.7/src/sie_haystack/__init__.py +62 -0
- sie_haystack-0.1.7/src/sie_haystack/embedders.py +418 -0
- sie_haystack-0.1.7/src/sie_haystack/extractors.py +144 -0
- sie_haystack-0.1.7/src/sie_haystack/rankers.py +139 -0
- sie_haystack-0.1.7/tests/__init__.py +1 -0
- sie_haystack-0.1.7/tests/conftest.py +216 -0
- sie_haystack-0.1.7/tests/test_embedders.py +274 -0
- sie_haystack-0.1.7/tests/test_extractors.py +93 -0
- sie_haystack-0.1.7/tests/test_integration.py +416 -0
- sie_haystack-0.1.7/tests/test_rankers.py +117 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.venv
|
|
140
|
+
env/
|
|
141
|
+
venv/
|
|
142
|
+
ENV/
|
|
143
|
+
env.bak/
|
|
144
|
+
venv.bak/
|
|
145
|
+
|
|
146
|
+
# Spyder project settings
|
|
147
|
+
.spyderproject
|
|
148
|
+
.spyproject
|
|
149
|
+
|
|
150
|
+
# Rope project settings
|
|
151
|
+
.ropeproject
|
|
152
|
+
|
|
153
|
+
# mkdocs documentation
|
|
154
|
+
/site
|
|
155
|
+
|
|
156
|
+
# Pyre type checker
|
|
157
|
+
.pyre/
|
|
158
|
+
|
|
159
|
+
# pytype static type analyzer
|
|
160
|
+
.pytype/
|
|
161
|
+
|
|
162
|
+
# Cython debug symbols
|
|
163
|
+
cython_debug/
|
|
164
|
+
|
|
165
|
+
# PyCharm
|
|
166
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
167
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
168
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
169
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
170
|
+
#.idea/
|
|
171
|
+
|
|
172
|
+
# Abstra
|
|
173
|
+
# Abstra is an AI-powered process automation framework.
|
|
174
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
175
|
+
# Learn more at https://abstra.io/docs
|
|
176
|
+
.abstra/
|
|
177
|
+
|
|
178
|
+
# Visual Studio Code
|
|
179
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
180
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
181
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
182
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
183
|
+
# .vscode/
|
|
184
|
+
|
|
185
|
+
# Ruff stuff:
|
|
186
|
+
.ruff_cache/
|
|
187
|
+
|
|
188
|
+
# PyPI configuration file
|
|
189
|
+
.pypirc
|
|
190
|
+
|
|
191
|
+
# Cursor
|
|
192
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
193
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
194
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
195
|
+
.cursorignore
|
|
196
|
+
.cursorindexingignore
|
|
197
|
+
|
|
198
|
+
# vcscode
|
|
199
|
+
.vscode
|
|
200
|
+
|
|
201
|
+
# Marimo
|
|
202
|
+
marimo/_static/
|
|
203
|
+
marimo/_lsp/
|
|
204
|
+
__marimo__/
|
|
205
|
+
|
|
206
|
+
# SIE specific
|
|
207
|
+
# Model weights cache
|
|
208
|
+
.cache/
|
|
209
|
+
*.safetensors
|
|
210
|
+
*.bin
|
|
211
|
+
|
|
212
|
+
# Secrets (never commit)
|
|
213
|
+
*.pem
|
|
214
|
+
*.key
|
|
215
|
+
credentials.json
|
|
216
|
+
*-key.json
|
|
217
|
+
|
|
218
|
+
# Terraform
|
|
219
|
+
# Local .terraform directories (cached providers/modules)
|
|
220
|
+
**/.terraform/*
|
|
221
|
+
.terraform.lock*
|
|
222
|
+
# State files (contain sensitive data)
|
|
223
|
+
*.tfstate
|
|
224
|
+
*.tfstate.*
|
|
225
|
+
# Crash log files
|
|
226
|
+
crash.log
|
|
227
|
+
crash.*.log
|
|
228
|
+
# Override files (local developer overrides)
|
|
229
|
+
override.tf
|
|
230
|
+
override.tf.json
|
|
231
|
+
*_override.tf
|
|
232
|
+
*_override.tf.json
|
|
233
|
+
# tfvars files may contain secrets
|
|
234
|
+
*.tfvars
|
|
235
|
+
*.tfvars.json
|
|
236
|
+
# Keep .terraform.lock.hcl for reproducibility (provider versions)
|
|
237
|
+
|
|
238
|
+
# Node.js
|
|
239
|
+
node_modules/
|
|
240
|
+
|
|
241
|
+
# OS
|
|
242
|
+
.DS_Store
|
|
243
|
+
Thumbs.db
|
|
244
|
+
|
|
245
|
+
# VIM
|
|
246
|
+
*.swp
|
|
247
|
+
|
|
248
|
+
# Worktree metadata
|
|
249
|
+
.base-branch
|
|
250
|
+
|
|
251
|
+
# Temporary files
|
|
252
|
+
tmp/
|
|
253
|
+
.tmp/
|
|
254
|
+
.local/
|
|
255
|
+
|
|
256
|
+
.requirements-modal.txt
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sie-haystack
|
|
3
|
+
Version: 0.1.7
|
|
4
|
+
Summary: SIE integration for Haystack
|
|
5
|
+
Author-email: Superlinked <dev@superlinked.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: haystack-ai>=2.0.0
|
|
15
|
+
Requires-Dist: sie-sdk>=0.1.0
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: chroma-haystack>=2.0.0; extra == 'dev'
|
|
18
|
+
Requires-Dist: chromadb>=0.4.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# sie-haystack
|
|
24
|
+
|
|
25
|
+
SIE integration for Haystack.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install sie-haystack
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from haystack import Document
|
|
37
|
+
from sie_haystack import SIETextEmbedder, SIEDocumentEmbedder, SIERanker
|
|
38
|
+
|
|
39
|
+
# Embed a query
|
|
40
|
+
text_embedder = SIETextEmbedder(base_url="http://localhost:8080", model="BAAI/bge-m3")
|
|
41
|
+
result = text_embedder.run(text="What is machine learning?")
|
|
42
|
+
query_embedding = result["embedding"]
|
|
43
|
+
|
|
44
|
+
# Embed documents
|
|
45
|
+
doc_embedder = SIEDocumentEmbedder(base_url="http://localhost:8080", model="BAAI/bge-m3")
|
|
46
|
+
docs = [Document(content="Python is a programming language.")]
|
|
47
|
+
result = doc_embedder.run(documents=docs)
|
|
48
|
+
embedded_docs = result["documents"]
|
|
49
|
+
|
|
50
|
+
# Rerank documents
|
|
51
|
+
ranker = SIERanker(
|
|
52
|
+
base_url="http://localhost:8080",
|
|
53
|
+
model="jinaai/jina-reranker-v2-base-multilingual"
|
|
54
|
+
)
|
|
55
|
+
result = ranker.run(query="What is Python?", documents=embedded_docs, top_k=3)
|
|
56
|
+
ranked_docs = result["documents"]
|
|
57
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# sie-haystack
|
|
2
|
+
|
|
3
|
+
SIE integration for Haystack.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install sie-haystack
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from haystack import Document
|
|
15
|
+
from sie_haystack import SIETextEmbedder, SIEDocumentEmbedder, SIERanker
|
|
16
|
+
|
|
17
|
+
# Embed a query
|
|
18
|
+
text_embedder = SIETextEmbedder(base_url="http://localhost:8080", model="BAAI/bge-m3")
|
|
19
|
+
result = text_embedder.run(text="What is machine learning?")
|
|
20
|
+
query_embedding = result["embedding"]
|
|
21
|
+
|
|
22
|
+
# Embed documents
|
|
23
|
+
doc_embedder = SIEDocumentEmbedder(base_url="http://localhost:8080", model="BAAI/bge-m3")
|
|
24
|
+
docs = [Document(content="Python is a programming language.")]
|
|
25
|
+
result = doc_embedder.run(documents=docs)
|
|
26
|
+
embedded_docs = result["documents"]
|
|
27
|
+
|
|
28
|
+
# Rerank documents
|
|
29
|
+
ranker = SIERanker(
|
|
30
|
+
base_url="http://localhost:8080",
|
|
31
|
+
model="jinaai/jina-reranker-v2-base-multilingual"
|
|
32
|
+
)
|
|
33
|
+
result = ranker.run(query="What is Python?", documents=embedded_docs, top_k=3)
|
|
34
|
+
ranked_docs = result["documents"]
|
|
35
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sie-haystack"
|
|
3
|
+
version = "0.1.7"
|
|
4
|
+
description = "SIE integration for Haystack"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "Apache-2.0" }
|
|
8
|
+
authors = [{ name = "Superlinked", email = "dev@superlinked.com" }]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 4 - Beta",
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Programming Language :: Python :: 3.10",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"License :: OSI Approved :: Apache Software License",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
dependencies = [
|
|
19
|
+
"sie-sdk>=0.1.0",
|
|
20
|
+
"haystack-ai>=2.0.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = [
|
|
25
|
+
"pytest>=8.0.0",
|
|
26
|
+
"pytest-asyncio>=0.23.0",
|
|
27
|
+
"chromadb>=0.4.0",
|
|
28
|
+
"chroma-haystack>=2.0.0"
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[build-system]
|
|
32
|
+
requires = ["hatchling"]
|
|
33
|
+
build-backend = "hatchling.build"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/sie_haystack"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
asyncio_mode = "auto"
|
|
40
|
+
addopts = "-v --tb=short -m 'not integration'"
|
|
41
|
+
markers = ["integration: marks tests as integration tests (require running server)"]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""SIE integration for Haystack.
|
|
2
|
+
|
|
3
|
+
This package provides Haystack components that use SIE for inference:
|
|
4
|
+
|
|
5
|
+
Dense Embedders:
|
|
6
|
+
- SIETextEmbedder: Embeds single text strings (queries)
|
|
7
|
+
- SIEDocumentEmbedder: Embeds documents and stores embeddings on them
|
|
8
|
+
|
|
9
|
+
Sparse Embedders (for hybrid search):
|
|
10
|
+
- SIESparseTextEmbedder: Sparse embeddings for queries
|
|
11
|
+
- SIESparseDocumentEmbedder: Sparse embeddings for documents
|
|
12
|
+
|
|
13
|
+
Rankers and Extractors:
|
|
14
|
+
- SIERanker: Reranks documents by relevance to a query
|
|
15
|
+
- SIEExtractor: Extracts entities from text
|
|
16
|
+
|
|
17
|
+
Example usage:
|
|
18
|
+
from haystack import Document
|
|
19
|
+
from sie_haystack import SIETextEmbedder, SIEDocumentEmbedder, SIERanker
|
|
20
|
+
|
|
21
|
+
# Embed a query
|
|
22
|
+
text_embedder = SIETextEmbedder(base_url="http://localhost:8080", model="BAAI/bge-m3")
|
|
23
|
+
result = text_embedder.run(text="What is machine learning?")
|
|
24
|
+
query_embedding = result["embedding"]
|
|
25
|
+
|
|
26
|
+
# Embed documents
|
|
27
|
+
doc_embedder = SIEDocumentEmbedder(base_url="http://localhost:8080", model="BAAI/bge-m3")
|
|
28
|
+
docs = [Document(content="Python is a programming language.")]
|
|
29
|
+
result = doc_embedder.run(documents=docs)
|
|
30
|
+
embedded_docs = result["documents"]
|
|
31
|
+
|
|
32
|
+
# Rerank documents
|
|
33
|
+
ranker = SIERanker(base_url="http://localhost:8080", model="jinaai/jina-reranker-v2-base-multilingual")
|
|
34
|
+
result = ranker.run(query="What is Python?", documents=embedded_docs, top_k=3)
|
|
35
|
+
ranked_docs = result["documents"]
|
|
36
|
+
|
|
37
|
+
Hybrid search example:
|
|
38
|
+
from sie_haystack import SIESparseTextEmbedder, SIESparseDocumentEmbedder
|
|
39
|
+
|
|
40
|
+
# Sparse embeddings for hybrid search with Qdrant
|
|
41
|
+
sparse_text_embedder = SIESparseTextEmbedder(model="BAAI/bge-m3")
|
|
42
|
+
result = sparse_text_embedder.run(text="What is machine learning?")
|
|
43
|
+
sparse_embedding = result["sparse_embedding"] # {"indices": [...], "values": [...]}
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
from sie_haystack.embedders import (
|
|
47
|
+
SIEDocumentEmbedder,
|
|
48
|
+
SIESparseDocumentEmbedder,
|
|
49
|
+
SIESparseTextEmbedder,
|
|
50
|
+
SIETextEmbedder,
|
|
51
|
+
)
|
|
52
|
+
from sie_haystack.extractors import SIEExtractor
|
|
53
|
+
from sie_haystack.rankers import SIERanker
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
"SIEDocumentEmbedder",
|
|
57
|
+
"SIEExtractor",
|
|
58
|
+
"SIERanker",
|
|
59
|
+
"SIESparseDocumentEmbedder",
|
|
60
|
+
"SIESparseTextEmbedder",
|
|
61
|
+
"SIETextEmbedder",
|
|
62
|
+
]
|