ayush2917 commited on
Commit
9db42cc
·
verified ·
1 Parent(s): 98125d3

Upload model/intent_classifier.py

Browse files
Files changed (1) hide show
  1. intent_classifier.py +11 -0
intent_classifier.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ from config import MODEL_NAME, INTENT_LABELS
3
+
4
+ # Load zero-shot classification pipeline
5
+ classifier = pipeline("zero-shot-classification", model=MODEL_NAME)
6
+
7
+ def classify_conversation(conversation_text):
8
+ result = classifier(conversation_text, INTENT_LABELS)
9
+ top_label = result['labels'][0]
10
+ rationale = f"Conversation was classified as '{top_label}' because the final messages indicate a likely intent of {top_label.lower()}."
11
+ return top_label, rationale