ttphong68 commited on
Commit
c57473d
·
1 Parent(s): 43e258c

Create app.py

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