File size: 730 Bytes
868a964
 
 
 
 
644ccb4
5f1e0b9
 
868a964
 
 
 
 
 
 
 
 
5f1e0b9
868a964
5f1e0b9
868a964
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

pipe = pipeline("question-answering", model="huggingface-course/bert-finetuned-squad")

def qa(question, context):
    result = pipe(question=question, context=context)
    return result['answer'], result['score']

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            question = gr.Textbox(label= 'Question')
            context = gr.Textbox(label= 'Context')
            submit_btn = gr.Button(value = 'Submit')
        with gr.Column():
            answer = gr.Textbox(label= 'Answer')
            score = gr.Textbox(label= 'Score')

    submit_btn.click(qa, inputs = [question, context], outputs = [answer, score])

demo.launch()