Views
No views yet
distilbert-base-uncased1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="your-username/content-moderation-distilbert",
6 tokenizer="your-username/content-moderation-distilbert",
7 return_all_scores=True,
8 function_to_apply="sigmoid" # multi-label classification
9)
10
11texts = [
12 "You are an amazing person and I respect you.",
13 "I hate you, you are disgusting!",
14 "I will not kill you tomorrow"
15]
16
17for t in texts:
18 preds = classifier(t)
19 print(f"\nInput: {t}")
20 for label in preds[0]:
21 print(f"{label['label']}: {label['score']:.3f}")