Views
No views yet
1
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4 tokenizer = AutoTokenizer.from_pretrained("AyoubChLin/DistilBERT_ZeroShot")
5
6 model = AutoModelForSequenceClassification.from_pretrained("AyoubChLin/DistilBERT_ZeroShot")
71
2
3 from transformers import pipeline
4
5 # Create a zero-shot classification pipeline
6 classifier = pipeline("zero-shot-classification", model=model, tokenizer=tokenizer)
7
8 # Classify a sentence
9 sentence = "The latest scientific breakthroughs in medicine"
10 candidate_labels = ["politics", "sports", "technology", "business"]
11
12 result = classifier(sentence, candidate_labels)
13
14 print(result)
15