File size: 795 Bytes
c57ccc5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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")
]
) |