Dochee commited on
Commit
c86946c
1 Parent(s): 8fe4998

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForQuestionAnswering,AutoTokenizer, pipeline
2
+
3
+ import gradio as grad
4
+ import ast
5
+
6
+ mdl_name = "deepset/roberta-base-squad2"
7
+
8
+ my_pipeline = pipeline('question-answering', model=mdl_name,tokenizer=mdl_name)
9
+
10
+ def answer_question(question,context):
11
+
12
+ text= "{"+"'question': '"+question+"','context':'"+context+"'}"
13
+
14
+ di=ast.literal_eval(text)
15
+
16
+ response = my_pipeline(di)
17
+
18
+ return response
19
+
20
+ grad.Interface(answer_question, inputs=["text","text"],outputs="text").launch()