Spaces:
Runtime error
Runtime error
subrota2k2
commited on
Commit
•
81cad45
1
Parent(s):
1690a12
Upload 2 files
Browse files- app.py +15 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
2 |
+
import gradio as grad
|
3 |
+
import ast
|
4 |
+
|
5 |
+
mdl_name = "distilbert-base-cased-distilled-squad"
|
6 |
+
my_pipeline = pipeline('question-answering', model=mdl_name, tokenizer=mdl_name)
|
7 |
+
|
8 |
+
|
9 |
+
def answer_question(question,context):
|
10 |
+
text= "{"+"'question': '"+question+"','context': '"+context+"'}"
|
11 |
+
|
12 |
+
di=ast.literal_eval(text)
|
13 |
+
response = my_pipeline(di)
|
14 |
+
return response
|
15 |
+
grad.Interface(answer_question, inputs=["text","text"], outputs="text").launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torch
|