eloi-goncalves commited on
Commit
5c2f8ce
1 Parent(s): 80b26db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -1,7 +1,15 @@
1
- import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
2
+ import gradio as grad
3
+ import ast
4
 
5
+ mdl_name = "deepset/roberta-base-squad2"
6
+ my_pipeline = pipeline('question-answering', model=mdl_name, tokenizer=mdl_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
+
14
+ grad.Interface(answer_question, inputs=["text","text"], outputs="text").launch()
15
+ Listing 5-1Code for app.py