sohailq commited on
Commit
c2ec267
1 Parent(s): 5443ba2

Create app.py

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