9wimu9 commited on
Commit
9999a2d
·
1 Parent(s): 2913cc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -1,5 +1,23 @@
1
  import gradio as gr
 
 
 
 
 
 
2
  def question_answer(context, question):
3
- pass # Implement your question-answering model here...
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- gr.Interface(fn=question_answer, inputs=["text", "text"], outputs=["textbox", "text"]).launch()
 
1
  import gradio as gr
2
+ from simpletransformers.question_answering import QuestionAnsweringModel, QuestionAnsweringArgs
3
+ import constants
4
+
5
+ model = QuestionAnsweringModel(
6
+ constants.MODEL_TYPE, constants.MODEL_NAME, use_cuda=constants.USE_CUDA
7
+ )
8
  def question_answer(context, question):
9
+ to_predict = [
10
+ {
11
+ "context": context,
12
+ "qas": [
13
+ {
14
+ "question": question,
15
+ "id": "0",
16
+ }
17
+ ],
18
+ }
19
+ ]
20
+ answers, probabilities = model.predict(to_predict)
21
+ return answers[0]['answer'][0]
22
 
23
+ gr.Interface(fn=question_answer, inputs=["text", "text"], outputs=["text"]).launch()