Lint creative_acr
This commit is contained in:
@@ -1,11 +1,17 @@
|
|||||||
from typing import Union, Generator
|
"""Module loading the CreativePromptTokenizingStrategy and similar classes"""
|
||||||
|
|
||||||
|
from typing import Tuple, Union, Generator
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from axolotl.prompt_tokenizers import InstructionPromptTokenizingStrategy
|
from axolotl.prompt_tokenizers import InstructionPromptTokenizingStrategy
|
||||||
|
|
||||||
|
|
||||||
class CreativeAnsweringPromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
|
class CreativeAnsweringPromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
|
||||||
def parse_instruction_fields(self, prompt) -> (str, str, str):
|
"""
|
||||||
|
Tokenizing strategy for Creative Answering
|
||||||
|
"""
|
||||||
|
|
||||||
|
def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
|
||||||
question = prompt["instruction"]
|
question = prompt["instruction"]
|
||||||
answer = prompt[
|
answer = prompt[
|
||||||
"revision"
|
"revision"
|
||||||
@@ -18,6 +24,10 @@ class CreativeAnsweringPromptTokenizingStrategy(InstructionPromptTokenizingStrat
|
|||||||
|
|
||||||
|
|
||||||
class CreativeCritiquePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
|
class CreativeCritiquePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
|
||||||
|
"""
|
||||||
|
Tokenizing strategy for Creative Critique
|
||||||
|
"""
|
||||||
|
|
||||||
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:
|
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:
|
||||||
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.
|
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.
|
||||||
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.
|
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}
|
|||||||
Answer: {answer}
|
Answer: {answer}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def parse_instruction_fields(self, prompt) -> (str, str, str):
|
def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
|
||||||
scores = yaml.dump(
|
scores = yaml.dump(
|
||||||
prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
|
prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
|
||||||
)
|
)
|
||||||
@@ -67,6 +77,10 @@ Answer: {answer}
|
|||||||
|
|
||||||
|
|
||||||
class CreativeRevisePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
|
class CreativeRevisePromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
|
||||||
|
"""
|
||||||
|
Tokenizing strategy for Creative Revise
|
||||||
|
"""
|
||||||
|
|
||||||
user_prompt = """Definitions:
|
user_prompt = """Definitions:
|
||||||
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.
|
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.
|
||||||
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.
|
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:
|
|||||||
{evaluation}
|
{evaluation}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def parse_instruction_fields(self, prompt) -> (str, str, str):
|
def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
|
||||||
scores = yaml.dump(
|
scores = yaml.dump(
|
||||||
prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
|
prompt["scores"], default_flow_style=False, Dumper=yaml.Dumper
|
||||||
)
|
)
|
||||||
@@ -101,13 +115,19 @@ Evaluation:
|
|||||||
|
|
||||||
|
|
||||||
class CreativePrompterBase:
|
class CreativePrompterBase:
|
||||||
|
"""
|
||||||
|
Base class for Creative Prompters
|
||||||
|
"""
|
||||||
|
|
||||||
system_prompt = ""
|
system_prompt = ""
|
||||||
prompt_input = "{system_prompt}\nUSER: {instruction}\nASSISTANT:"
|
prompt_input = "{system_prompt}\nUSER: {instruction}\nASSISTANT:"
|
||||||
|
|
||||||
def build_prompt(
|
def build_prompt(
|
||||||
self,
|
self,
|
||||||
instruction: str,
|
instruction: str,
|
||||||
input: Union[None, str] = None,
|
input: Union[ # pylint: disable=redefined-builtin, unused-argument
|
||||||
|
None, str
|
||||||
|
] = None,
|
||||||
output: Union[None, str] = None,
|
output: Union[None, str] = None,
|
||||||
) -> Generator[str, None, None]:
|
) -> Generator[str, None, None]:
|
||||||
if self.system_prompt:
|
if self.system_prompt:
|
||||||
@@ -120,14 +140,26 @@ class CreativePrompterBase:
|
|||||||
|
|
||||||
|
|
||||||
class CreativeAnswerPrompter(CreativePrompterBase):
|
class CreativeAnswerPrompter(CreativePrompterBase):
|
||||||
|
"""
|
||||||
|
Prompter for Creative Answering
|
||||||
|
"""
|
||||||
|
|
||||||
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."
|
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."
|
||||||
|
|
||||||
|
|
||||||
class CreativeCritiquePrompter(CreativePrompterBase):
|
class CreativeCritiquePrompter(CreativePrompterBase):
|
||||||
|
"""
|
||||||
|
Prompter for Creative Critique
|
||||||
|
"""
|
||||||
|
|
||||||
system_prompt = ""
|
system_prompt = ""
|
||||||
|
|
||||||
|
|
||||||
class CreativeRevisePrompter(CreativePrompterBase):
|
class CreativeRevisePrompter(CreativePrompterBase):
|
||||||
|
"""
|
||||||
|
Prompter for Creative Revise
|
||||||
|
"""
|
||||||
|
|
||||||
system_prompt = ""
|
system_prompt = ""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user