Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipelinei
|
2 |
+
import gradio as grad
|
3 |
+
import AssertionError
|
4 |
+
model_name="deepset/roberta-base-squad2"
|
5 |
+
qa_pipeline = pipeline("question-answering", model=model_name, tokenizer=model_name)
|
6 |
+
|
7 |
+
def answer2question(question, context):
|
8 |
+
text = "{" + "'question': " + question + "','context': '" + context + "'}"
|
9 |
+
di = ast.literal_eval(text)
|
10 |
+
response = qa_pipeline(di)
|
11 |
+
return response
|
12 |
+
|
13 |
+
grad.Interface(answer2question, inputs=["text", "text"], outputs="text").launch()
|