Iosif24 commited on
Commit
6e7bd9e
·
1 Parent(s): 6bb0713

Create app.py

Browse files

first commit QnA

Files changed (1) hide show
  1. app.py +13 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
2
+ import gradio as grad
3
+ import ast
4
+
5
+ model_name = "deepset/roberta-base-squad2"
6
+ my_pipeline = pipeline('question-answering', model=model_name, tokenizer=model_name)
7
+
8
+ def answer_question(question, context):
9
+ text = "{"+"'question': '"+question"', 'context': '"+context+"'}"
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()