Upload usage.py
Browse files
usage.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Define candidate labels for classification
|
5 |
+
candidate_labels_spam = ['Spam', 'not Spam']
|
6 |
+
candidate_labels_urgent = ['Urgent', 'not Urgent']
|
7 |
+
|
8 |
+
model="MoritzLaurer/deberta-v3-large-zeroshot-v1.1-all-33"
|
9 |
+
model="SpamUrgencyDetection"
|
10 |
+
clf = pipeline("zero-shot-classification", model=model)
|
11 |
+
def predict(text):
|
12 |
+
p_spam = clf(text, candidate_labels_spam)["labels"][0]
|
13 |
+
p_urgent = clf(text, candidate_labels_urgent)["labels"][0]
|
14 |
+
return p_spam,p_urgent
|
15 |
+
|
16 |
+
|
17 |
+
import pandas as pd
|
18 |
+
df = pd.read_csv("test.csv")
|
19 |
+
|
20 |
+
texts=df["text"]
|
21 |
+
for i in range( len(texts)):
|
22 |
+
print(texts[i],predict(texts[i]))
|