baadror commited on
Commit
7fed9b9
·
1 Parent(s): 375287a

example question

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -8,12 +8,18 @@ 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, context):
12
  # question, context = inputs
13
- pred = onnx_qa(question, context)['answer']
14
  return pred
15
 
16
 
 
 
 
 
 
 
17
  demo = gr.Blocks()
18
 
19
  with demo:
@@ -22,7 +28,8 @@ with demo:
22
  question = gr.Textbox(label='Question', lines= 3)
23
  b1 = gr.Button('Get Answer')
24
  answer = gr.Textbox(label='Answer', lines=4)
25
- b1.click(fn = get_answer, inputs=[question,context], outputs=answer)
 
26
 
27
  demo.launch()
28
 
 
8
 
9
  # question = "What's my name??"
10
  # context = "My name is Philipp and I live in Nuremberg."
11
+ def get_answer(context, question):
12
  # question, context = inputs
13
+ pred = onnx_qa(question, context)
14
  return pred
15
 
16
 
17
+ examples = [
18
+ ["""In supervised learning, input data is provided to the model along with the output. In unsupervised learning, only input data is provided to the model. The goal of supervised learning is to train the model so that it can predict the output when it is given new data.""", "Explain supervised learning",],
19
+ # [] # You can add context examples without questions
20
+ ]
21
+
22
+
23
  demo = gr.Blocks()
24
 
25
  with demo:
 
28
  question = gr.Textbox(label='Question', lines= 3)
29
  b1 = gr.Button('Get Answer')
30
  answer = gr.Textbox(label='Answer', lines=4)
31
+ gr.Examples(examples= examples, inputs=[context, question], outputs=answer)
32
+ b1.click(fn = get_answer, inputs=[context, question], outputs=answer)
33
 
34
  demo.launch()
35