File size: 1,001 Bytes
294b12e
cc5f086
857c438
 
add8153
857c438
ea8cf54
857c438
412347c
c8f8664
857c438
412347c
857c438
 
 
ea8cf54
857c438
 
 
c70e210
857c438
 
 
 
ea8cf54
72a4157
c70e210
857c438
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from transformers import pipeline 
import torch
import gradio as gr #this is in place of the streamlit of the HF video

title = "Saras second try categorizes statements [as business, education, law, politics]"
description = "Based on a zero-shot-classification model (default facebook/bart-large-mnli)"
examples = [["The president was elected last week then convicted of ten crimes and imprisoned, though he was paid $10,000 for his trouble"]]

classifier = pipeline("zero-shot-classification")

#heres the prediction function tp predict the response and add it to history
def predict(input):
    # generate a response
    response = classifier(
        input,
        candidate_labels=["education", "politics", "business","law"],
    )
    return response

#see https://www.gradio.app/guides/quickstart
gr.Interface(
    fn=predict,
    title=title,
    description=description,
    examples=examples,
    inputs=["text"],
    outputs=["text"],
    theme="finlaymacklon/boxy_violet",
).launch()