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 all supported pipeline config via API. Default to smaller models for labels to work with GitHub Actions.

davidmezzetti79aae2d31f63
diff --git a/src/python/txtai/api.py b/src/python/txtai/api.py
index 88303b6e..958e1842 100644
--- a/src/python/txtai/api.py
+++ b/src/python/txtai/api.py
@@ -48,11 +48,14 @@ class API(object):
# Extractor settings
extractor = self.config["extractor"]
- self.extractor = Extractor(self.embeddings, extractor["path"], extractor.get("quantize"))
+ self.extractor = Extractor(self.embeddings, extractor.get("path"), extractor.get("quantize"),
+ extractor.get("gpu"))
# Create labels instance
if "labels" in self.config:
- self.labels = Labels()
+ labels = self.config["labels"]
+
+ self.labels = Labels(labels.get("path"), labels.get("quantize"), labels.get("gpu"))
def size(self, request):
"""
diff --git a/src/python/txtai/pipeline.py b/src/python/txtai/pipeline.py
index d80062f8..d57d677a 100644
--- a/src/python/txtai/pipeline.py
+++ b/src/python/txtai/pipeline.py
@@ -8,7 +8,7 @@ from transformers import pipeline
class Pipeline(object):
"""
- Light wrapper around HuggingFace's pipeline component for selected tasks. Adds support for model
+ Light wrapper around Hugging Face's pipeline component for selected tasks. Adds support for model
quantization and minor interface changes.
"""
@@ -18,7 +18,8 @@ class Pipeline(object):
Args:
task: pipeline task or category
- path: optional path to model, will use default model for task if not provided
+ path: optional path to model, accepts Hugging Face model hub id or local path,
+ uses default model for task if not provided
quantize: if model should be quantized, defaults to False
gpu: if gpu inference should be used (only works if GPUs are available)
"""
diff --git a/test/python/testapi.py b/test/python/testapi.py
index 31073f0f..97f13062 100644
--- a/test/python/testapi.py
+++ b/test/python/testapi.py
@@ -33,6 +33,7 @@ extractor:
# Labels settings
labels:
+ path: squeezebert/squeezebert-mnli
"""
# Configuration that reads an existing similarity search index
diff --git a/test/python/testlabels.py b/test/python/testlabels.py
index 5df843fc..d5f15155 100644
--- a/test/python/testlabels.py
+++ b/test/python/testlabels.py
@@ -16,5 +16,5 @@ class TestLabels(unittest.TestCase):
Test labels
"""
- labels = Labels()
+ labels = Labels("squeezebert/squeezebert-mnli")
self.assertEqual(labels("This is the best sentence ever", ["positive", "negative"])[0][0], "positive")