Kom igångKom igång gratis

Kontrollera toxicitet

Du arbetar på ett företag inom sociala medier och behöver utvärdera kommentarer som lämnas på plattformen för att säkerställa att användarna följer uppförandekoden.

Din uppgift är att noggrant bedöma toxicitetsnivån i kommentarerna från user_1 och user_2.

Toxicitetsmåttet har laddats in åt dig som toxicity_metric.

Den här övningen är en del av kursen

Introduktion till LLM:er i Python

Visa kurs

Övningsinstruktioner

  • Beräkna den individuella toxiciteten för varje sekvens.
  • Beräkna den maximala toxiciteten.
  • Beräkna toxicitetskvoten per kommentar.

Interaktiv övning med praktiskt arbete

Testa den här övningen genom att slutföra den här exempelkoden.

# 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'])
Redigera och kör kod