Spaces:
Runtime error
Runtime error
Benjamin Consolvo
commited on
Commit
•
7dcde50
1
Parent(s):
08009f0
description updated
Browse files
app.py
CHANGED
@@ -6,11 +6,14 @@ qa_pipeline = pipeline(task="question-answering",model="Intel/bert-base-uncased-
|
|
6 |
def greet(name):
|
7 |
return "Hello " + name + "!!"
|
8 |
|
9 |
-
def predict(context
|
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}')
|
@@ -21,11 +24,14 @@ def predict(context="There are seven continents in the world.",question="How man
|
|
21 |
return score,answer,start
|
22 |
|
23 |
md = """
|
24 |
-
|
|
|
25 |
|
26 |
-
|
27 |
-
Training dataset: SQuADv1.1, based on the Rajpurkar et al. (2016) paper: [SQuAD: 100,000+ Questions for Machine Comprehension of Text](https://aclanthology.org/D16-1264/)
|
28 |
|
|
|
|
|
|
|
29 |
"""
|
30 |
|
31 |
# predict()
|
@@ -39,6 +45,7 @@ iface = gr.Interface(
|
|
39 |
fn=predict,
|
40 |
inputs=[context,question],
|
41 |
outputs=[score,start,answer],
|
|
|
42 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
43 |
description = md
|
44 |
)
|
|
|
6 |
def greet(name):
|
7 |
return "Hello " + name + "!!"
|
8 |
|
9 |
+
def predict(context,question):
|
10 |
'''
|
11 |
Sample prediction should return a dictionary of the form:
|
12 |
{'score': 0.9376363158226013, 'start': 10, 'end': 15, 'answer': 'seven'}
|
13 |
+
Score is the probability confidence score
|
14 |
+
Start is the starting character where it found the answer
|
15 |
+
End is the ending character where it found the answer
|
16 |
+
Answer is the part of the text it drew its answer from.
|
17 |
'''
|
18 |
predictions = qa_pipeline(context=context,question=question)
|
19 |
print(f'predictions={predictions}')
|
|
|
24 |
return score,answer,start
|
25 |
|
26 |
md = """
|
27 |
+
Author of Hugging Face Space: Benjamin Consolvo, AI Solutions Engineer Manager at Intel \n
|
28 |
+
Date last updated: 01/05/2023
|
29 |
|
30 |
+
[b]Introduction[\b]: 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.
|
|
|
31 |
|
32 |
+
The model is based on the Zafrir et al. (2021) paper: [Prune Once for All: Sparse Pre-Trained Language Models](https://arxiv.org/abs/2111.05754).
|
33 |
+
|
34 |
+
The training dataset used is the English Wikipedia dataset (2500M words), followed by the SQuADv1.1 dataset containing 89K training examples by Rajpurkar et al. (2016): [100, 000+ questions for machine comprehension of text](https://arxiv.org/abs/1606.05250)
|
35 |
"""
|
36 |
|
37 |
# predict()
|
|
|
45 |
fn=predict,
|
46 |
inputs=[context,question],
|
47 |
outputs=[score,start,answer],
|
48 |
+
examples=[],
|
49 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
50 |
description = md
|
51 |
)
|