Jaehan commited on
Commit
1ea7b52
1 Parent(s): 05ccf6b

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, pipelinei
2
+ import gradio as grad
3
+ import AssertionError
4
+ model_name="deepset/roberta-base-squad2"
5
+ qa_pipeline = pipeline("question-answering", model=model_name, tokenizer=model_name)
6
+
7
+ def answer2question(question, context):
8
+ text = "{" + "'question': " + question + "','context': '" + context + "'}"
9
+ di = ast.literal_eval(text)
10
+ response = qa_pipeline(di)
11
+ return response
12
+
13
+ grad.Interface(answer2question, inputs=["text", "text"], outputs="text").launch()