💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
fix(ann): exclude deleted rows from quantized numpy search results
serhiizghama954b17af4d65
diff --git a/src/python/txtai/ann/dense/numpy.py b/src/python/txtai/ann/dense/numpy.pyindex 19ac6dc1..97e6bbb4 100644--- a/src/python/txtai/ann/dense/numpy.py+++ b/src/python/txtai/ann/dense/numpy.py@@ -70,6 +70,10 @@ class NumPy(ANN):if self.qbits:# Calculate hamming score for integer vectorsscores = self.hammingscore(queries)++ # Zero out deleted (all-zero) rows. Unlike dot product, hamming scores them nonzero,+ # so they'd otherwise pass the caller's score > 0 filter and resurface in results.+ scores[:, self.all(self.backend == 0, axis=1)] = 0else:# Dot product on normalized vectors is equal to cosine similarityscores = self.dot(self.tensor(queries), self.backend.T)