💡 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
Handle empty token list with word vectorization, closes #861
davidmezzettie2e81cd2e36a
diff --git a/src/python/txtai/vectors/words.py b/src/python/txtai/vectors/words.pyindex cc14b970..99496579 100644--- a/src/python/txtai/vectors/words.py+++ b/src/python/txtai/vectors/words.py@@ -125,9 +125,10 @@ class WordVectors(Vectors):# Iterate over each data element, tokenize (if necessary) and build an aggregated embeddings vectorembeddings = []for tokens in data:- # Convert to tokens if necessary+ # Convert to tokens, if necessary. If tokenized list is empty, use input string.if isinstance(tokens, str):- tokens = Tokenizer.tokenize(tokens)+ tokenlist = Tokenizer.tokenize(tokens)+ tokens = tokenlist if tokenlist else [tokens]# Generate weights for each vector using a scoring methodweights = self.scoring.weights(tokens) if self.scoring else None