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()