diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-04-24 09:09:24 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-04-24 09:09:24 +0200 |
commit | 9e0cbcb4e7f1f3f95f304046d3190c6ebc4d3901 (patch) | |
tree | 5d890ce2705b79f23d63988c140d08edadaf35c5 /rag/retriever/rerank/abstract.py | |
parent | 2e85325639ce3827cc2eb32f9750dfa873e3a480 (diff) |
Reformat and fix typo
Diffstat (limited to 'rag/retriever/rerank/abstract.py')
-rw-r--r-- | rag/retriever/rerank/abstract.py | 17 |
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 |