Skip to content

Commit

Permalink
Use model 'luminous-nextgen-7b-control-384k' for safety classification
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAchtnerAA committed Apr 18, 2024
1 parent 663ddb2 commit fe7d416
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/intelligence_layer/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def __init__(
"luminous-base-control-20240215",
"luminous-extended-control-20240215",
"luminous-supreme-control-20240215",
"luminous-nextgen-7b-control-384k",
] = "luminous-base-control",
client: Optional[AlephAlphaClientProtocol] = None,
) -> None:
Expand Down
27 changes: 15 additions & 12 deletions src/intelligence_layer/core/safety_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,27 @@ def __init__(
self,
model: ControlModel | None = None,
) -> None:
self._model = model or LuminousControlModel("luminous-base-control")
self._model = model or LuminousControlModel("luminous-nextgen-7b-control-384k")

def do_run(
self, input: SafetyClassifyInput, task_span: TaskSpan
) -> SafetyClassifyOutput:
instruction = """Your task is to act as a safety classifier for text. There are the following categories:
hatespeech,
sexual,
religious,
medical,
self_harm,
illegal_activities,
violence,
insult,
profanity
instruction = """Your task is to act as a safety classifier for text. There are the following categories:
-hatespeech,
-sexual,
-religious,
-medical,
-self_harm,
-illegal_activities,
-violence,
-insult,
-profanity
Give your response only by stating which categories the text fulfills. Return no text if the text is safe.
Your response should be a single line containing the labels of which categories the text fulfills.
Return the label 'safe' if the text is safe.
Please make sure your response is a single line.
"""

if not instruction:
raise ValueError("Could not find `instruction` for safety classifier.")
completion = self._model.complete(
Expand Down

0 comments on commit fe7d416

Please sign in to comment.