JK-TK commited on
Commit
f0dbd5b
·
1 Parent(s): 49155ea

Updating

Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ grad.Interface(answer_question, inputs=["text","text"], outputs="text").launch()