Spaces:
Runtime error
Runtime error
Benjamin Consolvo
commited on
Commit
•
6af5526
1
Parent(s):
7dcde50
examples included
Browse files
app.py
CHANGED
@@ -24,28 +24,28 @@ def predict(context,question):
|
|
24 |
return score,answer,start
|
25 |
|
26 |
md = """
|
27 |
-
|
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),
|
|
|
|
|
35 |
"""
|
36 |
|
37 |
# predict()
|
38 |
context=gr.Text(lines=10,label="Context")
|
39 |
question=gr.Text(label="Question")
|
|
|
40 |
score=gr.Text(label="Score")
|
41 |
start=gr.Text(label="Answer found at character")
|
42 |
-
|
43 |
-
|
44 |
iface = gr.Interface(
|
45 |
fn=predict,
|
46 |
inputs=[context,question],
|
47 |
-
outputs=[score,start
|
48 |
-
examples=[],
|
49 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
50 |
description = md
|
51 |
)
|
|
|
24 |
return score,answer,start
|
25 |
|
26 |
md = """
|
27 |
+
Introduction: 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 |
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).
|
30 |
|
31 |
+
The training dataset used is the English Wikipedia dataset (2500M words), and then fine-tuned on 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).
|
32 |
+
|
33 |
+
Author of Hugging Face Space: Benjamin Consolvo, AI Solutions Engineer Manager at Intel\nDate last updated: 01/05/2023
|
34 |
"""
|
35 |
|
36 |
# predict()
|
37 |
context=gr.Text(lines=10,label="Context")
|
38 |
question=gr.Text(label="Question")
|
39 |
+
answer=gr.Text(label="Answer")
|
40 |
score=gr.Text(label="Score")
|
41 |
start=gr.Text(label="Answer found at character")
|
42 |
+
apple_context = "An apple is an edible fruit produced by an apple tree (Malus domestica). Apple trees are cultivated worldwide and are the most widely grown species in the genus Malus. The tree originated in Central Asia, where its wild ancestor, Malus sieversii, is still found today. Apples have been grown for thousands of years in Asia and Europe and were brought to North America by European colonists. Apples have religious and mythological significance in many cultures, including Norse, Greek, and European Christian tradition. Apples grown from seed tend to be very different from those of their parents, and the resultant fruit frequently lacks desired characteristics. Generally, apple cultivars are propagated by clonal grafting onto rootstocks. Apple trees grown without rootstocks tend to be larger and much slower to fruit after planting. Rootstocks are used to control the speed of growth and the size of the resulting tree, allowing for easier harvesting."
|
43 |
+
apple_question = "How many years have apples been grown for?"
|
44 |
iface = gr.Interface(
|
45 |
fn=predict,
|
46 |
inputs=[context,question],
|
47 |
+
outputs=[answer,score,start],
|
48 |
+
examples=[[apple_context],[apple_question]],
|
49 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
50 |
description = md
|
51 |
)
|