from transformers import pipeline import gradio as gr # Load zero-shot classification pipeline classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") # Define possible topics candidate_labels = ["politics", "sports", "technology", "education", "health", "entertainment", "climate change", "economy", "science", "travel"] def classify_topic(text): result = classifier(text, candidate_labels) top_label = result['labels'][0] score = round(result['scores'][0], 2) return f"🏷️ Topic: {top_label} (Confidence: {score})" # Gradio UI iface = gr.Interface(fn=classify_topic, inputs="text", outputs="text", title="Intent / Topic Classifier") iface.launch()