Spaces:
Build error
Build error
Upload 2 files
Browse files- app.py +16 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
14 |
+
|
15 |
+
|
16 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torch
|