Spaces:
Running
Running
eloi-goncalves
commited on
Commit
•
5c2f8ce
1
Parent(s):
80b26db
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,15 @@
|
|
1 |
-
import
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|