Checking toxicity
You work at a social media company and need to evaluate the comments that are being left on the platform to ensure users are respecting the code of conduct.
Your task is to carefully assess the toxicity level of comments of user_1 and user_2.
The toxicity metric has been loaded for you as toxicity_metric.
Deze oefening maakt deel uit van de cursus
Introduction to LLMs in Python
Oefeninstructies
- Calculate the individual toxicity of each sequence.
- Calculate the the maximum toxicity.
- Calculate the toxicity ratio per comment.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Calculate the individual toxicities
toxicity_1 = toxicity_metric.compute(predictions=____)
toxicity_2 = toxicity_metric.compute(predictions=____)
print("Toxicities (user_1):", toxicity_1['toxicity'])
print("Toxicities (user_2): ", toxicity_2['toxicity'])
# Calculate the maximum toxicities
toxicity_1_max = toxicity_metric.compute(____)
toxicity_2_max = toxicity_metric.compute(____)
print("Maximum toxicity (user_1):", toxicity_1_max['max_toxicity'])
print("Maximum toxicity (user_2): ", toxicity_2_max['max_toxicity'])
# Calculate the toxicity ratios
toxicity_1_ratio = ____(____)
toxicity_2_ratio = ____(____)
print("Toxicity ratio (user_1):", toxicity_1_ratio['toxicity_ratio'])
print("Toxicity ratio (user_2): ", toxicity_2_ratio['toxicity_ratio'])