Aan de slagGa gratis aan de slag

Toxiciteit controleren

Je werkt bij een socialmediabedrijf en moet de reacties op het platform beoordelen om te zorgen dat gebruikers zich aan de gedragscode houden.

Jouw taak is om het toxiciteitsniveau van de reacties van user_1 en user_2 zorgvuldig te beoordelen.

De toxiciteitsmetric is al voor je geladen als toxicity_metric.

Deze oefening maakt deel uit van de cursus

Introductie tot LLM’s in Python

Cursus bekijken

Oefeninstructies

  • Bereken de individuele toxiciteit van elke sequentie.
  • Bereken de maximale toxiciteit.
  • Bereken de toxiciteitsratio per reactie.

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'])
Code bewerken en uitvoeren