summaryrefslogtreecommitdiff
path: root/rag/retriever/rerank/abstract.py
diff options
context:
space:
mode:
Diffstat (limited to 'rag/retriever/rerank/abstract.py')
-rw-r--r--rag/retriever/rerank/abstract.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/rag/retriever/rerank/abstract.py b/rag/retriever/rerank/abstract.py
new file mode 100644
index 0000000..b96b70a
--- /dev/null
+++ b/rag/retriever/rerank/abstract.py
@@ -0,0 +1,17 @@
+from abc import abstractmethod
+
+from rag.generator.prompt import Prompt
+
+
+class AbstractReranker(type):
+ _instances = {}
+
+ def __call__(cls, *args, **kwargs):
+ if cls not in cls._instances:
+ instance = super().__call__(*args, **kwargs)
+ cls._instances[cls] = instance
+ return cls._instances[cls]
+
+ @abstractmethod
+ def rank(self, prompt: Prompt) -> Prompt:
+ return prompt