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
.
Este exercício faz parte do curso
Introduction to LLMs in Python
Instruções do exercício
- Calculate the individual toxicity of each sequence.
- Calculate the the maximum toxicity.
- Calculate the toxicity ratio per comment.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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'])