abhi227070's picture
Create app.py
c57ccc5 verified
raw
history blame
795 Bytes
from transformers import pipeline
import gradio as gr
question_answer = pipeline('question-answering',model = 'distilbert/distilbert-base-cased-distilled-squad')
output = pipe({
'context': context,
'question': question
})
def question_answering(context, question):
output = question_answer({
'context': context,
'question': question
})
return output['answer'], str(output['score'] * 100)
iface = gr.Interface(
fn = question_answering,
inputs = [
gr.Textbox(label = "Context", placeholder = "Enter your context here..", lines = 5),
gr.Textbox(label = "Question", placeholder = "Enter your question", lines = 2)
],
outputs = [
gr.Textbox(label = "Answer", lines = 2),
gr.Textbox(label = "Accuracy")
]
)