forked from spcl/graph-of-thoughts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompter.py
86 lines (73 loc) · 2.81 KB
/
prompter.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright (c) 2023 ETH Zurich.
# All rights reserved.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# main authors: Robert Gerstenberger, Nils Blach
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Dict, List
class Prompter(ABC):
"""
Abstract base class that defines the interface for all prompters.
Prompters are used to generate the prompts for the language models.
"""
@abstractmethod
def aggregation_prompt(self, state_dicts: List[Dict], **kwargs) -> str:
"""
Generate a aggregation prompt for the language model.
:param state_dicts: The thought states that should be aggregated.
:type state_dicts: List[Dict]
:param kwargs: Additional keyword arguments.
:return: The aggregation prompt.
:rtype: str
"""
pass
@abstractmethod
def improve_prompt(self, **kwargs) -> str:
"""
Generate an improve prompt for the language model.
The thought state is unpacked to allow for additional keyword arguments
and concrete implementations to specify required arguments explicitly.
:param kwargs: Additional keyword arguments.
:return: The improve prompt.
:rtype: str
"""
pass
@abstractmethod
def generate_prompt(self, num_branches: int, **kwargs) -> str:
"""
Generate a generate prompt for the language model.
The thought state is unpacked to allow for additional keyword arguments
and concrete implementations to specify required arguments explicitly.
:param num_branches: The number of responses the prompt should ask the LM to generate.
:type num_branches: int
:param kwargs: Additional keyword arguments.
:return: The generate prompt.
:rtype: str
"""
pass
@abstractmethod
def validation_prompt(self, **kwargs) -> str:
"""
Generate a validation prompt for the language model.
The thought state is unpacked to allow for additional keyword arguments
and concrete implementations to specify required arguments explicitly.
:param kwargs: Additional keyword arguments.
:return: The validation prompt.
:rtype: str
"""
pass
@abstractmethod
def score_prompt(self, state_dicts: List[Dict], **kwargs) -> str:
"""
Generate a score prompt for the language model.
:param state_dicts: The thought states that should be scored,
if more than one, they should be scored together.
:type state_dicts: List[Dict]
:param kwargs: Additional keyword arguments.
:return: The score prompt.
:rtype: str
"""
pass