Spaces:
Runtime error
Runtime error
Benjamin Consolvo
commited on
Commit
·
6da417a
1
Parent(s):
f905eda
inputs outputs for context
Browse files
app.py
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
|
6 |
def greet(name):
|
7 |
return "Hello " + name + "!!"
|
8 |
|
9 |
-
def predict(
|
10 |
-
|
|
|
11 |
return predictions
|
12 |
|
13 |
md = """
|
@@ -17,10 +18,13 @@ Based on the [Prune Once for All: Sparse Pre-Trained Language Models](https://ar
|
|
17 |
|
18 |
"""
|
19 |
|
|
|
|
|
|
|
20 |
iface = gr.Interface(
|
21 |
fn=predict,
|
22 |
-
inputs="
|
23 |
-
outputs="
|
24 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
25 |
description = md
|
26 |
)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
qa_pipeline = pipeline(task="question-answering",model="Intel/bert-base-uncased-squadv1.1-sparse-80-1x4-block-pruneofa")
|
5 |
|
6 |
def greet(name):
|
7 |
return "Hello " + name + "!!"
|
8 |
|
9 |
+
def predict(question,context):
|
10 |
+
|
11 |
+
predictions = qa_pipeline(context=context,question=question)
|
12 |
return predictions
|
13 |
|
14 |
md = """
|
|
|
18 |
|
19 |
"""
|
20 |
|
21 |
+
context = "The Amazon rainforest, also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname and French Guiana. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species."
|
22 |
+
question = "Which continent is the Amazon rainforest in?"
|
23 |
+
|
24 |
iface = gr.Interface(
|
25 |
fn=predict,
|
26 |
+
inputs=[gr.inputs.Textbox(lines=5, default=context, label="Context Paragraph"), gr.inputs.Textbox(lines=2, default=question, label="Question")],
|
27 |
+
outputs=[gr.outputs.Textbox(label="Answer"), gr.outputs.Textbox(label="Score")],
|
28 |
title = "Question & Answer with Sparse BERT using the SQuAD dataset",
|
29 |
description = md
|
30 |
)
|