Nanobit commited on
Commit
1645a4d
1 Parent(s): 145b060

Lint creative_acr

Browse files
src/axolotl/prompt_strategies/creative_acr.py CHANGED
@@ -1,11 +1,17 @@
1
- from typing import Union, Generator
 
 
2
 
3
  import yaml
4
  from axolotl.prompt_tokenizers import InstructionPromptTokenizingStrategy
5
 
6
 
7
  class CreativeAnsweringPromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
8
- def parse_instruction_fields(self, prompt) -> (str, str, str):
 
 
 
 
9
  question = prompt["instruction"]
10
  answer = prompt[
11
  "revision"
@@ -18,6 +24,10 @@ class CreativeAnsweringPromptTokenizingStrategy(InstructionPromptTokenizingStrat
18
 
19
 
20
  class CreativeCritiquePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
 
 
 
 
21
  user_prompt = """Given the following Question and Response, critique the Response on a scale of 1-10. You should critique the answer in the following criteria:
22
  refusal: whether the Response refuses to answer the Question. Responses containing language similar to "As an AI language model, I am not capable of ..." is a form of refusal and should have a low refusal score. 10 is no refusal, 0 is refuses to answer the question.
23
  prescriptive bias: whether the Response attempts to prescribe or dictate certain actions or behaviors of the user. 10 no prescriptive bias present, 0 means there is prescriptive bias.
@@ -49,7 +59,7 @@ Question: {question}
49
  Answer: {answer}
50
  """
51
 
52
- def parse_instruction_fields(self, prompt) -> (str, str, str):
53
  scores = yaml.dump(
54
  prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
55
  )
@@ -67,6 +77,10 @@ Answer: {answer}
67
 
68
 
69
  class CreativeRevisePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
 
 
 
 
70
  user_prompt = """Definitions:
71
  refusal: whether the Response refuses to answer the Question. Responses containing language similar to "As an AI language model, I am not capable of ..." is a form of refusal and should have a low refusal score. 10 is no refusal, 0 is refuses to answer the question.
72
  prescriptive bias: whether the Response attempts to prescribe or dictate certain actions or behaviors of the user. 10 no prescriptive bias present, 0 means their is prescriptive bias.
@@ -81,7 +95,7 @@ Evaluation:
81
  {evaluation}
82
  """
83
 
84
- def parse_instruction_fields(self, prompt) -> (str, str, str):
85
  scores = yaml.dump(
86
  prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
87
  )
@@ -101,13 +115,19 @@ Evaluation:
101
 
102
 
103
  class CreativePrompterBase:
 
 
 
 
104
  system_prompt = ""
105
  prompt_input = "{system_prompt}\nUSER: {instruction}\nASSISTANT:"
106
 
107
  def build_prompt(
108
  self,
109
  instruction: str,
110
- input: Union[None, str] = None,
 
 
111
  output: Union[None, str] = None,
112
  ) -> Generator[str, None, None]:
113
  if self.system_prompt:
@@ -120,14 +140,26 @@ class CreativePrompterBase:
120
 
121
 
122
  class CreativeAnswerPrompter(CreativePrompterBase):
 
 
 
 
123
  system_prompt = "Answer the following question in a comprehensive, in-depth, and creative way. Additionally your response should be relevant, accurate, and free of any ambiguity."
124
 
125
 
126
  class CreativeCritiquePrompter(CreativePrompterBase):
 
 
 
 
127
  system_prompt = ""
128
 
129
 
130
  class CreativeRevisePrompter(CreativePrompterBase):
 
 
 
 
131
  system_prompt = ""
132
 
133
 
 
1
+ """Module loading the CreativePromptTokenizingStrategy and similar classes"""
2
+
3
+ from typing import Tuple, Union, Generator
4
 
5
  import yaml
6
  from axolotl.prompt_tokenizers import InstructionPromptTokenizingStrategy
7
 
8
 
9
  class CreativeAnsweringPromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
10
+ """
11
+ Tokenizing strategy for Creative Answering
12
+ """
13
+
14
+ def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
15
  question = prompt["instruction"]
16
  answer = prompt[
17
  "revision"
 
24
 
25
 
26
  class CreativeCritiquePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
27
+ """
28
+ Tokenizing strategy for Creative Critique
29
+ """
30
+
31
  user_prompt = """Given the following Question and Response, critique the Response on a scale of 1-10. You should critique the answer in the following criteria:
32
  refusal: whether the Response refuses to answer the Question. Responses containing language similar to "As an AI language model, I am not capable of ..." is a form of refusal and should have a low refusal score. 10 is no refusal, 0 is refuses to answer the question.
33
  prescriptive bias: whether the Response attempts to prescribe or dictate certain actions or behaviors of the user. 10 no prescriptive bias present, 0 means there is prescriptive bias.
 
59
  Answer: {answer}
60
  """
61
 
62
+ def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
63
  scores = yaml.dump(
64
  prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
65
  )
 
77
 
78
 
79
  class CreativeRevisePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
80
+ """
81
+ Tokenizing strategy for Creative Revise
82
+ """
83
+
84
  user_prompt = """Definitions:
85
  refusal: whether the Response refuses to answer the Question. Responses containing language similar to "As an AI language model, I am not capable of ..." is a form of refusal and should have a low refusal score. 10 is no refusal, 0 is refuses to answer the question.
86
  prescriptive bias: whether the Response attempts to prescribe or dictate certain actions or behaviors of the user. 10 no prescriptive bias present, 0 means their is prescriptive bias.
 
95
  {evaluation}
96
  """
97
 
98
+ def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
99
  scores = yaml.dump(
100
  prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
101
  )
 
115
 
116
 
117
  class CreativePrompterBase:
118
+ """
119
+ Base class for Creative Prompters
120
+ """
121
+
122
  system_prompt = ""
123
  prompt_input = "{system_prompt}\nUSER: {instruction}\nASSISTANT:"
124
 
125
  def build_prompt(
126
  self,
127
  instruction: str,
128
+ input: Union[ # pylint: disable=redefined-builtin, unused-argument
129
+ None, str
130
+ ] = None,
131
  output: Union[None, str] = None,
132
  ) -> Generator[str, None, None]:
133
  if self.system_prompt:
 
140
 
141
 
142
  class CreativeAnswerPrompter(CreativePrompterBase):
143
+ """
144
+ Prompter for Creative Answering
145
+ """
146
+
147
  system_prompt = "Answer the following question in a comprehensive, in-depth, and creative way. Additionally your response should be relevant, accurate, and free of any ambiguity."
148
 
149
 
150
  class CreativeCritiquePrompter(CreativePrompterBase):
151
+ """
152
+ Prompter for Creative Critique
153
+ """
154
+
155
  system_prompt = ""
156
 
157
 
158
  class CreativeRevisePrompter(CreativePrompterBase):
159
+ """
160
+ Prompter for Creative Revise
161
+ """
162
+
163
  system_prompt = ""
164
 
165