Spaces:
Runtime error
Runtime error
Benjamin Consolvo
commited on
Commit
•
cc29eef
1
Parent(s):
33ff5cc
gradio inputs outputs
Browse files
app.py
CHANGED
@@ -14,7 +14,9 @@ def predict(context="There are seven continents in the world.",question="How man
|
|
14 |
'''
|
15 |
predictions = qa_pipeline(context=context,question=question)
|
16 |
print(f'predictions={predictions}')
|
17 |
-
|
|
|
|
|
18 |
|
19 |
md = """
|
20 |
If you came looking for chatGPT, sorry to disappoint, but this is different. This prediction model is designed to answer a question about a text. It is designed to do reading comprehension. The model does not just answer questions in general -- it only works from the text that you provide. However, accomplishing accurate reading comprehension can be a very valuable task, especially if you are attempting to get quick answers from a large (and maybe boring!) document.
|
@@ -26,12 +28,15 @@ Based on the Zafrir et al. (2021) paper: [Prune Once for All: Sparse Pre-Trained
|
|
26 |
"""
|
27 |
|
28 |
# predict()
|
|
|
|
|
|
|
|
|
29 |
|
30 |
iface = gr.Interface(
|
31 |
fn=predict,
|
32 |
-
inputs=[
|
33 |
-
outputs=
|
34 |
-
# examples =
|
35 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
36 |
description = md
|
37 |
)
|
|
|
14 |
'''
|
15 |
predictions = qa_pipeline(context=context,question=question)
|
16 |
print(f'predictions={predictions}')
|
17 |
+
score = predictions['score']
|
18 |
+
answer = predictions['answer']
|
19 |
+
return score,answer
|
20 |
|
21 |
md = """
|
22 |
If you came looking for chatGPT, sorry to disappoint, but this is different. This prediction model is designed to answer a question about a text. It is designed to do reading comprehension. The model does not just answer questions in general -- it only works from the text that you provide. However, accomplishing accurate reading comprehension can be a very valuable task, especially if you are attempting to get quick answers from a large (and maybe boring!) document.
|
|
|
28 |
"""
|
29 |
|
30 |
# predict()
|
31 |
+
context=gr.Text(label="Context")
|
32 |
+
question=gr.Text(label="Question")
|
33 |
+
score=gr.Text(label="Score")
|
34 |
+
answer=gr.Text(label="Answer")
|
35 |
|
36 |
iface = gr.Interface(
|
37 |
fn=predict,
|
38 |
+
inputs=[context,question],
|
39 |
+
outputs=[score,answer],
|
|
|
40 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
41 |
description = md
|
42 |
)
|