Skip to content

Commit

Permalink
🎨 Format Python code with psf/black
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRootOf3 committed Mar 22, 2024
1 parent 6a2c218 commit 5eb4991
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 47 deletions.
78 changes: 39 additions & 39 deletions eval_harmfulness/evaluation_scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,58 @@


__all__ = [
'IGNORE_INDEX',
'DEFAULT_BOS_TOKEN',
'DEFAULT_EOS_TOKEN',
'DEFAULT_PAD_TOKEN',
'DEFAULT_UNK_TOKEN',
'PROMPT_BEGIN',
'PROMPT_USER',
'PROMPT_ASSISTANT',
'PROMPT_INPUT',
'PROMPT_DICT',
'ADAM_BETAS',
'NUM_LABELS',
'LABEL_NAMES',
'ID2LABELS',
"IGNORE_INDEX",
"DEFAULT_BOS_TOKEN",
"DEFAULT_EOS_TOKEN",
"DEFAULT_PAD_TOKEN",
"DEFAULT_UNK_TOKEN",
"PROMPT_BEGIN",
"PROMPT_USER",
"PROMPT_ASSISTANT",
"PROMPT_INPUT",
"PROMPT_DICT",
"ADAM_BETAS",
"NUM_LABELS",
"LABEL_NAMES",
"ID2LABELS",
]


IGNORE_INDEX: int = -100
DEFAULT_BOS_TOKEN: str = '<s>'
DEFAULT_EOS_TOKEN: str = '</s>'
DEFAULT_PAD_TOKEN: str = '<pad>'
DEFAULT_UNK_TOKEN: str = '<unk>'
DEFAULT_BOS_TOKEN: str = "<s>"
DEFAULT_EOS_TOKEN: str = "</s>"
DEFAULT_PAD_TOKEN: str = "<pad>"
DEFAULT_UNK_TOKEN: str = "<unk>"

PROMPT_BEGIN: str = 'BEGINNING OF CONVERSATION: '
PROMPT_USER: str = 'USER: {input} '
PROMPT_ASSISTANT: str = 'ASSISTANT:' # should not have a space at the end
PROMPT_BEGIN: str = "BEGINNING OF CONVERSATION: "
PROMPT_USER: str = "USER: {input} "
PROMPT_ASSISTANT: str = "ASSISTANT:" # should not have a space at the end
PROMPT_INPUT: str = PROMPT_BEGIN + PROMPT_USER + PROMPT_ASSISTANT

PROMPT_DICT: dict[str, str] = {
'prompt_begin': PROMPT_BEGIN,
'prompt_user': PROMPT_USER,
'prompt_assistant': PROMPT_ASSISTANT,
'prompt_input': PROMPT_INPUT,
"prompt_begin": PROMPT_BEGIN,
"prompt_user": PROMPT_USER,
"prompt_assistant": PROMPT_ASSISTANT,
"prompt_input": PROMPT_INPUT,
}

ADAM_BETAS: tuple[float, float] = (0.9, 0.95)

LABEL_NAMES: list[str] = [
'animal_abuse',
'child_abuse',
'controversial_topics,politics',
'discrimination,stereotype,injustice',
'drug_abuse,weapons,banned_substance',
'financial_crime,property_crime,theft',
'hate_speech,offensive_language',
'misinformation_regarding_ethics,laws_and_safety',
'non_violent_unethical_behavior',
'privacy_violation',
'self_harm',
'sexually_explicit,adult_content',
'terrorism,organized_crime',
'violence,aiding_and_abetting,incitement',
"animal_abuse",
"child_abuse",
"controversial_topics,politics",
"discrimination,stereotype,injustice",
"drug_abuse,weapons,banned_substance",
"financial_crime,property_crime,theft",
"hate_speech,offensive_language",
"misinformation_regarding_ethics,laws_and_safety",
"non_violent_unethical_behavior",
"privacy_violation",
"self_harm",
"sexually_explicit,adult_content",
"terrorism,organized_crime",
"violence,aiding_and_abetting,incitement",
]

NUM_LABELS: int = len(LABEL_NAMES)
Expand Down
24 changes: 16 additions & 8 deletions eval_harmfulness/evaluation_scripts/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def predict(
batch_size: int,
return_bool: Literal[False],
threshold: float,
) -> list[dict[str, float]]: ...
) -> list[dict[str, float]]:
...

@overload
def predict(
Expand All @@ -231,7 +232,8 @@ def predict(
batch_size: int,
return_bool: Literal[True],
threshold: float,
) -> list[dict[str, bool]]: ...
) -> list[dict[str, bool]]:
...

@overload
def predict(
Expand All @@ -240,7 +242,8 @@ def predict(
batch_size: int,
return_bool: Literal[False],
threshold: float,
) -> dict[str, float]: ...
) -> dict[str, float]:
...

@overload
def predict(
Expand All @@ -249,7 +252,8 @@ def predict(
batch_size: int,
return_bool: Literal[True],
threshold: float,
) -> dict[str, bool]: ...
) -> dict[str, bool]:
...

@torch.inference_mode()
def predict(
Expand Down Expand Up @@ -322,7 +326,8 @@ def predict( # pylint: disable=arguments-differ
batch_size: int,
return_bool: Literal[False],
threshold: float,
) -> list[dict[str, float]]: ...
) -> list[dict[str, float]]:
...

@overload
def predict( # pylint: disable=arguments-differ
Expand All @@ -332,7 +337,8 @@ def predict( # pylint: disable=arguments-differ
batch_size: int,
return_bool: Literal[True],
threshold: float,
) -> list[dict[str, bool]]: ...
) -> list[dict[str, bool]]:
...

@overload
def predict( # pylint: disable=arguments-differ
Expand All @@ -342,7 +348,8 @@ def predict( # pylint: disable=arguments-differ
batch_size: int,
return_bool: Literal[False],
threshold: float,
) -> dict[str, float]: ...
) -> dict[str, float]:
...

@overload
def predict( # pylint: disable=arguments-differ
Expand All @@ -352,7 +359,8 @@ def predict( # pylint: disable=arguments-differ
batch_size: int,
return_bool: Literal[True],
threshold: float,
) -> dict[str, bool]: ...
) -> dict[str, bool]:
...

@torch.inference_mode()
def predict( # pylint: disable=arguments-differ,arguments-renamed
Expand Down

0 comments on commit 5eb4991

Please sign in to comment.