Spaces:
Sleeping
Sleeping
BilalSardar
commited on
Commit
·
b524623
1
Parent(s):
8a4478b
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
2 |
+
import gradio as gr
|
3 |
+
# Creating the Q&A pipeline
|
4 |
+
nlp = pipeline('question-answering', model='deepset/roberta-base-squad2', tokenizer='deepset/roberta-base-squad2')
|
5 |
+
|
6 |
+
def questionAndAnswer(ques,content):
|
7 |
+
question_set = {'question':ques,'context':content}
|
8 |
+
results = nlp(question_set)
|
9 |
+
return results['answer']
|
10 |
+
|
11 |
+
interface = gr.Interface(fn=questionAndAnswer,
|
12 |
+
inputs=["text","text"],
|
13 |
+
outputs="text",
|
14 |
+
title='Bilal Question&Answer')
|
15 |
+
|
16 |
+
|
17 |
+
interface.launch(inline=False)
|
18 |
+
|