Wootang01 commited on
Commit
5e14ce4
·
1 Parent(s): 679333b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -1,14 +1,12 @@
1
  import gradio as gr
2
- from bert import QA
3
 
4
- model = QA('bert-large-uncased-whole-word-masking-finetuned-squad')
 
 
5
 
6
- def qa_func(context, question):
7
- return model.predict(context, question)["answer"]
8
-
9
- gr.Interface(qa_func,
10
- [
11
- gr.inputs.Textbox(lines=7, label="Paragraph"),
12
- gr.inputs.Textbox(label="Question"),
13
- ],
14
- gr.outputs.Textbox(label="Answer")).launch()
 
1
  import gradio as gr
 
2
 
3
+ examples = [
4
+ ["It's rainy today but it will stop in a few hours", "What is the weather like in a few hours?"]
5
+ ]
6
 
7
+ gr.Interface.load("huggingface/deepset/roberta-base-squad2",
8
+ inputs=[gr.inputs.Textbox(lines=10, label="Context", placeholder="Type a sentence or paragraph here."),
9
+ gr.inputs.Textbox(lines=2, label="Question", placeholder="Ask a question based on the context.")],
10
+ outputs=[gr.outputs.Textbox(label="Answer"),
11
+ gr.outputs.Label(label="Probability")],
12
+ examples=examples).launch()