What is a Toxicity Detection model
A Toxicity Detection model identifies whether a piece of text is unwelcome and, if so, for which reason.
What needs to be done
Implement a Toxicity Detection model that exposes the following public methods:
.train() method:
.train(output_path: Optional[str] = None, num_samples: int = config.DEFAULT_SYNTHEX_DATAPOINT_NUM, num_epochs: int = 3)`
The method should train the model to assign one of the following labels
safe
toxic
insulting
threatening
obscene
identity-attack
other-unsafe
to any piece of text.
.__call__(text: Union[str, list[str])
-
If a str is provided, the model should return any one of the labels listed above.
-
If a list[str] is provided, the model should return a list of labels, one per sentence.
.load(model_path: str)
Loads a pre-trained Toxicity Detection model from the specified path.
What is a Toxicity Detection model
A Toxicity Detection model identifies whether a piece of text is unwelcome and, if so, for which reason.
What needs to be done
Implement a Toxicity Detection model that exposes the following public methods:
.train()method:The method should train the model to assign one of the following labels
safetoxicinsultingthreateningobsceneidentity-attackother-unsafeto any piece of text.
.__call__(text: Union[str, list[str])If a
stris provided, the model should return any one of the labels listed above.If a
list[str]is provided, the model should return a list of labels, one per sentence..load(model_path: str)Loads a pre-trained Toxicity Detection model from the specified path.