faiss-haystack 3.1.0__tar.gz → 3.2.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.
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/CHANGELOG.md +15 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/PKG-INFO +1 -1
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/src/haystack_integrations/components/retrievers/faiss/embedding_retriever.py +4 -1
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/src/haystack_integrations/document_stores/faiss/document_store.py +8 -3
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/tests/test_document_store.py +28 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/tests/test_embedding_retriever.py +9 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/.gitignore +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/LICENSE.txt +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/README.md +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/pydoc/config_docusaurus.yml +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/pyproject.toml +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/src/haystack_integrations/components/retrievers/faiss/__init__.py +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/src/haystack_integrations/document_stores/faiss/__init__.py +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/src/haystack_integrations/document_stores/py.typed +0 -0
- {faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/tests/__init__.py +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/faiss-v3.1.1] - 2026-11-30
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- *(faiss)* Raise on repeated IDs within a batch under DuplicatePolicy.FAIL (#4332)
|
|
8
|
+
- *(faiss)* [**breaking**] Score closer documents higher for all index types (#4342)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [integrations/faiss-v3.1.0] - 2026-11-27
|
|
12
|
+
|
|
13
|
+
### 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
- *(faiss)* Keep searching when filters drop the first candidates (#4323)
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## [integrations/faiss-v3.0.1] - 2026-11-09
|
|
4
19
|
|
|
5
20
|
### 🐛 Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: faiss-haystack
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: An integration of FAISS (library for efficient similarity search of dense vectors) with Haystack
|
|
5
5
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/faiss#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
@@ -128,7 +128,10 @@ class FAISSEmbeddingRetriever:
|
|
|
128
128
|
- `documents`: List of `Document`s that are similar to `query_embedding`.
|
|
129
129
|
"""
|
|
130
130
|
filters = apply_filter_policy(self.filter_policy, self.filters, filters)
|
|
131
|
-
|
|
131
|
+
if top_k is None:
|
|
132
|
+
top_k = self.top_k
|
|
133
|
+
if top_k == 0:
|
|
134
|
+
return {"documents": []}
|
|
132
135
|
docs = self.document_store.search(query_embedding=query_embedding, top_k=top_k, filters=filters)
|
|
133
136
|
return {"documents": docs}
|
|
134
137
|
|
|
@@ -145,12 +145,15 @@ class FAISSDocumentStore:
|
|
|
145
145
|
if not documents:
|
|
146
146
|
return 0
|
|
147
147
|
|
|
148
|
-
# Check for duplicates first if policy is FAIL
|
|
148
|
+
# Check for duplicates first if policy is FAIL, including IDs repeated within this batch,
|
|
149
|
+
# so that a failing batch is rejected before anything is written
|
|
149
150
|
if policy == DuplicatePolicy.FAIL:
|
|
151
|
+
batch_ids: set[str] = set()
|
|
150
152
|
for doc in documents:
|
|
151
|
-
if doc.id in self.documents:
|
|
153
|
+
if doc.id in self.documents or doc.id in batch_ids:
|
|
152
154
|
msg = f"Document with id '{doc.id}' already exists."
|
|
153
155
|
raise DuplicateDocumentError(msg)
|
|
156
|
+
batch_ids.add(doc.id)
|
|
154
157
|
|
|
155
158
|
# Process documents. Pending vectors are keyed by document ID so that a later duplicate in the same
|
|
156
159
|
# batch replaces the earlier one instead of leaving an orphaned vector in the FAISS index.
|
|
@@ -272,7 +275,9 @@ class FAISSDocumentStore:
|
|
|
272
275
|
continue
|
|
273
276
|
|
|
274
277
|
# Build a new instance instead of mutating score in place.
|
|
275
|
-
|
|
278
|
+
# Every index built here uses the L2 metric, so a smaller distance means a closer match whatever the
|
|
279
|
+
# index type. Map it to a score where higher is better, as the other document stores do.
|
|
280
|
+
score = float(1 / (1 + dist))
|
|
276
281
|
result_doc = replace(doc, score=score)
|
|
277
282
|
|
|
278
283
|
results.append(result_doc)
|
|
@@ -55,6 +55,19 @@ class TestFAISSDocumentStoreUnit:
|
|
|
55
55
|
with pytest.raises(DuplicateDocumentError, match="already exists"):
|
|
56
56
|
ds.write_documents([Document(id="dup", content="second")], policy=DuplicatePolicy.FAIL)
|
|
57
57
|
|
|
58
|
+
def test_write_documents_fail_policy_raises_on_duplicate_in_same_batch(self):
|
|
59
|
+
ds = FAISSDocumentStore(embedding_dim=2)
|
|
60
|
+
docs = [
|
|
61
|
+
Document(id="a", content="old", embedding=[0.0, 0.0]),
|
|
62
|
+
Document(id="a", content="new", embedding=[0.1, 0.1]),
|
|
63
|
+
]
|
|
64
|
+
with pytest.raises(DuplicateDocumentError, match="already exists"):
|
|
65
|
+
ds.write_documents(docs, policy=DuplicatePolicy.FAIL)
|
|
66
|
+
|
|
67
|
+
# The check runs before anything is written, so a failed batch leaves the store untouched
|
|
68
|
+
assert ds.count_documents() == 0
|
|
69
|
+
assert ds.index.ntotal == 0
|
|
70
|
+
|
|
58
71
|
def test_write_documents_overwrite_duplicate_in_same_batch_leaves_no_orphan_vector(self):
|
|
59
72
|
ds = FAISSDocumentStore(embedding_dim=2)
|
|
60
73
|
docs = [
|
|
@@ -197,3 +210,18 @@ class TestFAISSDocumentStore(
|
|
|
197
210
|
|
|
198
211
|
# get_metadata_field_unique_values behavior (search term, pagination, meta-prefix handling, non-string
|
|
199
212
|
# type preservation, filter restriction) is covered by the inherited GetMetadataFieldUniqueValuesTest mixin.
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
@pytest.mark.parametrize("index_string", ["Flat", "HNSW32"])
|
|
216
|
+
def test_search_scores_higher_for_closer_documents(index_string):
|
|
217
|
+
store = FAISSDocumentStore(embedding_dim=4, index_string=index_string)
|
|
218
|
+
store.write_documents(
|
|
219
|
+
[
|
|
220
|
+
Document(id="near", content="near", embedding=[1.0, 0.0, 0.0, 0.0]),
|
|
221
|
+
Document(id="far", content="far", embedding=[0.0, 0.0, 0.0, 5.0]),
|
|
222
|
+
]
|
|
223
|
+
)
|
|
224
|
+
results = store.search([1.0, 0.0, 0.0, 0.0], top_k=2)
|
|
225
|
+
assert [doc.id for doc in results] == ["near", "far"]
|
|
226
|
+
assert results[0].score > results[1].score
|
|
227
|
+
assert all(0.0 < doc.score <= 1.0 for doc in results)
|
|
@@ -36,6 +36,15 @@ def test_invalid_document_store_type():
|
|
|
36
36
|
FAISSEmbeddingRetriever(document_store="not_a_store") # type: ignore[arg-type]
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
def test_run_with_top_k_zero_returns_no_documents(populated_store):
|
|
40
|
+
"""``top_k=0`` asks for no documents; it must not fall back to the init default."""
|
|
41
|
+
retriever = FAISSEmbeddingRetriever(document_store=populated_store, top_k=10)
|
|
42
|
+
|
|
43
|
+
result = retriever.run(query_embedding=[1.0, 0.0, 0.0], top_k=0)
|
|
44
|
+
|
|
45
|
+
assert result == {"documents": []}
|
|
46
|
+
|
|
47
|
+
|
|
39
48
|
@pytest.mark.integration
|
|
40
49
|
class TestFAISSEmbeddingRetriever:
|
|
41
50
|
def test_run_with_query_embedding_only(self, populated_store):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{faiss_haystack-3.1.0 → faiss_haystack-3.2.0}/src/haystack_integrations/document_stores/py.typed
RENAMED
|
File without changes
|
|
File without changes
|