baadror commited on
Commit
090f39a
·
1 Parent(s): c64851f

Allow to put context as well

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -6,10 +6,10 @@ tokenizer = AutoTokenizer.from_pretrained("deepset/roberta-base-squad2")
6
 
7
  onnx_qa = pipeline("question-answering", model=model, tokenizer=tokenizer)
8
 
9
- question = "What's my name??"
10
- context = "My name is Philipp and I live in Nuremberg."
11
  def get_answer(question):
12
- pred = onnx_qa(question, context)
13
  return pred
14
 
15
 
@@ -17,6 +17,7 @@ demo = gr.Blocks()
17
 
18
  with demo:
19
  with gr.Row():
 
20
  question = gr.Textbox(label='Question', lines= 3)
21
  b1 = gr.Button('Get Answer')
22
  answer = gr.Textbox(label='Answer', lines=4)
 
6
 
7
  onnx_qa = pipeline("question-answering", model=model, tokenizer=tokenizer)
8
 
9
+ # question = "What's my name??"
10
+ # context = "My name is Philipp and I live in Nuremberg."
11
  def get_answer(question):
12
+ pred = onnx_qa(question, context)['answer']
13
  return pred
14
 
15
 
 
17
 
18
  with demo:
19
  with gr.Row():
20
+ context = gr.Textbox(label='Document', lines=10)
21
  question = gr.Textbox(label='Question', lines= 3)
22
  b1 = gr.Button('Get Answer')
23
  answer = gr.Textbox(label='Answer', lines=4)