-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement inheritance for each risk type
Signed-off-by: Martín Santillán Cooper <[email protected]>
- Loading branch information
1 parent
26d091f
commit 0aa47f1
Showing
20 changed files
with
211 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from unitxt import add_to_catalog | ||
from unitxt.metrics import GraniteGuardianMetric | ||
from unitxt.metrics import GraniteGuardianBase, RISK_TYPE_TO_CLASS | ||
|
||
for risk_type, risk_names in GraniteGuardianMetric.available_risks.items(): | ||
for risk_type, risk_names in GraniteGuardianBase.available_risks.items(): | ||
for risk_name in risk_names: | ||
metric_name = f"""granite_guardian.{risk_type.value}.{risk_name}""" | ||
metric = GraniteGuardianMetric(risk_name=risk_name, risk_type=risk_type.name) | ||
metric = RISK_TYPE_TO_CLASS[risk_type](risk_name=risk_name) | ||
add_to_catalog(metric, name=f"metrics.{metric_name}", overwrite=True) |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/agentic_risk/function_call.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "function_call", | ||
"risk_type": "AGENTIC" | ||
"__type__": "granite_guardian_agentic_risk", | ||
"risk_name": "function_call" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/assistant_risk/harm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "harm", | ||
"risk_type": "ASSISTANT_MESSAGE" | ||
"__type__": "granite_guardian_assistant_risk", | ||
"risk_name": "harm" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/assistant_risk/profanity.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "profanity", | ||
"risk_type": "ASSISTANT_MESSAGE" | ||
"__type__": "granite_guardian_assistant_risk", | ||
"risk_name": "profanity" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/assistant_risk/social_bias.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "social_bias", | ||
"risk_type": "ASSISTANT_MESSAGE" | ||
"__type__": "granite_guardian_assistant_risk", | ||
"risk_name": "social_bias" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/assistant_risk/unethical_behavior.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "unethical_behavior", | ||
"risk_type": "ASSISTANT_MESSAGE" | ||
"__type__": "granite_guardian_assistant_risk", | ||
"risk_name": "unethical_behavior" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/assistant_risk/violence.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "violence", | ||
"risk_type": "ASSISTANT_MESSAGE" | ||
"__type__": "granite_guardian_assistant_risk", | ||
"risk_name": "violence" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/rag_risk/answer_relevance.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "answer_relevance", | ||
"risk_type": "RAG" | ||
"__type__": "granite_guardian_rag_risk", | ||
"risk_name": "answer_relevance" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/rag_risk/context_relevance.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "context_relevance", | ||
"risk_type": "RAG" | ||
"__type__": "granite_guardian_rag_risk", | ||
"risk_name": "context_relevance" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/rag_risk/groundedness.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "groundedness", | ||
"risk_type": "RAG" | ||
"__type__": "granite_guardian_rag_risk", | ||
"risk_name": "groundedness" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/user_risk/harm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "harm", | ||
"risk_type": "USER_MESSAGE" | ||
"__type__": "granite_guardian_user_risk", | ||
"risk_name": "harm" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/user_risk/jailbreak.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "jailbreak", | ||
"risk_type": "USER_MESSAGE" | ||
"__type__": "granite_guardian_user_risk", | ||
"risk_name": "jailbreak" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/user_risk/profanity.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "profanity", | ||
"risk_type": "USER_MESSAGE" | ||
"__type__": "granite_guardian_user_risk", | ||
"risk_name": "profanity" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/user_risk/social_bias.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "social_bias", | ||
"risk_type": "USER_MESSAGE" | ||
"__type__": "granite_guardian_user_risk", | ||
"risk_name": "social_bias" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/user_risk/unethical_behavior.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "unethical_behavior", | ||
"risk_type": "USER_MESSAGE" | ||
"__type__": "granite_guardian_user_risk", | ||
"risk_name": "unethical_behavior" | ||
} |
5 changes: 2 additions & 3 deletions
5
src/unitxt/catalog/metrics/granite_guardian/user_risk/violence.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"__type__": "granite_guardian_metric", | ||
"risk_name": "violence", | ||
"risk_type": "USER_MESSAGE" | ||
"__type__": "granite_guardian_user_risk", | ||
"risk_name": "violence" | ||
} |
Oops, something went wrong.