Skip to content

Commit

Permalink
Add ability for extractor to reference another pipeline in applicatio…
Browse files Browse the repository at this point in the history
…ns, closes #501
  • Loading branch information
davidmezzetti committed Jul 8, 2023
1 parent 4c205c2 commit 9740126
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/python/txtai/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def pipes(self):
if "." in key:
pipelines.append(key)

# Move dependent pipelines to end of list
pipelines = sorted(pipelines, key=lambda x: x in ["similarity", "extractor"])

# Create pipelines
for pipeline in pipelines:
if pipeline in self.config:
Expand All @@ -115,6 +118,11 @@ def pipes(self):
if pipeline == "extractor" and "similarity" not in config:
# Add placeholder, will be set to embeddings index once initialized
config["similarity"] = None

# Resolve reference pipeline, if necessary
if config.get("path") in self.pipelines:
config["path"] = self.pipelines[config["path"]]

elif pipeline == "similarity" and "path" not in config and "labels" in self.pipelines:
config["model"] = self.pipelines["labels"]

Expand Down
6 changes: 5 additions & 1 deletion test/python/testapi/testembeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
# Allow indexing of documents
writable: True
# Questions settings
questions:
path: distilbert-base-cased-distilled-squad
# Embeddings settings
embeddings:
path: sentence-transformers/nli-mpnet-base-v2
# Extractor settings
extractor:
path: distilbert-base-cased-distilled-squad
path: questions
"""

# Configuration for a read-only embeddings index
Expand Down

0 comments on commit 9740126

Please sign in to comment.