Case-Classification / zero-shot-classification.py
Jorge Fioranelli
Added zero-shot and distilbert models
6f0a968
raw
history blame
655 Bytes
import gradio as gr
from transformers import pipeline
classifier = pipeline("zero-shot-classification")
labels = ["Connectivity", "Billing", "Setup"]
def predict(text):
preds = classifier(text, candidate_labels=labels)
return {label: float(pred) for label, pred in zip(preds["labels"], preds["scores"])}
input = gr.inputs.Textbox(label="Customer Sentence")
output = gr.outputs.Label(num_top_classes=4, label="Zero-Shot-Classification")
title = "Case Classification"
description = "Zero-Shot-Classification test"
gr.Interface(predict, input, output, live=True, title=title, analytics_enabled=False,
description=description).launch()