Multi-Turn_Intent_Classification / intent_classifier.py
ayush2917's picture
Upload model/intent_classifier.py
9db42cc verified
raw
history blame contribute delete
513 Bytes
from transformers import pipeline
from config import MODEL_NAME, INTENT_LABELS
# Load zero-shot classification pipeline
classifier = pipeline("zero-shot-classification", model=MODEL_NAME)
def classify_conversation(conversation_text):
result = classifier(conversation_text, INTENT_LABELS)
top_label = result['labels'][0]
rationale = f"Conversation was classified as '{top_label}' because the final messages indicate a likely intent of {top_label.lower()}."
return top_label, rationale