File size: 640 Bytes
48b5f4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
from transformers import pipeline

# Define candidate labels for classification
candidate_labels_spam = ['Spam', 'not Spam']
candidate_labels_urgent = ['Urgent', 'not Urgent']

model="MoritzLaurer/deberta-v3-large-zeroshot-v1.1-all-33"
model="SpamUrgencyDetection"
clf = pipeline("zero-shot-classification", model=model)
def predict(text):
    p_spam = clf(text, candidate_labels_spam)["labels"][0]
    p_urgent = clf(text, candidate_labels_urgent)["labels"][0]
    return p_spam,p_urgent


import pandas as pd
df = pd.read_csv("test.csv")

texts=df["text"]
for i in    range( len(texts)):
     print(texts[i],predict(texts[i]))