Add Reranker pipeline, closes #960

This commit is contained in:
davidmezzetti
2025-08-27 15:00:12 -04:00
parent 0e54ad3c3f
commit b8980bc5be
13 changed files with 295 additions and 3 deletions
+41
View File
@@ -92,6 +92,27 @@ rag:
output: flatten
"""
# Configuration for reranker
RERANK = """
# Index file path
path: %s
# Allow indexing of documents
writable: True
# Embeddings settings
embeddings:
path: sentence-transformers/nli-mpnet-base-v2
content: True
# Similarity and Reranking settings
similarity:
path: neuml/colbert-bert-tiny
lateencode: True
reranker:
"""
class TestEmbeddings(unittest.TestCase):
"""
@@ -401,6 +422,26 @@ class TestEmbeddings(unittest.TestCase):
response = self.client.post("batchrag", json={"queries": ["bear", "bear"]}).json()
self.assertEqual(len(response), 2)
def testXRerank(self):
"""
Test rerank via API
"""
# Re-create model with custom functions
self.client = TestEmbeddings.start(RERANK)
# Index data
self.client.post("add", json=[{"id": x, "text": row} for x, row in enumerate(self.data)])
self.client.get("index")
uid = self.client.get("rerank?query=bear").json()[0]["id"]
self.assertEqual(uid, "3")
results = self.client.post("batchrerank", json={"queries": ["bear", "bear"]}).json()
uids = [result[0]["id"] for result in results]
self.assertEqual(uids, ["3", "3"])
class Elements:
"""