💡 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
Improve hybrid scoring algorithm, closes #931
davidmezzetti9c3bf13d39d0
diff --git a/src/python/txtai/embeddings/search/base.py b/src/python/txtai/embeddings/search/base.pyindex e3c040bf..9461c74e 100644--- a/src/python/txtai/embeddings/search/base.py+++ b/src/python/txtai/embeddings/search/base.py@@ -102,12 +102,13 @@ class Search:if index:return self.subindex(queries, limit, weights, index)- # Run against base index- dense = self.dense(queries, limit) if self.ann else None- sparse = self.sparse(queries, limit) if self.scoring else None+ # Run against base indexes+ hybrid = self.ann and self.scoring+ dense = self.dense(queries, limit * 10 if hybrid else limit) if self.ann else None+ sparse = self.sparse(queries, limit * 10 if hybrid else limit) if self.scoring else None# Combine scores together- if dense and sparse:+ if hybrid:# Create weights array if single number passedif isinstance(weights, (int, float)):weights = [weights, 1 - weights]