-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbase_verifier.py
More file actions
30 lines (23 loc) · 904 Bytes
/
base_verifier.py
File metadata and controls
30 lines (23 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
DEFAULT_VERIFIER_PROMPT_PATH = os.path.join(SCRIPT_DIR, "verifier_prompt.txt")
class BaseVerifier:
SUPPORTED_METRIC_CHOICES = None
def __init__(self, seed=1994, prompt_path=None):
prompt_path = prompt_path or DEFAULT_VERIFIER_PROMPT_PATH
self.seed = seed
self.verifier_prompt = self.load_verifier_prompt(prompt_path)
@staticmethod
def load_verifier_prompt(prompt_path: str) -> str:
with open(prompt_path, "r") as f:
return f.read()
def prepare_inputs(self, images, prompts, **kwargs):
"""
Prepare inputs for the verifier given images and prompts.
"""
raise NotImplementedError
def score(self, inputs, **kwargs):
"""
Score the given inputs and return a list of results.
"""
raise NotImplementedError