fsaglam2002 commited on
Commit
86f1f69
·
verified ·
1 Parent(s): 715072b

Create app.py

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