import subprocess # Install transformers library subprocess.check_call(["pip", "install", "transformers"]) subprocess.check_call(["pip", "install", "torch"]) import gradio as gr from transformers import pipeline # Replace this with your own checkpoint model_checkpoint = "huggingface-course/bert-finetuned-squad" question_answerer = pipeline("question-answering", model=model_checkpoint) def answer_question(question, context): answer = question_answerer(question=question, context=context) return answer['answer'], answer['score'], answer['start'], answer['end'] iface = gr.Interface( fn=answer_question, inputs=["text", "text"], outputs=["text", "number", "number", "number"], title="Extractive Question Answering" ) iface.launch()