From 9e0cbcb4e7f1f3f95f304046d3190c6ebc4d3901 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Wed, 24 Apr 2024 09:09:24 +0200 Subject: Reformat and fix typo --- rag/retriever/rerank/abstract.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 rag/retriever/rerank/abstract.py (limited to 'rag/retriever/rerank/abstract.py') 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 -- cgit v1.2.3-70-g09d2