CoolFace
Apppublic

adorkin/zero-shot-classification-nli-bilingual

sourceHugging Faceupdated 1y agoView on Hugging Face
1likes
app.py31 linesDownload Raw Back to root
1from transformers import pipeline2import gradio as gr3 4classifier = pipeline("zero-shot-classification", model="DeepPavlov/xlm-roberta-large-en-ru-mnli")5 6def wrap_classifier(text, labels, template):7    labels = labels.split(",")8    outputs = classifier(text, labels, hypothesis_template=template)9    return outputs["labels"][0]10 11gr.Interface(12    fn=wrap_classifier,13    title="Zero-shot Classification",14    inputs=[15        gr.Textbox(16            lines=3,17            label="Text to classify",18            value="Sneaky Credit Card Tactics Keep an eye on your credit card issuers -- they may be about to raise your rates."19            ),20        gr.Textbox(21            lines=1,22            label="Candidate labels separated with commas (no spaces)",23            value="World,Sports,Business,Sci/Tech",24            placeholder="World,Sports,Business,Sci/Tech",25            ),26        gr.Textbox(lines=1, label="Template", value="The topic of this text is {}.", placeholder="The topic of this text is {}.")27    ],28    outputs=[29        gr.Label(label="Predicted label")30    ],31).launch()