A basic template for moderating comments. For each comment, we generate a moderation score and assign labels using prompts sent to LLMs hosted on AWS Bedrock.
- Claude 3.5
- Llama 3.3 70b
- Deepseek R1
- We fetch data from the mmathys/openai-moderation-api-evaluation
- Send each comment to the LLM for moderation analysis.
- For each comment, generate a dictionary containing:
Model Logic: Explanation of why the model assigned specific scores and labels.Ai Labels: Labels assigned by the model.Human Labels: Labels annotated in the dataset.
- Pass the resulting dictionary to the evaluation step.
We evaluate the model output by constructing a confusion matrix, defined as follows
True Positive: The model correctly identified labels that match the annotated data.True Negative: The model correctly did not flag the comment, matching the annotation.False Positive: The model assigned a label that is not present in the annotated data.False Negative: The model failed to assign a label that should have been applied, according to the annotation.
Some comments in the dataset are highly toxic or sensitive. As a result, certain LLMs may refuse to analyze them due to safety constraints. For more comprehensive testing, consider using uncensored or less restrictive models.