File size: 1,329 Bytes
c827bd8
 
 
 
 
 
 
 
bff723d
c827bd8
bff723d
c827bd8
 
bff723d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9cc9ee4
bff723d
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
import gradio as gr

title = "ELECTRA"

description = "Gradio Demo for ELECTRA. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."

article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2003.10555' target='_blank'>ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators</a></p>"


examples = [
    ["My name is Sarah and I live in London","electra_large_discriminator_squad2_512","Where do I live?"]
]

io1 = gr.Interface.load("huggingface/ahotrod/electra_large_discriminator_squad2_512")

io2 = gr.Interface.load("huggingface/deepset/electra-base-squad2")

def inference(context, model,question):
    if model == "electra_large_discriminator_squad2_512":
        outlabel = io1(context,question)
    else:
        outlabel = io2(context,question)
    return outlabel
     

gr.Interface(
    inference, 
    [gr.inputs.Textbox(label="Context",lines=10),gr.inputs.Dropdown(choices=["electra_large_discriminator_squad2_512","electra-base-squad2"], type="value", default="electra_large_discriminator_squad2_512", label="model"),gr.inputs.Textbox(label="Question Answering")], 
    [gr.outputs.Textbox(label="Output")],
    examples=examples,
    article=article,
    title=title,
    description=description).launch(enable_queue=True)