Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
·
bff723d
1
Parent(s):
424be87
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,29 @@ description = "Gradio Demo for ELECTRA. To use it, simply add your text, or clic
|
|
| 6 |
|
| 7 |
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>"
|
| 8 |
|
|
|
|
| 9 |
examples = [
|
| 10 |
-
["My name is Sarah and I live in London","Where do I live?"]
|
| 11 |
]
|
| 12 |
|
| 13 |
-
gr.Interface.load("huggingface/ahotrod/electra_large_discriminator_squad2_512"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
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>"
|
| 8 |
|
| 9 |
+
|
| 10 |
examples = [
|
| 11 |
+
["My name is Sarah and I live in London","electra_large_discriminator_squad2_512","Where do I live?"]
|
| 12 |
]
|
| 13 |
|
| 14 |
+
io1 = gr.Interface.load("huggingface/ahotrod/electra_large_discriminator_squad2_512")
|
| 15 |
+
|
| 16 |
+
io2 = gr.Interface.load("huggingface/deepset/electra-base-squad2")
|
| 17 |
+
|
| 18 |
+
def inference(context, model,question):
|
| 19 |
+
if model == "electra_large_discriminator_squad2_512":
|
| 20 |
+
outlabel = io1(context,question)
|
| 21 |
+
else:
|
| 22 |
+
outlabel = io2(context,question)
|
| 23 |
+
return outlabel
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
gr.Interface(
|
| 27 |
+
inference,
|
| 28 |
+
[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")],
|
| 29 |
+
[gr.outputs.Textbox(label="Output")],
|
| 30 |
+
examples=examples,
|
| 31 |
+
article=article,
|
| 32 |
+
title=title,
|
| 33 |
+
description=description).launch(enable_queue=True, cache_examples=True)
|
| 34 |
+
|