Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Allow downloading models directly from sentence-transformers, closes #72

davidmezzettieb981b8cdcd6
diff --git a/src/python/txtai/vectors/transformers.py b/src/python/txtai/vectors/transformers.py
index 7e17f06f..87f14281 100644
--- a/src/python/txtai/vectors/transformers.py
+++ b/src/python/txtai/vectors/transformers.py
@@ -19,10 +19,17 @@ class TransformersVectors(Vectors):
"""
def load(self, path):
- model = Transformer(path)
- pooling = Pooling(model.get_word_embedding_dimension())
+ modelhub = self.config.get("modelhub", True)
- return SentenceTransformer(modules=[model, pooling])
+ # Download model from the model hub (default)
+ if modelhub:
+ model = Transformer(path)
+ pooling = Pooling(model.get_word_embedding_dimension())
+
+ return SentenceTransformer(modules=[model, pooling])
+
+ # Download model directly from sentence transformers if model hub disabled
+ return SentenceTransformer(path)
def index(self, documents):
ids, dimensions, stream = [], None, None