Spaces:
Running
Running
Benjamin Consolvo
commited on
Commit
·
33ff5cc
1
Parent(s):
debe187
text box
Browse files
app.py
CHANGED
|
@@ -6,9 +6,13 @@ qa_pipeline = pipeline(task="question-answering",model="Intel/bert-base-uncased-
|
|
| 6 |
def greet(name):
|
| 7 |
return "Hello " + name + "!!"
|
| 8 |
|
| 9 |
-
def predict(
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
print(f'predictions={predictions}')
|
| 13 |
return predictions
|
| 14 |
|
|
@@ -21,14 +25,15 @@ Based on the Zafrir et al. (2021) paper: [Prune Once for All: Sparse Pre-Trained
|
|
| 21 |
|
| 22 |
"""
|
| 23 |
|
| 24 |
-
predict()
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
#
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
| 6 |
def greet(name):
|
| 7 |
return "Hello " + name + "!!"
|
| 8 |
|
| 9 |
+
def predict(context="There are seven continents in the world.",question="How many continents are there in the world?"):
|
| 10 |
+
'''
|
| 11 |
+
Sample prediction should return a dictionary of the form:
|
| 12 |
+
{'score': 0.9376363158226013, 'start': 10, 'end': 15, 'answer': 'seven'}
|
| 13 |
|
| 14 |
+
'''
|
| 15 |
+
predictions = qa_pipeline(context=context,question=question)
|
| 16 |
print(f'predictions={predictions}')
|
| 17 |
return predictions
|
| 18 |
|
|
|
|
| 25 |
|
| 26 |
"""
|
| 27 |
|
| 28 |
+
# predict()
|
| 29 |
|
| 30 |
+
iface = gr.Interface(
|
| 31 |
+
fn=predict,
|
| 32 |
+
inputs=[gr.TextBox('Context'),gr.TextBox('Question')],
|
| 33 |
+
outputs="text",
|
| 34 |
+
# examples =
|
| 35 |
+
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
| 36 |
+
description = md
|
| 37 |
+
)
|
| 38 |
|
| 39 |
+
iface.launch()
|