Jaehan commited on
Commit
67a2f10
1 Parent(s): 01e8b06

Update app.py

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