Toxizität prüfen
Du arbeitest bei einem Social-Media-Unternehmen und sollst die Kommentare auf der Plattform überprüfen, um sicherzustellen, dass die Nutzer sich an die Verhaltensregeln halten.
Deine Aufgabe ist es, die Toxizität der Kommentare von user_1 und user_2 genau zu prüfen.
Die Toxizitätskennzahl wurde für dich als toxicity_metric geladen.
Diese Übung ist Teil des Kurses
Einführung in LLMs mit Python
Anleitung zur Übung
- Berechne die Toxizität jeder einzelnen Sequenz.
- Berechne die maximale Toxizität.
- Berechne das jeweilige Toxizitätsverhältnis für jeden Kommentar.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# 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'])