kumaranke commited on
Commit
9ce457f
1 Parent(s): c65de50

Create app.py

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