Spaces:
Runtime error
Runtime error
Updated app.py with pretrained model
Browse files
app.py
CHANGED
|
@@ -1,10 +1,17 @@
|
|
| 1 |
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
| 3 |
import gradio as gr
|
| 4 |
+
|
| 5 |
+
nlp = pipeline('question-answering', model='deepset/roberta-base-squad2', tokenizer='deepset/roberta-base-squad2')
|
| 6 |
+
|
| 7 |
+
def qnamodel(ques,content):
|
| 8 |
+
question_set = {'question':ques,'context':content}
|
| 9 |
+
results = nlp(question_set)
|
| 10 |
+
return results['answer']
|
| 11 |
+
|
| 12 |
+
interface = gr.Interface(fn=qnamodel,
|
| 13 |
+
inputs=["text","text"],
|
| 14 |
+
outputs="text",
|
| 15 |
+
title='Context Question Answering')
|
| 16 |
+
|
| 17 |
+
interface.launch(inline=False)
|